0
votes

I am implementing a distributed system that runs a consensus protocol. The algorithm that I am using does not matter for my question. What I am concerned with is the communication between nodes in the system. I need a way to allow for asynchronous messaging between nodes. There are certain types of messages that should trigger an event in listening nodes. For example

(node_1) sendMessageA()              ---> (node_2, ..., node_n) recvMessageA()
(node_2, ..., node_n) sendMessageB() ---> (node_1) recvMessageB()
(node_1) sendMessageC()              ---> (node_2, ..., node_n) recvMessageC()
...

Basically, I have a function that might be called from a given node_i, and this should send a message to the other nodes in the system and trigger the appropriate function in the other nodes. These messages need to be asynchronous in this distributed system.

What are some good frameworks or tools to help allow for this type of communication?

I am aware of Netty, and ZeroMQ, which both seem relevant for this type of problem, but I don't have experience with either. Which one of these is better suited to this type of problem? Are there any better alternatives? I would prefer a framework that uses java, but I would consider technologies that use other languages as well.

2
Using RMI you can communicate between peers in plain java. If you stick to java and want to avoid the complexity of a second framework I would suggest to use this. - Martin Fernau

2 Answers

0
votes

I recommend you looking into JGroups. It is a Java based group communication toolkit. If you looking into the docs, you will see that you can add the required functionality by implementing the Protocol interface. It takes a bit to get used to it, but the documentation is excellent. Also, the community is quite large: you should be able to find help easily if you get stuck.

0
votes

The solution that I decided to use was Apache Thrift. Even though I didn't use it for cross-language communication, it was still very helpful because it allowed me to create a simple definition of the interface that I wanted to use between nodes, and then it auto-generated the appropriate classes. To quote their site:

Instead of writing a load of boilerplate code to serialize and transport your objects and invoke remote methods, you can get right down to business.

This was definitely true, and after a few hours of learning how Thrift works, I was able to set up communication with RPCs.