2

I have a C++ application that needs to send structured data to an Akka actor. The best option I found (Google, stackoverflow...) is to use protocol buffer and ZeroMQ, since it looks like everyone recommends it. However I struggled the whole day trying to make it work, having various crashes into my Scala actor code (with strange Windows socket errors). And when I take a deeper look at it, I notice that it seems zeromq disappeared from the Akka official documentation a while ago, and the most recent documentation I read about it said that ZeroMQ 3 was still not supported by zeromq-scala-bindings underneath (while the version 4 is already out).

Would it be a better option to use the Camel-netty extension and pass the information through JSON ?

Thanks !

CanardMoussant
  • 913
  • 8
  • 22
  • I never used Akka, so I will only speak about java, hoping it not differs that much. I use every day protocol buffer between C++ and Java and it is really a pleasure to configure and use. I recommend you to try harder making it work. You can give a shot to [swig](http://www.swig.org/) I never tried it but I only had good returns on it. – A. Ocannaille Feb 11 '16 at 16:31
  • Protocolbuffer sounds very good (I also used it before), my problem is more about the transport protocol. I would like minimum setup on Akka side, and it looks like receiving protocolbuffer from the outside world is not trivial. – CanardMoussant Feb 11 '16 at 17:08
  • So it seems to be a socket problem? In my case we used [this simple java snippet](http://cs.lmu.edu/~ray/notes/javanetexamples/) to make our socket work. We never had any difficulties to make protobuf work once the socket stabilized... Sorry, I Can't help you more, Good luck :-) – A. Ocannaille Feb 11 '16 at 17:14
  • If both applications are on the same device, A workaround avoiding sockets (and validating protobuf) would be to write the serialized data in files in a particular folder in an application and in the other pool regulary this same folder and unserialize the data in file (and then delete file). I think it could work. (If you are on linux consider using /run/shm/ folder to store these file in ram and not on disk to maximize performances) – A. Ocannaille Feb 11 '16 at 17:27
  • They are indeed on the same device for the moment, but if I can avoid to add any limitation I would be even happier. Thanks for the socket example, I will see :). I just wonder why ZeroMQ suddenly disappeared from Akka doc. – CanardMoussant Feb 12 '16 at 09:29
  • @Canard check out this communication from Typesafe regarding ZeroMQ https://www.typesafe.com/blog/akka-roadmap-update-2014 I'm not sure if anybody has taken up development of this since they moved it out of akka – justinhj Feb 15 '16 at 19:35
  • Excellent, this is exactly what I was looking for ! Thanks !! – CanardMoussant Feb 17 '16 at 07:22

1 Answers1

0

A fairly simple way would be to write a HTTP endpoint using Spray.io. Spray has JSON support and since it is built on Akka it communicates seamlessly with other Actors. This has the advantage that the data you send to the endpoint does not have to match the message format the Actor is expecting. You can change the message the actor is expecting without changing what your C++ code sends. For bi-directional communication there is also web socket support.

justinhj
  • 11,147
  • 11
  • 58
  • 104
  • Thanks for the input. Out of curiosity, do you know the pros/cons of what you propose versus what is in Akka documentation (the camel-netty extension) ? Since what I want to do is pretty simple, I am not sure I need all the features coming along Spray.io. – CanardMoussant Feb 15 '16 at 13:55
  • @Canard Good question. I don't think Camel is a bad choice at all, it seems well supported by Akka. I was more responding to your suggestion to use ZeroMQ which seems to be be a little more tricky since it has been kicked out of the official Akka distribution. The advantage of my approach is that you are essentially making a little microservice for talking with your C++ system. Less configuration to do and allows either side to change more easily. If you don't need those benefits Camel is a fine choice. – justinhj Feb 15 '16 at 19:39