Kafka alPakka throwing compile issues when using restart source - alpakka

Trying to use restart with source in case of Kafka rebalance , however below code is throwing error when using Alpakka Kafka library
Throwing complies error while using below code
Caused by: java.lang.ClassCastException: akka.NotUsed$ cannot be cast to java.util.concurrent.CompletionStage
CompletionStage<Done> streamCompletion =
RestartSource.onFailuresWithBackoff(
restartSettings,
() ->
Consumer.plainSource(consumerSettings, Subscriptions.topics(topic))
.mapMaterializedValue(
c -> {
// this is a hack to get access to the Consumer.Control
// instances of the latest Kafka Consumer source
control.set(c);
return c;
})
.via(business()))
.runWith(Sink.ignore(), system);

Related

SignalR-Client-Cpp on Petalinux Throwing "Error in SSL handshake" Exception

I have a Xilinx ZCU106 with a Petalinux build I created that includes an application using SignalR-Client-Cpp. Despite trying a number of things, I'm continually getting an "Error in SSL handshake" exception after calling start() on my signalr::hub_connection.
This application runs fine on other Linux systems like Ubuntu. I think the problem is it's having trouble finding the ca-certificates.crt file which is usually in /usr/local/ssl on more normal Linux distro's like Ubuntu. In the Petalinux build it's located here: /etc/ssl/certs/ca-certificates.crt.
The best I can tell, I need to do something like this to configure the signalr::hub_connection to use the certificate file:
web::http::client::http_client_config httpConfig;
httpConfig.set_ssl_context_callback([](boost::asio::ssl::context& ctx) {
ctx.load_verify_file("/etc/ssl/certs/ca-certificates.crt"); });
web::websockets::client::websocket_client_config wsConfig;
wsConfig.set_ssl_context_callback([](boost::asio::ssl::context& ctx) {
ctx.load_verify_file("/etc/ssl/certs/ca-certificates.crt"); });
signalr::signalr_client_config signalrConfig;
signalrConfig.set_http_client_config(httpConfig);
signalrConfig.set_websocket_client_config(wsConfig);
auto hubConn = signalr::hub_connection_builder::create(signalrURI).build();
hubConn.set_client_config(signalrConfig);
std::promise<void> task;
hubConn.start([&task](std::exception_ptr exception) {
// Code that checks the exception, etc
Yet, even when doing this, the exception that is passed into start() is populated, stating "Error in SSL handshake".
I've tried some other things like using web::credentials and setting those on the signalr_client_config before giving it to the hub_connection but I get the same results.
I'm out of ideas as to how to get this to work and I'm hoping someone else might have some ideas?

Connecting to a local database using mysql-cpp-connector

Introduction
I am new to using mysql in c++ and have been trying to use mysqlcppconnector for connecting to my local database. I have successfully linked the libraries after a lot of effort. (It wasn't straightforward for me)
Preparation
I am using the following code to connect with a database running on my local.
#include <mysqlx/xdevapi.h>
void make_db_connection() {
mysqlx::Session sess("localhost", 33060, "mudrex", "mudrex");
mysqlx::Schema db= sess.getSchema("mudrex");
// or Schema db(sess, "test");
mysqlx::Collection myColl = db.getCollection("user_api_key_map");
// or Collection myColl(db, "my_collection");
mysqlx::DocResult myDocs = myColl.find("user_id")
.limit(1)
.bind("user_id","L%").execute();
cout << myDocs.fetchOne()<<endl;
}
Errors
When I call the above function, I get the following error :
libc++abi.dylib: terminating with uncaught exception of type mysqlx::abi2::r0::Error: CDK Error: Connection refused (generic:61)
Abort trap: 6
Any help would be really appreciated. Thank you for your time.
mysqlx::Session is for connection to the MySQL X protocol. The Error: Connection refused is the very first hint of missing listeners of the port 33060. You need to install and enable the MySQL Shell that supports X Protocol and enables you to use X DevAPI. See https://dev.mysql.com/doc/mysql-shell/en/mysql-shell-install.html for instructions.

Using libhttpserver to build https server

I am trying to compile the below piece of code to run a basic https server and i am encountering an error which i am not able to resolve. The class hello_world_resource is responsible for the server startup and the return statement gives the response that the server should give when it is accessed.
the url for the server is defined by function 'register_resource'
the url for the github documentation of the library - https://github.com/etr/libhttpserver
I've tried downloading ssl and curl multiple times and searched the google too but i am still not able to find the cause for this problem.
abcd.key and xyz.crt are the self-signed certificates that i generated following this procedure online -
https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-16-04
#include <httpserver.hpp>
using namespace httpserver;
class hello_world_resource : public http_resource
{
public:
const std::shared_ptr<http_response> render(const http_request&)
{
return std::shared_ptr<http_response>(new
string_response("Hello, World!"));
}
};
int main()
{
webserver ws = create_webserver(8080)
.use_ssl()
.https_mem_key("/path/to/abcd.key")
.https_mem_cert("/path/to/xyz.crt");
hello_world_resource hwr;
ws.register_resource("/hello", &hwr);
ws.start(true);
return 0;
}
The error being thrown is :
terminate called after throwing an instance of 'std::invalid_argument'
what(): BD
A
(G BBJ
Aborted
the code should run and a server should be available at - https://localhost:8080/hello

System.Web.Services.Protocols.SoapException The application encountered an unhandled system exception. From binary file

I have a project in .net that accesses a GP Web Services, it works fine. However when I generate a dll from this project and try to run the same from a different project using this dll, I get the following message: System.Web.Services.Protocols.SoapException The application encountered an unhandled system exception. Contact your system administrator for details.
I think it might be a permissions issue or something like this but I'm not sure, this is how the client is created:
WSHttpBinding binding = new WSHttpBinding();
EndpointAddress ep = new EndpointAddress(new Uri("..."), new UpnEndpointIdentity("..."), (AddressHeader[])null);
DynamicsGPClient wsDynamicsGP = new DynamicsGPClient(binding, ep);

Akka-ZMQ subscriber creation error (poll)

I successfully created publisher but failed to create subscriber by using the following:
public static void main(String [] args)
{
ActorSystem system = ActorSystem.create("System");
ActorRef subscriber = system.actorOf(new Props(Sub.class), "subscriber");
subscriber.tell(new MyActor("CharlieParker", 50, 25), subscriber);
}
public class Sub extends UntypedActor
{
ActorRef subSocket = ZeroMQExtension.get(getContext().system()).newSubSocket(
new Connect("tcp://127.0.0.1:1237"),
new Listener(getSelf()), Subscribe.all());
}
Got this error:
Uncaught error from thread [System-akka.zeromq.socket-dispatcher-7] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[System]
java.lang.NoSuchMethodError: org.zeromq.ZMQ$Poller.poll(J)J
at akka.zeromq.ConcurrentSocketActor$$anonfun$10.apply(ConcurrentSocketActor.scala:180)
at akka.zeromq.ConcurrentSocketActor$$anonfun$10.apply(ConcurrentSocketActor.scala:179)
at akka.zeromq.ConcurrentSocketActor.akka$zeromq$ConcurrentSocketActor$$doPoll(ConcurrentSocketActor.scala:197)
at akka.zeromq.ConcurrentSocketActor$$anonfun$receive$1.applyOrElse(ConcurrentSocketActor.scala:46)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425)
at akka.actor.ActorCell.invoke(ActorCell.scala:386)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230)
at akka.dispatch.Mailbox.run(Mailbox.scala:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
What does it mean?
I had the same type of error while trying to work with akka-zeromq and did some investigation on the subject. So the situation is the following: the error message states that it didn't find a method long poll(long timeout) in the class ZMQ.Poller (see this answer for the error message interpretation). This happens because of the following reasons
Akka is built with zeromq-scala bindings.
zeromq-scala is supposed to be compatible with jzmq , but unfortunately it's not at the moment because in scala bindings you have method long poll(long timeout) while in jzmq you have int poll(long timeout)
To overcome your problem locally you either have to rebuild Akka with zmq.jar, or use a quick and dirty workaround: change the return type for the method poll(long timeout) in jzmq ZMQ.Poller class and rebuild the java bindings. For more details and bindings compatibility discussion take a look here
However there is a global java/scala bindings compatibility problem, but it's outside of the scope of your question.
it seems like you are either missing or having the wrong version of zeromq-scala-binding on your path.
Which version of akka and zeromq are you using?