2

We are considering using a Message-broker to achieve a message-based publish-subscribe communication pattern.

Do you need to use Actor-model to be able to have message based pub/sub communications between your Microservices.

user217648
  • 3,338
  • 9
  • 37
  • 61

2 Answers2

1

Most message brokers allow both synchronous and asynchronous API. First you have to decide which API to use: synchronous or asynchronous. Synchronous is simpler, but uses blocking I/O operations. Blocking operation blocks a thread, and you have to keep as many threads as how many you have waiting I/O operations. Since each thread consumes significant amount of core memory, there is natural limit about 10000 threads per Java process. So first evaluate if you can afford to use synchronous API, and if yes, use it.

If the number of simultaneously circulating messages in one JVM exceeds 10000, then you have to use asynchronous API and asynchronous processing of messages. Actors are only one kind of asynchronous processing units. Others are CompletableFuture's from standard java, Observers from RxJava and other reactive libraries, or usually message brokers offer their own ways of asynchronous processing. Look at all that asynchronous libraries and choose what you like more.

Alexei Kaigorodov
  • 13,189
  • 1
  • 21
  • 38
0

Messages broker is just one of asynchronous mechanisms. Actor model is more wide notion, i.e. when messages are sent to local actors (i.e. running in the same program, in the same thread).

So, they are independent of each other: messages broker can be used without actors (i.e. redis, rabbit-mq, zero-mq), as well as actors can be implemented without message-broker.

Ivan Baidakou
  • 713
  • 9
  • 14