RabbitMQ JMS producer and receiving message with RabbitMQ consumer

143 views
Skip to first unread message

Karsten B

unread,
Feb 7, 2024, 9:21:36 AM2/7/24
to rabbitmq-users
Hi everybody,
i have a question regarding the mix of a producer using the Rabbit MQ JMS client library and consumer receiving those messages directly with the RabbitMQ amqp protocol.

Is this at all possible or
demands the usage of the RMQ JMS lib also a receiver using the RMQ JMS lib?
There seems to be an issue, because one gets a kind of serialized Java Objects (or amqp serialized data stream), which are not unserialized properly.

producer: spring-boot, rmq jms lib
consumer: spring-boot, camel, rmq component

the rmq jms connection factory is configured with:
    TLS_TYPE: "TLSv1.2"
    host: "rmq.server.com"
    port: 5671
    user: "rmquser"
    password: "rmqpwd"
    vhost: "rmqvhost"
    timeout: 3000
    channel: "aqueue" #using queueSession.createQueue(channel)

the rmq configuration:
spring:
   rabbitmq:
    host: " rmq.server.com "
    virtualhost: " rmqvhost "
    port: 5671
    username: " rmquser"
    password: " rmqpwd"
    ssl:
      enabled: true
      verifyhostname: false
      algorithm: "TLSv1.2"
 
queue defined on camel endpoint: rabbitmq:queue

Any hint would be appreciated.
Bye,
Karsten

Arnaud Cogoluègnes

unread,
Feb 8, 2024, 2:49:41 AM2/8/24
to rabbitmq-users
Yes, it's possible to publish with the RabbitMQ JMS client and consume with an AMQP client.

See the documentation for details [1] and the testSendToAmqp* methods in this test class [2] for examples.

Karsten B

unread,
Feb 8, 2024, 9:39:32 AM2/8/24
to rabbitmq-users
Hi,
i am receiving messages, but they look like this. 
Is the conversion for the content type wrong? I expect a TextMessage, if i use the RMQ JMS lib then i am able to cast to jms.TextMessage and retrieve a String.

��\u0000\u0005wx\u0000.com.rabbitmq.jms.client.message.RMQTextMessage\u0000$034cf7ba-0e2e-4160-8072-41525c1aee08\u0000\u0000\u0000\u0006\u0000\u001brmq.jms.message.destination sr\u0000%com.rabbitmq.jms.admin.RMQDestination\bHٍ��&)\u0002\u0000\bZ\u0000\u0004amqpZ\u0000\u0007isQueueZ\u0000\u000bisTemporaryL\u0000\u0010amqpExchangeNamet\u0000\u0012Ljava\/lang\/String;L\u0000\ramqpQueueNameq\u0000~\u0000\u0001L\u0000\u000eamqpRoutingKeyq\u0000~\u0000\u0001L\u0000\u000fdestinationNameq\u0000~\u0000\u0001L\u0000\u0015queueDeclareArgumentst\u0000\u000fLjava\/util\/Map;xp\u0000\u0001\u0000t\u0000\u0012jms.durable.queuest\u0000\u0010the queue nameq\u0000~\u0000\u0005q\u0000~\u0000\u0005pz\u0000\u0000\u0001�\u0000\u001drmq.jms.message.delivery.mode\u0004\u0000\u0000\u0000\u0002\u0000\u0019rmq.jms.message.timestamp\u0005\u0000\u0000\u0001����\u0000\u0018rmq.jms.message.priority\u0004\u0000\u0000\u0000\u0004\u0000\u001armq.jms.message.expiration\u0005\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0012rmq.jms.message.id\b\u0000'ID:034cf7ba-0e2e-4160-8072-41525c1aee08\u0000\u0000\u0000\t\u0000\u0005refNo\b\u0000\u000eQCR2402-000011\u0000\tdocStatus\b\u0000\u0006active\u0000\u0005vpoNo\b\u0000\u000eproperty\u0000\reditingStatus\b\u0000\tconfirmed\u0000\nupdateUser\b\u0000\u0019Karsten.b\u0000\tupdatedOn\b\u0000\u00172024-02-08 13:30:30.761\u0000\u0007version\b\u0000\u00012\u0000\tModule\b\u0000\rireport\u0000\u0006status\b\u0000\bofficialz\u0000\u0000\u0004\u0000\u0000\u0000\u0000�={\"id\":\"402890958d88d5c5018d88e96eec0025" - further json body escaped but also with special characters".....

