I beleive my problem is something related to the Spring support. When I used
the JMSTestClient provided by the Panacya which uses jmsTemplate.receive()
to retreive one message back from the queue, the message was successfully
dequed. I could run that multiple times over to keep dequeing messages.
However, when I use the SpringConsumer onMessage() example, I do not
retrieve a message. On looking at the JMX view, I noticed that the consumer
does appear as a client to the Queue so I eliminated the fact that the test
might be pointing to the wrong queue.
The following is my applicationContext definition, I am using JNDI
connection factory for sending but using the jmsfactory for receiving. I
tried to use the JNDI for both to no success as well.
Any assistance would be greately appreciated. Thanks in advance.
<bean id="jndiTemplate"
class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop
key="brokerURL">tcp://localhost:61616</prop>
<prop key="java.naming.factory.initial">
org.apache.activemq.jndi.ActiveMQInitialContextFactory
</prop>
<prop key="queue.requestQueue">
org.apache.activemq.requestQueue
</prop>
</props>
</property>
</bean>
<!-- JNDI Object factory bean for request queue -->
<bean id="requestQueue"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName">
<value>requestQueue</value>
</property>
</bean>
<bean id="connectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="jndiName">
<value>ConnectionFactory</value>
</property>
</bean>
<bean id="jmsTemplate"
class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="connectionFactory" />
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
</bean>
<!-- a sample POJO which uses a Spring JmsTemplate -->
<bean id="producer" class="com.activemq.test.SpringProducer">
<property name="template">
<ref bean="jmsTemplate"></ref>
</property>
<property name="messageCount">
<value>10</value>
</property>
<property name="destination">
<ref bean="echoRequestQueue" />
</property>
</bean>
<bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
<property name="connectionFactory">
<bean
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>tcp://localhost:61616</value>
</property>
<property name="userName">
<value>user</value>
</property>
<property name="password">
<value>password</value>
</property>
</bean>
</property>
</bean>
<!-- Spring JMS Template -->
<bean id="consumerJmsTemplate"
class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref local="jmsFactory" />
</property>
</bean>
<!-- a sample POJO consumer -->
<bean id="consumer" class="com.activemq.test.SpringConsumer">
<property name="template">
<ref bean="consumerJmsTemplate"></ref>
</property>
<property name="destination">
<ref bean="consumerDestination" />
</property>
</bean>
<bean id="consumerDestination"
class="org.apache.activemq.command.ActiveMQQueue"
autowire="constructor" lazy-init="default"
dependency-check="default">
<constructor-arg value="org.apache.activemq.replyQueue" />
</bean>
CobraTheSleek wrote:
>
> Hi,
>
> ENV:
> ActiveMQ-Snapshot-5.0
> JBoss AS 4.2.1
>
> I have the following queues defined:
>
> <mbean code="org.jboss.resource.deployment.AdminObject"
> name="activemq.queue:name=org.apache.activemq.requestQueue">
> <attribute name="JNDIName">activemq/requestQueue</attribute>
> <depends
> optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends>
> <attribute name="Type">javax.jms.Queue</attribute>
> <attribute
> name="Properties">PhysicalName=org.apache.activemq.requestQueue</attribute>
> </mbean>
>
> <mbean code="org.jboss.resource.deployment.AdminObject"
> name="activemq.queue:name=org.apache.activemq.replyQueue">
> <attribute name="JNDIName">activemq/replyQueue</attribute>
> <depends
> optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends>
> <attribute name="Type">javax.jms.Queue</attribute>
> <attribute
> name="Properties">PhysicalName=org.apache.activemq.replyQueue</attribute>
> </mbean>
>
> I have an MDB defined that listens for messages from the requestQueue and
> posts a response on the replyQueue.
>
> I am using the Spring unit tests provided (Producer and Consumer) and my
> Producer sends messages to the requestQueue, the MDB receives the request
> and posts a message back on to the replyQueue.
>
> I can see that there are messages in the replyQueue via JMX. However, my
> Consumer never receives messages from the replyQueue.
>
> If I run the test without the MDB, by placing messages in the replyQueue
> via the PRODUCER, my Consumer receives the messages successfully. In other
> words messages posted by the MDB are never received by the consumer.
>
> The following is what my MDB does to place messages back on the reply
> queue:
>
> InitialContext initCtx = new InitialContext();
>
> QueueConnectionFactory qcf = (QueueConnectionFactory) initCtx
> .lookup("java:comp/env/jms/MyQueueConnectionFactory");
>
> QueueConnection qcon = qcf.createQueueConnection();
> QueueSession qsession = qcon.createQueueSession(true, 0);
> Queue q = (Queue) initCtx.lookup("activemq/replyQueue");
> QueueSender qsender = qsession.createSender(q);
>
> TextMessage message = qsession.createTextMessage();
>
> message.setText(response);
> qsender.setTimeToLive(100000000);
> qsender.send(message);
>
> qsender.close();
> qsession.close();
> qcon.close();
>
>
> I am quite confused as to why this is happening as I see messages as being
> available in the replyQueue.
> Any tips would be appreciated.
>
--
View this message in context:
http://www.nabble.com/Messages-not-being-received-by-consumer-tf4779201s2354.html#a13691974
Sent from the ActiveMQ - User mailing list archive at Nabble.com.