vert-x3 / vertx-eventbus-bridge-clients

Home for various EventBus Bridge clients
Other
65 stars 32 forks source link

Java client only handles JSON (Map) messages #79

Open jt70 opened 8 months ago

jt70 commented 8 months ago

The EventBusClient.java appears to only handle Map data due to this line.

https://github.com/vert-x3/vertx-eventbus-bridge-clients/blob/d43e37bee66a0a1e403d32ef01bf439f01e002d1/java/src/main/java/io/vertx/eventbusclient/EventBusClient.java#L315

Here is a failing example that I added to TcpBusTest.java:

https://gist.github.com/jt70/d19debaa081d93db8a1aa9792fc17a7f#file-tcpbustest-java

The examples in the documentation have String messages, so I'm thinking this is a bug rather than a feature (unless I'm doing something wrong)?

If this is a bug, would you accept a pull-request to change this behavior? I'd like to be able to receive Base64 encoded byte array messages, but that may be beyond the scope this project?

tsegismont commented 8 months ago

Thanks for the report! Can you paste a link to the problematic example?

jt70 commented 8 months ago

I was talking about the examples in the Java documentation - https://github.com/vert-x3/vertx-eventbus-bridge-clients/blob/master/java/docs/index.adoc

For example:

busClient.consumer("newsfeed", new Handler<Message<String>>() {
  @Override
  public void handle(Message<String> message) {
    System.out.println("Received a news " + message.body());
  }
});

I believe this can never work because if the message body is a String then EventBusClient will throw an exception.

As a work around for now, I'm just going to use other ways to get messages into Vert.x so I can use protobuf as well.

tsegismont commented 6 months ago

Thanks for the details. I believe you are right, this is a bug. The client should support any valid JSON payload (string, number, boolean, null, json object and json array).