-
15. Re: connectionFactoryJndiName config property
tobinibot Nov 29, 2006 9:10 PM (in response to tobinibot)Got it.
<connection-factories> <tx-connection-factory> <jndi-name>activemq/QueueConnectionFactory</jndi-name> <xa-transaction/> <track-connection-by-tx/> <!-- Thanks to Adrian Brock for pointing this one out! --> <rar-name>activemq-ra-4.0.2.rar</rar-name> <connection-definition>javax.jms.QueueConnectionFactory</connection-definition> <security-domain-and-application>JmsXARealm</security-domain-and-application> </tx-connection-factory> <tx-connection-factory> <jndi-name>activemq/TopicConnectionFactory</jndi-name> <xa-transaction/> <track-connection-by-tx/> <!-- Thanks to Adrian Brock for pointing this one out too! --> <rar-name>activemq-ra-4.0.2.rar</rar-name> <connection-definition>javax.jms.TopicConnectionFactory</connection-definition> <security-domain-and-application>JmsXARealm</security-domain-and-application> </tx-connection-factory> <mbean code="org.jboss.resource.deployment.AdminObject" name="activemq.queue:name=outboundQueue"> <attribute name="JNDIName">activemq/queue/outbound</attribute> <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra-4.0.2.rar'</depends> <attribute name="Type">javax.jms.Queue</attribute> <attribute name="Properties"> PhysicalName=queue.outbound </attribute> </mbean> </connection-factories>
-
16. Re: connectionFactoryJndiName config property
weston.price Nov 29, 2006 9:33 PM (in response to tobinibot)Ok, assuming that guy deployed ok, the infrastructure is set up to do what you want. Now it's time to develop/deploy your MDB. Take a look at:
http://www.activemq.org/site/inbound-communication.html
This gives the basics on how to hook things up. There is also a sample project attached that's pretty good. Also this link:
http://www.activemq.org/site/jndi-support.html
shows the basics on how to use JNDI to talk to ActiveMQ if you want to run a thin client.
The *-ds.xml file did deploy right? :-) -
17. Re: connectionFactoryJndiName config property
tobinibot Nov 29, 2006 9:46 PM (in response to tobinibot)Yes, it deployed.
21:38:11,781 INFO [testQueue] Bound to JNDI name: queue/testQueue
21:38:11,968 INFO [UILServerILService] JBossMQ UIL service available at : /0.0.0.0:8093
21:38:12,015 INFO [DLQ] Bound to JNDI name: queue/DLQ
21:38:12,359 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
21:38:12,671 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=activemq/QueueConnectionFactory' to JNDI name 'java:activemq/QueueConnectionFactory'
21:38:12,687 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=activemq/TopicConnectionFactory' to JNDI name 'java:activemq/TopicConnectionFactory'
21:38:12,750 INFO [AdminObject] Bound admin object 'org.apache.activemq.command.ActiveMQQueue' at 'activemq/queue/outbound'
21:38:12,937 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
21:38:13,546 INFO [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080
21:38:13,734 INFO [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
I'll start going through those other 2 pages. I appreciate your help very, very much. If I have questions (probably tomorrow), do you mind if I just tack the question on to this thread?
Thanks again. -
18. Re: connectionFactoryJndiName config property
weston.price Nov 29, 2006 9:52 PM (in response to tobinibot)Not a problem. A word of advice on this, keep it simple to start. I was able to get a simple MDB up and running so if you need it I can send it as a fallback.
Working through those examples is a good thing. What I woud do is a SLSB that just posts a message to ActiveMQ Queue. This way you can get a feel for how all the parts interact. -
19. Re: connectionFactoryJndiName config property
tobinibot Nov 29, 2006 9:56 PM (in response to tobinibot)One thing I noticed was that the examples all seem to be using EJB2. We're using EJB3, so I'll have to convert the examples, but I'm hoping that's a fairly trivial process.
-
20. Re: connectionFactoryJndiName config property
weston.price Nov 29, 2006 9:58 PM (in response to tobinibot)Shouldn't be an issue. You just need to set the appropriate annotations. The EJB3 MDB container will just pass them along to the ActiveMQ Activation spec.
-
21. Re: connectionFactoryJndiName config property
weston.price Nov 29, 2006 10:02 PM (in response to tobinibot)The most important configuration piece in the puzzle is the destination name in your activation config. This *has* to point to the physical queue name on ActiveMQ, not the JNDI name. This has been known to trip people up. Also, while ActiveMQ does support dynamic Queue/Topic creation via JNDI, this probably won't work in this scnenario being that the MDB is bound to a particular destination at deployment time.
I could be wrong on this one, ActiveMQ very well may create a destination when one is unknown (like JBossMQ), but I would have to verify this. -
22. Re: connectionFactoryJndiName config property
tobinibot Nov 30, 2006 1:09 PM (in response to tobinibot)Ok, well I was able to get the sample project (EJB2) up and running successfully. Now to try and get it running with EJB3.
Using the same JBoss setup, I created a new EJB3 project and one MDB:package ejb; import javax.ejb.ActivationConfigProperty; import javax.ejb.MessageDriven; import javax.jms.Message; import javax.jms.MessageListener; import org.jboss.logging.Logger; /** * @author tjuday */ @MessageDriven(mappedName = "jms/SimpleMessageReceiverBean", activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue.outbound") }) public class SimpleMessageReceiverBean implements MessageListener { private Logger logger = Logger.getLogger(SimpleMessageReceiverBean.class); public void onMessage(Message message) { logger.info("received message"); } }
And this is with the panacya-ds.xml, here:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE connection-factories PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN" "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd"> <connection-factories> <tx-connection-factory> <jndi-name>activemq/QueueConnectionFactory</jndi-name> <xa-transaction/> <track-connection-by-tx/> <!-- Thanks to Adrian Brock for pointing this one out! --> <rar-name>activemq-ra-4.0.2.rar</rar-name> <connection-definition>javax.jms.QueueConnectionFactory</connection-definition> <security-domain-and-application>JmsXARealm</security-domain-and-application> </tx-connection-factory> <tx-connection-factory> <jndi-name>activemq/TopicConnectionFactory</jndi-name> <xa-transaction/> <track-connection-by-tx/> <!-- Thanks to Adrian Brock for pointing this one out too! --> <rar-name>activemq-ra-4.0.2.rar</rar-name> <connection-definition>javax.jms.TopicConnectionFactory</connection-definition> <security-domain-and-application>JmsXARealm</security-domain-and-application> </tx-connection-factory> <mbean code="org.jboss.resource.deployment.AdminObject" name="activemq.queue:name=outboundQueue"> <attribute name="JNDIName">activemq/queue/outbound</attribute> <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra-4.0.2.rar'</depends> <attribute name="Type">javax.jms.Queue</attribute> <attribute name="Properties"> PhysicalName=queue.outbound </attribute> </mbean> </connection-factories>
When I run that, I get this in the log file:11:33:31,562 INFO [EJBContainer] STARTED EJB: ejb.SimpleMessageReceiverBean ejbName: SimpleMessageReceiverBean
11:33:31,578 WARN [MessagingContainer] Could not find the queue destination-jndi-name=queue.outbound
11:33:31,578 WARN [MessagingContainer] destination not found: queue/queue.outbound reason: javax.naming.NameNotFoundException: queue.outbound not bound
11:33:31,765 WARN [MessagingContainer] creating a new temporary destination: queue/queue.outbound
11:33:31,765 INFO [outbound] Bound to JNDI name: queue/queue.outbound
11:33:31,812 INFO [EJB3Deployer] Deployed: file:/C:/Program Files/Fresh_JBoss/server/default/deploy/Panacya_EJB3.jar
11:33:31,921 WARN [JmsActivation] Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@1b57890(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@6972f1 destination=queue.outbound isTopic=false tx=true durable=false reconnect=10 provider=java:/DefaultJMSProvider user=null maxMessages=1 minSession=1 maxSession=15 keepAlive=60000 useDLQ=true DLQHandler=org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler DLQJndiName=queue/DLQ DLQUser=null DLQMaxResent=0)
javax.naming.NameNotFoundException: queue.outbound 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:296)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.jboss.util.naming.Util.lookup(Util.java:215)
at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupDestination(JmsActivation.java:399)
at org.jboss.resource.adapter.jms.inflow.JmsActivation.setup(JmsActivation.java:306)
at org.jboss.resource.adapter.jms.inflow.JmsActivation$SetupActivation.run(JmsActivation.java:589)
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:743)
at java.lang.Thread.run(Thread.java:595)
You can see that I'm using the physical name of the queue for my destination, but it's not working. I've tried all sorts of things in that destination field, and I can't get anything to work. -
23. Re: connectionFactoryJndiName config property
weston.price Nov 30, 2006 1:42 PM (in response to tobinibot)The problem is you are missing the @ResourceAdapter annotation. By default, if the EJB3 messaging layer does not see this, it attempts to deploy your code with the JBoss JMS/JCA adapter. The annotation would look something like
@ResourceAdapter("adapter-name") -
24. Re: connectionFactoryJndiName config property
tobinibot Nov 30, 2006 1:58 PM (in response to tobinibot)THAT WORKED!!!
Thank you so much for your help, you have no idea how desperate we were getting.
If anyone else is still reading along, here is what my final MDB looks like:package ejb; import javax.ejb.ActivationConfigProperty; import javax.ejb.MessageDriven; import javax.jms.Message; import javax.jms.MessageListener; import org.jboss.annotation.ejb.ResourceAdapter; import org.jboss.logging.Logger; /** * @author tjuday */ @MessageDriven(mappedName = "jms/SimpleMessageReceiverBean", activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue.outbound") }) @ResourceAdapter("activemq-ra-4.0.2.rar") public class SimpleMessageReceiverBean implements MessageListener { private Logger logger = Logger.getLogger(SimpleMessageReceiverBean.class); public void onMessage(Message message) { logger.info("received message"); } }
I've got a little more playing around to do, I would like to see if ActiveMQ will create a non-existent destination, or if it has to be bound. I'll report back my findings here.
Weston, again, thanks for your all you work. You've been a great help. -
25. Re: connectionFactoryJndiName config property
weston.price Nov 30, 2006 2:00 PM (in response to tobinibot)No problem. I am glad you got it up and running!
-
26. Re: connectionFactoryJndiName config property
tobinibot Nov 30, 2006 2:10 PM (in response to tobinibot)It looks like ActiveMQ is able to construct destinations on the fly through the resource adapter.
I changed my destination to "queue/randomQueue" (which does not exists anywhere in any system). My bean deployed successfully, and when I sent a message to that queue (using a small JMS client outside JBoss), my MDB was executed. Very nice indeed. -
27. Re: connectionFactoryJndiName config property
weston.price Nov 30, 2006 2:12 PM (in response to tobinibot)Hmmm...excellent. I know that you can do it via use of their JNDI stuff. I wasn't sure it would get bound to the adapter.
-
28. Re: connectionFactoryJndiName config property
dan.lee Jan 7, 2007 10:03 PM (in response to tobinibot)But I want to ask whether @ResourceAdapter is under JavaEE 5 spec ?
-
29. Re: connectionFactoryJndiName config property
adamhmitchell Aug 13, 2007 1:02 PM (in response to tobinibot)When you add the "@ResourceAdapter("foo.rar")" annotation to the MDB, are the JNDI bindings you created in the *-ds.xml file being used?
I'm trying to use Sun's MQ server (IMQ) in JBoss and I found that I could deploy the RAR from Sun IMQ and use the following annotations (without using a *-ds.xml datasource):@MessageDriven(mappedName = "jms/LoggingEventBean", activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"), @ActivationConfigProperty(propertyName = "clientId", propertyValue = "LoggingEventBean"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "elm_topics_LoggingEvent_default"), @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "LoggingEventBean") //@ActivationConfigProperty(propertyName = "UserName", propertyValue = "guest"), //@ActivationConfigProperty(propertyName = "Password", propertyValue = "guest") }) @ResourceAdapter("imqjmsra.rar") public class LoggingEventBean implements MessageListener { ...