2

I am new for event bus in Vert.x. In guidance https://vertx.io/docs/vertx-core/java/, it describes as following:

Best-effort delivery

Vert.x does its best to deliver messages and won’t consciously throw them away. This is called best-effort delivery.

If your application cares about lost messages, you should code your handlers to be idempotent, and your senders to retry after recovery.

My system doesn't expect to lose any messages, so I have to understand event bus and decide whether or not to use Vert.x. The following are my questions:

  1. what is typical scenario to lose messages for event bus?

  2. Suppose a scenario, producer is fast and consumer is slow. could producer perceive it and slow down sending? How to deal with this situation?

  3. Suppose another scenario, consumer register for event bus, then for some reason consumer doesn't work, at this time, does producer sending return exception? Or producer doesn't know consumer status and continue to send? How to deal with this situation?

  4. Is event loop thread responsible for delivering messages for event bus?

  5. Does event bus have a queue to buffer messages? If yes, by default how big for size?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Joe
  • 307
  • 1
  • 11

1 Answers1

0

By default the event-bus buffer holds 1000 events per consumer and the limit can be changed.

Which means, the "slow" consumer can wait another 1000 messages before the new incoming messages would be dropped. I think this is pretty good and thus the EB can be considered pretty safe and lossless.

When the messages are about to start getting dropped, you should scale your slow consumer verticle up.

Usually the probability of message drop outside of vert.x event-bus is way bigger than that between the nodes of cluster. Any external internet connection is not that stable compared to local ones of your "private" network.

If the consumer is not accessible for whatever reason, the vert.x can notify about message delivery:

vertx.eventBus().request( 'some.addr', 'some payload' ){ AsyncResult ar ->
  if( ar.succeded() )
    println 'ok'
  else 
    println "Error : ${ar.cause()}"
} 

In case of failed delivery because of not-present consumer, you would get appropriate exception

injecteer
  • 20,038
  • 4
  • 45
  • 89
  • Thank your prompt reply. It helps. Have to clarify more. which component is responsible for message forwarding in the event bus? Is it event loop thread? – Joe Mar 20 '20 at 13:58
  • Not sure what you mean, but for message sending is clustering technology is responsible, like hazelcast – injecteer Mar 20 '20 at 14:57
  • Thanks. One more question, how to change event buffer size (you mentioned by default 1000)? I would like to make it larger. – Joe Mar 20 '20 at 16:00
  • @Joe get some enlightenment from https://stackoverflow.com/questions/59266097/behaviour-of-vert-x-event-bus-when-reaching-the-limit :) – injecteer Mar 20 '20 at 16:07
  • Thanks a lot, very helpful. – Joe Mar 20 '20 at 17:01