MDB Queue Injection in Clustered Environment
red247.matt.parker.cox.net Nov 3, 2008 10:42 PMI have an application that runs fine using the non-clustered JBoss AS 4.2.3.GA.
When I try to move to the clustered setup, the MDBs attached to a queue will start consuming messages. In each MDB, another queue is injected to send messages back to a JMX service. The injected queue cannot be looked up. What I find odd is that the MDBs are retrieving messages from the queue, but the queue to pass the messages back cannot be found.
@Name("CorrConvMDB") @Depends("jboss.j2ee:service=EARDeployment,url='bap.ear'") @MessageDriven(name = "CorrConvMDB", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/corrConvQueue"), //Set to 1 for clustered environment. One per node. Otherwise, increase as necessary. @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1") }) public class CorrConvMDB implements MessageListener { @PersistenceContext EntityManager manager; @In QueueSender corrConvProcessedQueue; . . . }
Here is the queue configuration from jbossmq-destinations-service.xml on the master node in the deploy-hasingleton jms directory.
<mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:name=corrConvQueue,service=Queue"> <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends> <attribute name="MaxDepth">10000</attribute> <!-- Used to load balance the CorrConvMDBs in a clustered setup. --> <attribute name="ReceiversImpl">org.jboss.mq.server.ReceiversImplArrayList</attribute> </mbean> <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:name=corrConvProcessedQueue,service=Queue"> <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends> <attribute name="MaxDepth">10000</attribute> <attribute name="ReceiversImpl">org.jboss.mq.server.ReceiversImplArrayList</attribute> </mbean>
Here is the stack trace for the error:
16:00:15,311 ERROR [JmsServerSession] Unexpected error delivering message org.jboss.mq.SpyObjectMessage { Header { jmsDestination : QUEUE.corrConvQueue jmsDeliveryMode : 2 jmsExpiration : 0 jmsPriority : 4 jmsMessageID : ID:1-1225746015564118 jmsTimeStamp : 1225746015564 jmsCorrelationID: null jmsReplyTo : null jmsType : null jmsRedelivered : true jmsProperties : {JMSXDeliveryCount=4, JMS_JBOSS_REDELIVERY_COUNT=3} jmsPropReadWrite: false msgReadOnly : true producerClientId: ID:1 } } javax.ejb.EJBTransactionRolledbackException: Could not instantiate Seam component: corrConvProcessedQueue at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87) at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:249) at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268) at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138) at $Proxy192.onMessage(Unknown Source) at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178) at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:906) at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170) at org.jboss.mq.SpySession.run(SpySession.java:323) at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237) at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204) at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756) at java.lang.Thread.run(Thread.java:619) Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: corrConvProcessedQueue at org.jboss.seam.Component.newInstance(Component.java:1986) at org.jboss.seam.Component.getInstance(Component.java:1876) at org.jboss.seam.Component.getInstance(Component.java:1843) at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2192) at org.jboss.seam.Component.getValueToInject(Component.java:2144) at org.jboss.seam.Component.injectAttributes(Component.java:1601) at org.jboss.seam.Component.inject(Component.java:1419) at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:118) at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50) at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118) at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126) ... 17 more Caused by: java.lang.RuntimeException: exception invoking: create at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:135) at org.jboss.seam.Component.callComponentMethod(Component.java:2092) at org.jboss.seam.Component.callCreateMethod(Component.java:2015) at org.jboss.seam.Component.newInstance(Component.java:1976) ... 40 more Caused by: javax.naming.NameNotFoundException: queue not bound at org.jnp.server.NamingServer.getBinding(NamingServer.java:529) at org.jnp.server.NamingServer.getBinding(NamingServer.java:537) at org.jnp.server.NamingServer.getObject(NamingServer.java:543) at org.jnp.server.NamingServer.lookup(NamingServer.java:267) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.jboss.seam.jms.ManagedQueueSender.getQueue(ManagedQueueSender.java:45) at org.jboss.seam.jms.ManagedQueueSender.create(ManagedQueueSender.java:51) at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.seam.util.Reflections.invoke(Reflections.java:21) at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125) ... 43 more
Here is the relevant section of the components.xml file:
<components> : : : <jms:queue-connection queue-connection-factory-jndi-name="java:/JmsXA" /> <jms:managed-queue-sender name="corrConvQueue" auto-create="true" queue-jndi-name="queue/corrConvQueue"/> <jms:managed-queue-sender name="corrConvProcessedQueue" auto-create="true" queue-jndi-name="queue/corrConvProcessedQueue"/> </components>
TIA.