the received headers are:
{"timestamp":"2024-02-08T14:22:37.299Z","level":"DEBUG","logger":"staging","thread":"pool-4-thread-4","message":"Received message headers {CamelSpringRabbitmqContentType=application\/octet-stream, CamelSpringRabbitmqDeliveryMode=PERSISTENT, CamelSpringRabbitmqDeliveryTag=2, CamelSpringRabbitmqExchangeName=jms.durable.queues, CamelSpringRabbitmqPriority=4, CamelSpringRabbitmqRedelivered=false, CamelSpringRabbitmqRoutingKey=queue name, Module=report, docStatus=active, editingStatus=confirmed, JMSDeliveryMode=PERSISTENT, JMSMessageID=ID:034cf7ba-0e2e-4160-8072-41525c1aee08, JMSPriority=4, JMSTimestamp=1707399034079, status=official, updatedOn=2024-02-08 13:30:30.761, updateUser=Karsten.b version=2"}

Arnaud Cogoluègnes

unread,
Feb 9, 2024, 3:22:33 AM2/9/24
to rabbitmq-users
Have you looked at the links I mentioned above? You need to use a specific "AMQP destination".

Please provide a standalone project that reproduces the issue, we need to see the whole thing to understand what's going on.

Karsten B

unread,
Feb 9, 2024, 2:10:43 PM2/9/24
to rabbitm...@googlegroups.com
Hello Arnaud,
well, yes i have read the links, but perhaps not understood.

for understanding:
" AMQP destination" = "a queue where one expects AMQP encoded messages / an exchange where one is writing AMQP encoded messages to"?

When i am using the RMQ JMS lib and configure a jms connection factory as in my first post and create from this a jms queue with "a specific name". Then I receive a "RMQTextMessage extends RMQMessage implements TextMessage" and get the JSON String body with msg.getText().
If i create a RMQ connection factory with spring-rabbitmq and use the default RMQ exchange with key and queue having the same "a specific name" as above, I am receiving what I believe (now) is the raw AMQP message (see previous post). The com.rabbitmq.jms.client.RMQMessage#fromMessage and implementation of com.rabbitmq.jms.client.RMQMessage#readAmqpBody seem to decode and deserialize this octet-stream.

But according to your links i should receive the real payload from this AMQP destination, see test com.rabbitmq.integration.tests.SimpleAmqpQueueMessageIT#testSendToAmqpAndReceiveTextMessage
the Spring-Boot RabbitTemplate is doing exactly this: org.springframework.amqp.rabbit.core.RabbitTemplate#doReceiveNoWait

Is there on the server side some configuration to consider? (The server side is not under my control)
Is there a header to be considered?

Bye
Karsten
Sample project is a bit hard, regarding the server side.


--
You received this message because you are subscribed to a topic in the Google Groups "rabbitmq-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rabbitmq-users/dAPwNFoCmms/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/a368d05d-7e69-4486-9e32-1f34b283dc49n%40googlegroups.com.


--

Arnaud Cogoluègnes

unread,
Feb 12, 2024, 2:57:04 AM2/12/24
to rabbitmq-users
The JMS Destination you publish to must be an "AMQP destination", see [1] for an example. The JMS client library will publish the JMS message so that a regular AMQP client library can read it. Note destinations can be configured in the application, but also on the server side, then looked up using JNDI.

Karsten B

