Search code examples
vert.xvertx-eventbus

Vert.x - Clustered Mode - Message buffering


I have no experience with vert.x Just exploring as it looks interesting.

My question is, when we use event-bus in the clustered mode with infinispan or hazelcast, 1 jvm instance sends a message to an address, another jvm instance which is the consumer of the messages is not available, will the infinispan buffer and deliver the message when the consumer comes up & gets that processed and respond back to the sender?


Solution

  • If there is no EventBus consumer registered for the given address, the message sender will get an error that says no consumer could be found at the specified address. The message will not be buffered and delivered when a consumer becomes available. This is mentioned in the Vert.x manual:

    Message sends can fail for other reasons, including:

    • There are no handlers available to send the message to

    • The recipient has explicitly failed the message using fail

    In all cases, the reply handler will be called with the specific failure.

    It works this way because Vert.x has no way of knowing whether or not a consumer will ever show up to handle the message, so it does not try to wait around to see if one will appear. If you have this kind of use-case, you need to code in retries on the client-side. In general, Vert.x uses what it calls "Best-effort delivery", so it's up users to provide any kind of reliability guarantees they need on their own.