catch event bus exceptions

52 views
Skip to first unread message

Gadi Eichhorn

unread,
Jul 20, 2017, 8:17:57 AM7/20/17
to vert.x
Hi all!

How do I catch event bus exceptions?
for example when I send a message and there is no subscriber/listener?

Thanks,
G.

Gadi Eichhorn

unread,
Jul 20, 2017, 9:02:14 AM7/20/17
to vert.x
I mean, is there a generic way to handle exceptions on the event bus or do I need to handle it per message?

Julien Viet

unread,
Jul 20, 2017, 9:04:34 AM7/20/17
to ve...@googlegroups.com
Hi,

you need to have the message consumer to perform an explicit reply to acknowledge the reception of the message. If there is no subscriber you will get an error reply instead.

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/7dca6ca4-79e1-4fb5-8328-81f6018dc8cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gadi Eichhorn

unread,
Jul 21, 2017, 3:41:56 AM7/21/17
to vert.x
my use case is sending a message to one subscriber with no reply message.
if there is no subscriber I get an error message.
is there a way to catch these errors?


io.vertx.core.eventbus.ReplyException: Timed out after waiting 2000(ms) for a reply. address: 10
        at io.vertx.core.eventbus.impl.HandlerRegistration.sendAsyncResultFailure(HandlerRegistration.java:118) ~[42:io.vertx.core:3.4.1]
        at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$new$0(HandlerRegistration.java:65) ~[42:io.vertx.core:3.4.1]
        at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:803) ~[42:io.vertx.core:3.4.1]
        at io.vertx.core.impl.VertxImpl$InternalTimerHandler.handle(VertxImpl.java:774) ~[42:io.vertx.core:3.4.1]
        at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:337) ~[42:io.vertx.core:3.4.1]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [15:io.netty.common:4.1.8.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403) [15:io.netty.common:4.1.8.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:445) [20:io.netty.transport:4.1.8.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [15:io.netty.common:4.1.8.Final]
        at java.lang.Thread.run(Thread.java:748) [?:?]

Tim Fox

unread,
Jul 21, 2017, 4:20:59 AM7/21/17
to vert.x
You will have got the below exception by calling send with a reply handler, and no reply was received within the timeout.

That exception will have been passed to that reply handler.

This is explained in the docs: See http://vertx.io/docs/vertx-core/java/#event_bus "sending with timeouts"

hth
Reply all
Reply to author
Forward
0 new messages