unread,
Feb 27, 2024, 7:21:17 AM2/27/24
to rabbitm...@googlegroups.com
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
Hello,

differences are:
my endpoint is using the default exchange (denoted with "default" in Camel instead of "" in RMQ client configuration) and the proper queue and key declaration:
"spring-rabbitmq:default?routingKey=OutBound&queues=OutBound&acknowledgeMode=AUTO"

I have added a Spring Message converter to control the conversion of the message more directly on the Spring layer, declaring a subclass
of org.springframework.amqp.support.converter.SimpleMessageConverter in the application context. So I am able to see the headers like below.
Instead of using the contentType to derive the proper message conversion, i know the payload should be a JSON String so, directly creating a new String, but with the result shown below. So no difference to the previous version.

message properties:
MessageProperties [headers={refNo=XXX, JMSMessageID=ID:5c04208d-9a9b-4ee4-94ae-70413c869b27, vpoNo=XXXX, JMSTimestamp=1709033485921, updateUser=Karste...@XXX.com, updatedOn=2024-02-27 11:31:23.903, JMSDeliveryMode=PERSISTENT, version=3, JMSPriority=4, docStatus=active, status=scheduled}, contentType=application/octet-stream, contentLength=0, receivedDeliveryMode=PERSISTENT, priority=4, redelivered=false, receivedExchange=jms.durable.queues, receivedRoutingKey=OutBound, deliveryTag=1, consumerTag=amq.ctag-c-XM6pWAHKM-l3puikO79g, consumerQueue=OutBound]

String conversion result:
\u0000\u0005wx\u0000.com.rabbitmq.jms.client.message.RMQTextMessage\u0000$5c04208d-9a9b-4ee4-94ae-70413c869b27\u0000\u0000\u0000\u0006\u0000\u001brmq.jms.message.destination sr\u0000%com.rabbitmq.jms.admin.RMQDestination\bHٍ��&)\u0002\u0000\bZ\u0000\u0004amqpZ\u0000\u0007isQueueZ\u0000\u000bisTemporaryL\u0000\u0010amqpExchangeNamet\u0000\u0012Ljava\/lang\/String;L\u0000\ramqpQueueNameq\u0000~\u0000\u0001L\u0000\u000eamqpRoutingKeyq\u0000~\u0000\u0001L\u0000\u000fdestinationNameq\u0000~\u0000\u0001L\u0000\u0015queueDeclareArgumentst\u0000\u000fLjava\/util\/Map;xp\u0000\u0001\u0000t\u0000\u0012jms.durable.queuest\u0000\u0010OI_SB.OIOutBoundq\u0000~\u0000\u0005q\u0000~\u0000\u0005pz\u0000\u0000\u0001�\u0000\u001drmq.jms.message.delivery.mode\u0004\u0000\u0000\u0000\u0002\u0000\u0019rmq.jms.message.timestamp\u0005\u0000\u0000\u0001
.... all the headers encoded ....
... afterwards the real JSON payload

So looks like a printout of a com.rabbitmq.jms.client.message.RMQTextMessage if I am using the RMQ client (via Spring, Camel), but
using the RMQ JMS i am getting the proper JSON payload.

I cannot deserialize the incoming byte array, because RMQTextMessage is not implementing java.lang.Serializable.
Does contentType=application/octet-stream has strange effects on RMQ client but not on RMQ JMS client?

Any thoughts?

without thoughts
Karsten





Arnaud Cogoluègnes

unread,
Feb 27, 2024, 8:14:26 AM2/27/24
to rabbitmq-users
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
You expect me to set up a project from the sample you mention and some explanations of your use case, reproduce the issue, and debug it? I don't have time for this, it's not part of my job. This is the third and last time I ask you to provide a sample project that I can run in one command to reproduce and investigate the issue. I can't spend hours guessing what you are doing with RabbitMQ libraries and several frameworks on top of them and trying to reproduce the issues you're mentioning.
Reply all
Reply to author
Forward
0 new messages