Can a EJB3 listen and consume messages from a remote queue (JB 6.1) ?
philcero Feb 8, 2012 10:00 AMHi all,
I hae searched all the WEB (This site too) to soluce that question.
I have found examples for Topics but they "seems" not to work with standard Queues.
I have two JBoss 6.1 servers (dev00 [1099] and dev01 [1199]) and I try to have a EJB3 in DEV01 which "listen" to messages on a DEV00 queue [/queue/TESTSOUT].
My elements on DEV00 :
server/dev00/deploy/hornetq/hornetq-jms.xml :
...
<queue name="TESTSOUT">
<entry name="/queue/TESTSOUT"/>
</queue>
...
The queue is present in the admin console and I can publish simple string messages to it with a local EJB in DEV00 (The console report 7 messages in it today).
My elements on DEV01 :
server/dev01/deploy/hornetq/jms-ds.xml :
<connection-factories>
<mbean code="org.jboss.jms.jndi.JMSProviderLoader" name="jboss.mq:service=JMSProviderLoader,name=RemoteJMSProvider,server=rt-vm205.gfisoblagnac">
<attribute name="ProviderName">RemoteJMSProvider</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<attribute name="FactoryRef">java:/XAConnectionFactory</attribute>
<attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>
<attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>
<attribute name="Properties">
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jnp.interfaces
java.naming.provider.url=rt-vm205.gfisoblagnac:1099
</attribute>
</mbean>
...
My EJB (ToLower.java) :
package monpkg.tests;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
@MessageDriven(activationConfig =
{
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "/queue/TESTSOUT"),
@ActivationConfigProperty(propertyName = "providerAdapterJNDI", propertyValue = "java:/RemoteJMSProvider") })
public class ToLower implements MessageListener
{
public ToLower()
{
}
public void onMessage(Message message)
{
System.out.println("ToLower get message : " + message.toString());
}
}
We have no error in server/dev01/log/boot.log.
When I publish again my EJB I have this :
...
2012-02-08 15:41:36,926 INFO [org.jboss.ejb3.EJBContainer] (HDScanner) STOPPED EJB: monpkg.tests.ToLower ejbName: ToLower
2012-02-08 15:41:36,961 WARN [org.jboss.ejb3.interceptor.InterceptorInfoRepository] (HDScanner) EJBTHREE-1852: InterceptorInfoRepository is deprecated
2012-02-08 15:41:36,970 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) Created KernelDeployment for: EJBTestsToLower.jar
2012-02-08 15:41:36,970 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) installing bean: jboss.j2ee:jar=EJBTestsToLower.jar,name=ToLower,service=EJB3
2012-02-08 15:41:36,970 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) with dependencies:
2012-02-08 15:41:36,970 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) and demands:
2012-02-08 15:41:36,970 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) jboss.ejb:service=EJBTimerService; Required: Described
2012-02-08 15:41:36,970 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) jboss-switchboard:appName=EJBTestsToLower,module=EJBTestsToLower,name=ToLower; Required: Create
2012-02-08 15:41:36,971 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) and supplies:
2012-02-08 15:41:36,971 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) jndi:null
2012-02-08 15:41:36,971 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) Class:javax.jms.MessageListener
2012-02-08 15:41:36,971 INFO [org.jboss.ejb3.deployers.JBossASKernel] (HDScanner) Added bean(jboss.j2ee:jar=EJBTestsToLower.jar,name=ToLower,service=EJB3) to KernelDeployment of: EJBTestsToLower.jar
2012-02-08 15:41:36,985 INFO [org.jboss.ejb3.EJBContainer] (HDScanner) STARTED EJB: monpkg.tests.ToLower ejbName: ToLower
2012-02-08 15:41:36,988 WARN [org.jboss.ejb3.TimerServiceContainer] (HDScanner) EJBTHREE-2193: using deprecated TimerServiceFactory for restoring timers
2012-02-08 15:41:36,992 INFO [org.hornetq.ra.inflow.HornetQActivation] (pool-1-thread-2) awaiting topic/queue creation /queue/TESTSOUT
2012-02-08 15:41:38,994 INFO [org.hornetq.ra.inflow.HornetQActivation] (pool-1-thread-2) Attempting to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@2db118c5 destination=/queue/TESTSOUT destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15)
2012-02-08 15:41:39,000 INFO [org.hornetq.ra.inflow.HornetQActivation] (pool-1-thread-2) awaiting topic/queue creation /queue/TESTSOUT
2012-02-08 15:41:41,003 INFO [org.hornetq.ra.inflow.HornetQActivation] (pool-1-thread-2) Attempting to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@2db118c5 destination=/queue/TESTSOUT destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15)
...
No error but no message is consumed and the EJB seems to wait for the "creation" of the queue...
Anyone can help ?