JMS client (spring-beans) cannot publish well to rabbitmq Q

700 views
Skip to first unread message

Gregory Orciuch

unread,
Feb 15, 2017, 9:40:21 AM2/15/17
to rabbitmq-users
Hi,

Hi,

I'm trying to run jms-client from spring environment towards RabbitMQ server;

I do have it configured like that (just follwing example from here https://www.rabbitmq.com/jms-client.html )

  <bean id="jmsConnectionFactory" class="com.rabbitmq.jms.admin.RMQConnectionFactory">
    <property name="username" value="user" />
    <property name="password" value="test" />
    <property name="virtualHost" value="lbb" />
    <property name="host" value="localhost" />
    <property name="port" value="45671" />
    <property name="ssl" value="true" />
  </bean>

  <bean id="jmsDestination" class="com.rabbitmq.jms.admin.RMQDestination" >
    <property name="destinationName" value="site666" />
    <property name="amqp"            value="true" />
    <property name="amqpQueueName"   value="siteId-8" />
  </bean>
thing is that it dont wont to push the message throwing

3:30:01,054 DEBUG RMQConnectionFactory| Connection RMQConnection{rabbitConnection=amqp://us...@127.0.0.1:45671/lbb, stopped=true, queueBrowserReadMax=0} created.
13:30:01,070 ERROR t.RMQMessageProducer| Cannot write to AMQP destination RMQDestination{destinationName='site666', queue(permanent, amqp)', amqpExchangeName='null', amqpRoutingKey='null', amqpQueueName='siteId-8'}
13:30:01,080 INFO         citrus.Citrus| 
13:30:01,080 ERROR        citrus.Citrus| TEST FAILED RabbitMQ.jmsTry <com.bbb.lbb.tests.impl.behavioral> Nested exception is: 
org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is com.rabbitmq.jms.util.RMQJMSException: Cannot write to AMQP destination
at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487)
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:559)
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:550)

I did tried setting exchange name to amq.default (but logs says it cannot find that in that vhost, also I put exchange as amq.direct, didnt help) Also supplying the routing key does not help much.

Used queues siteId-8 and site666 are previosly declared and durable and visible from vhost user.
(to pre precise they are normally used via amqp)

Looking for suggestions. I just want to push simple message towards named queue.

If anybody wants to replicate the problem here is a PoC project to do that: https://github.com/GregoryOrciuch/jmsRmqCitrus

BR,
Gregory

Arnaud Cogoluègnes

unread,
Feb 16, 2017, 3:55:54 AM2/16/17
to rabbitm...@googlegroups.com
As stated in [1], you need to define both the amqpExchangeName and amqpRoutingKey properties to be able to send messages to a RMQDestination (the amqpQueueName doesn't matter for sending).

Something like this does the trick (at least makes your test pass and send a message to the siteId-8 AMQP queue):

  <bean id="jmsDestination" class="com.rabbitmq.jms.admin.RMQDestination" >
    <property name="destinationName" value="site666" />
    <property name="amqp"            value="true" />
    <property name="amqpExchangeName" value="" />
    <property name="amqpRoutingKey" value="siteId-8" />
  </bean>

It uses the default exchange (name is empty string) and the name of queue as the routing key. You may prefer to use your own exchange and binding, it's more flexible than simply relying on the default exchange, especially for large applications.


On Wed, Feb 15, 2017 at 3:40 PM, Gregory Orciuch <g.or...@gmail.com> wrote:
Hi,

Hi,

I'm trying to run jms-client from spring environment towards RabbitMQ server;

I do have it configured like that (just follwing example from here https://www.rabbitmq.com/jms-client.html )

  <bean id="jmsConnectionFactory" class="com.rabbitmq.jms.admin.RMQConnectionFactory">
    <property name="username" value="user" />
    <property name="password" value="test" />
    <property name="virtualHost" value="lbb" />
    <property name="host" value="localhost" />
    <property name="port" value="45671" />
    <property name="ssl" value="true" />
  </bean>

  <bean id="jmsDestination" class="com.rabbitmq.jms.admin.RMQDestination" >
    <property name="destinationName" value="site666" />
    <property name="amqp"            value="true" />
    <property name="amqpQueueName"   value="siteId-8" />
  </bean>
thing is that it dont wont to push the message throwing

3:30:01,054 DEBUG RMQConnectionFactory| Connection RMQConnection{rabbitConnection=amqp://user@127.0.0.1:45671/lbb, stopped=true, queueBrowserReadMax=0} created.
13:30:01,070 ERROR t.RMQMessageProducer| Cannot write to AMQP destination RMQDestination{destinationName='site666', queue(permanent, amqp)', amqpExchangeName='null', amqpRoutingKey='null', amqpQueueName='siteId-8'}
13:30:01,080 INFO         citrus.Citrus| 
13:30:01,080 ERROR        citrus.Citrus| TEST FAILED RabbitMQ.jmsTry <com.bbb.lbb.tests.impl.behavioral> Nested exception is: 
org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is com.rabbitmq.jms.util.RMQJMSException: Cannot write to AMQP destination
at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487)
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:559)
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:550)

I did tried setting exchange name to amq.default (but logs says it cannot find that in that vhost, also I put exchange as amq.direct, didnt help) Also supplying the routing key does not help much.

Used queues siteId-8 and site666 are previosly declared and durable and visible from vhost user.
(to pre precise they are normally used via amqp)

Looking for suggestions. I just want to push simple message towards named queue.

If anybody wants to replicate the problem here is a PoC project to do that: https://github.com/GregoryOrciuch/jmsRmqCitrus

BR,
Gregory

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages