amqp / rhea

A reactive messaging library based on the AMQP protocol
Apache License 2.0
280 stars 79 forks source link

Sending message to JMS consumer #331

Closed tobias-zeptio closed 3 years ago

tobias-zeptio commented 3 years ago

I'm having an issue where a message sent using rhea is not decoded by a JMS based consumer, even though another rhea instance receives the message fine. Is there something that needs to be done the message when sending it to ensure a JMS consumer can read it?

grs commented 3 years ago

I don't believe so.

What JMS client are you using and what broker? Do you get a decoding error on the JMS client? Or the message received is just not as expected in some way?

tobias-zeptio commented 3 years ago

I'm using ActiveMQ Artemis as broker, and the consumer is eclipse/ditto. I don't see and errors, just that the headers and payload are null. I send this:

send({
    ttl: 10000,
    body
});

And receive this:

Received JmsMessage from AMQP 1.0: JmsObjectMessageFacade { org.apache.qpid.jms.provider.amqp.message.AmqpJmsObjectMessageFacade@e00d9d45 } with Properties: java.util.Collections$3@c79393a3 and AckType 1
Received message at 'iot.hdt.in' of unsupported type (org.apache.qpid.jms.message.JmsObjectMessage) with headers: {to=iot.hdt.in, absolute-expiry-time=1610104746153}
Received message from AMQP 1.0 with externalMessageHeaders: {absolute-expiry-time=1610104746153, to=iot.hdt.in}
Received message from AMQP 1.0 with payload: binary

Don't understand why payload is binary, should be text or json.

grs commented 3 years ago

The body should be a named attribute on the message object, e.g.:

send({body:'hello'});

Otherwise I would expect the body to be null when sent (which still doesn't explain why it would be detected as binary).

Can you run the client with env var PN_TRACE_FRM=1 set? That will give more detail of the message it gets at the protocol level.

grs commented 3 years ago

Also, I don't know ditto so this may not be relevant, but https://www.eclipse.org/ditto/connectivity-protocol-bindings-amqp10.html#content-type suggests that a special format and content-type may be required for the body to be recognised?

tobias-zeptio commented 3 years ago

Thanks for the help, now I found the issue. I had to send to body as a string, while send to another rhea client an object works.

send({
    ttl: 10000,
    body: JSON.stringify(jsonBody)
});

Still think an object should work if I set content-type "application/json", but it doesn't. This is fine for now.