0
votes

I am using vertx-rx-java

I have two verticles which communicate which each other using EventBus, one of the verticles returns complex object as the result, to do so I created custom MessageCodec and wanted to register it in EventBus.

In standard io.vertx.core.eventbus.EventBus there is a method registerCodec which gives possibility to register custom codecs for this EventBus.

However since I am using io.vertx.rxjava.core.Vertx, by calling vertx.eventBus() I receive io.vertx.rxjava.core.eventbus.EventBus, which doesn't have such method. What is the purpose of removing this method from rxjava EventBus, is it considered bad practice to use custom codecs whens using rxjava? If so, what is the recommended approach?

The only way to add custom codec I found is to call eventBus.getDelegate():

EventBus eb = vertx.eventBus();

((io.vertx.core.eventbus.EventBus) eb.getDelegate()).registerCodec(new StringMessageCodec());
1
Caveat: I know next to nothing about Vertex/EventBus, but I can see that vertx.io/preview/docs/apidocs/io/vertx/core/… returns vertx.io/preview/docs/apidocs/io/vertx/core/eventbus/… which does have vertx.io/preview/docs/apidocs/io/vertx/core/eventbus/… . That contradicts your statements... Perhaps an upgrade would solve your problem? - Will Cain
@WillCain you are looking at the wrong class, this one is from vertx-core and I wrote that it works well, however I am using vertx-rxjava so if you take a look at io.vertx.rxjava.core.Vertx class it returns io.vertx.rxjava.core.eventbus.EventBus which doesn't have such method. - Ruslan Akhundov
Gotcha. Sorry, it looked like your question originally referenced io.vertx.core.eventbus.EventBus. - Will Cain
The good news is it looks like this has changed recently (August) on the master branch, see they removed @GenIgnore github.com/eclipse-vertx/vert.x/commit/… - Will Cain

1 Answers

2
votes

Short answer appears it has not been supported. Hoewever this has changed recently (August) on the unreleased master branch; see they removed @GenIgnore from EventBus here. However, that is not yet in the release 3.5.3. Presumably this change will go out in one of the next releases.