The jms:listener element: hardcoded queue name
Posted by danielmeyer on July 18, 2008
I thought I’d try using Spring’s jms: namespace to define my DefaultMessageListener container. So I changed this:
<bean id=”jmsContainer” class=”org.springframework.jms.listener.DefaultMessageListenerContainer”>
<property name=”connectionFactory” ref=”queueConnectionFactory” />
<property name=”destination” ref=”queue” />
<property name=”messageListener” ref=”messageListener” />
<property name=”transactionManager” ref=”transactionManager” />
</bean>
to this:
<jms:listener-container connection-factory=”queueConnectionFactory” transaction-manager=”transactionManager”>
<jms:listener destination=”queue” ref=”messageListener” />
</jms:listener-container>
(the queue bean was defined this way:
<amq:queue id=”queue” physicalName=”gloriousTest.Queue” />
)
But now when I deployed my .war project, ActiveMQ had a queue named “queue”, and no consumers were listening to the gloriousTest.Queue queue.
As it turns out, the jms:listener element’s destination attribute refers to a physical queue name — it’s not a bean reference. So I guess if I were going to use the jms:listener element I would need to hardcode gloriousTest.Queue there. I’m not ready to do that at this point, so I think I’m going to revert back to the plain old <bean> element usage for my DefaultMessageListenerContainer.