1

I have a HornetQ server which has topic and queue's. I am not aware of the config on the other side but the way I connect to the Queue is:

<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref ="jndiTemplate"/>
    <property name="jndiName" value="ConnectionFactory"/>
</bean>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="defaultDestination" ref="destination"/>
    <property name="pubSubDomain" value="false"/>
    <property name="deliveryPersistent" value="true"/>
    <property name="deliveryMode" value="2"/>
</bean>

<bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="jndiTemplate"/>
    <property name="jndiName" value="QUEUE_NAME"/>
</bean>

<!-- Listener Asynchronous -->
<bean id="queueListener" class="com.my.queueListener"/>

<jms:listener-container concurrency="5-10">
             <jms:listener destination="QUEUE_NAME" ref="queueListener"/>
</jms:listener-container>

I had set the pubSubDomain to true and it worked (strange but true). Anyhow now I want to connect to a topic. I set the pubSubDomain as true and still it gives me an error saying

WARNING: Setup of JMS message listener invoker failed for destination 'Activate_NTD' - trying to recover. Cause: There is no queue with name TOPIC_NAME

I know HornetQ behaves a bit differently as specified here:

exact example for JMS Topic in HornetQ

but I am unable to figure out what to do and how to get this working.

Community
  • 1
  • 1
Anuja Khemka
  • 265
  • 1
  • 6
  • 17
  • 1
    The error message indicates that the message listener has its `pubSubDomain` flag set to `false`. The `DestinationResolver` is trying to resolve a **queue** and not a **topic**. Note that setting the flag on the `JmsTemplate` is useless for receiving messages, you need to set that on the `jms:listener-container` element. – Stephane Nicoll Jul 24 '14 at 07:57
  • 1
    Yes as Stephane pointed out you need to set destination-type="topic" in jms-listner-container – Karthik Prasad Jul 24 '14 at 17:18
  • ok. let me try that out. i thought i was missing something. hopefully this resolves it. – Anuja Khemka Jul 24 '14 at 17:36
  • @StéphaneNicoll and karthik thanks for the help.. set the destination-type="topic" in the jms-listener. thanks a tonn! – Anuja Khemka Jul 24 '14 at 22:08

1 Answers1

1

Set the destination-type on the container that defaults to queue, something like

<jms:listener-container destination-type="topic" concurrency="5-10">
         <jms:listener destination="TOPIC_NAME" ref="topicListener"/>
</jms:listener-container>
Stephane Nicoll
  • 31,977
  • 9
  • 97
  • 89
  • Finally, I am clear that I want to use **destination-type="topic"**, for my listener to work but here comes a major issue, Can we do this with JAVA DSL? – HVT7 May 04 '16 at 07:33
  • Sure thing. there is a setter for that as well. – Stephane Nicoll May 04 '16 at 15:31
  • I am using **DefaultMessageListenerContainer** and I can not see any setter for that property. After digging a bit found a way to solve it. Please see to my comment in the link over SO: http://stackoverflow.com/questions/25212488/what-is-the-equivalent-of-destination-type-from-jmslistener-container-in-javaco/37027806#37027806 – HVT7 May 04 '16 at 16:04
  • Reading the doc might help `setPubSub(true)` creates a listener for a topic. Actually the answer in the link you provide tells you exactly that. – Stephane Nicoll May 05 '16 at 13:26