2
votes

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?

1

1 Answers

0
votes

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