On 20 Jan, Michel de Groot wrote: > Hi peter, > > are you still working on MessageDrivenBeans for JBoss? It's been a couple of weeks since I commited any code, but thats mostly because it works for me, and nobody else seems to be using MDB (at least there has been no problems reported hierto, plus that I have a pile of other work to do). >I've tried to use > them, but without success so far. In the source, I noticed that some > fields in the deployment descriptor are named differently in the EJB 2.0 > spec. Hm, which fields? I thought I verrifyed the stuff agains the ejb2.0 DTD. > I changed this, but still no luck. There is something wrong with > the standardjboss.xml I think, because some required configuration > fields are not filled, which throws NullPointer in line 406 of > org.jboss.ejb.ContainterFactory. standardjboss.xml have no MDB support, see further down. > > Also, could you explain to me how the MDB gets mapped to a Topic or > Queue? Where is it defined what the name is of the Topic/Queue? In jboss.xml, see further down >Where do > I need to find which Topics/Queues exist? That is a question of wich JMS provider you use. Currently MDB works with spyderMQ and OpenEJB (the default on jboss.jcml is SpyderMQ). > > Sincerely, > Michel de Groot > Here is *verry* terse howto: Six steps to MDB nirvana in Jboss. ================================== Peter Antman The easies way to get up and working with Message Driven Beans in jboss is the check out the jbosstest from cvs and look into the mdb test. But here are also the steps you need to go through to get it working. 1. Check out the latest jboss from cvs and compile. 2. Write the sourcecode for a Message Driven Bean. 3. Write the ejb-jar.xml descriptor. Here is an example for a bean listening on a queue with bean managed transactions : <?xml version="1.0"?> <!DOCTYPE ejb-jar> <!-- PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd" --> <ejb-jar> <enterprise-beans> <message-driven> <ejb-name>QueueBean</ejb-name> <ejb-class>org.jboss.test.mdb.bean.QueueBean</ejb-class> <jms-message-selector></jms-message-selector> <transaction-type>Bean</transaction-type> <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode> <message-driven-destination> <jms-destination-type>javax.jms.Queue</jms-destination-type> <subscription-durability>NonDurable</subscription-durability> </message-driven-destination> </message-driven> </enterprise-beans> </ejb-jar> And here are one for a durable topic with containermanaged transactions: <?xml version="1.0"?> <!DOCTYPE ejb-jar> <message-driven> <ejb-name>DurableTopicBean</ejb-name> <ejb-class>org.jboss.test.mdb.bean.TopicBean</ejb-class> <jms-message-selector></jms-message-selector> <transaction-type>Container</transaction-type> <message-driven-destination> <jms-destination-type>javax.jms.Topic</jms-destination-type> <subscription-durability>Durable</subscription-durability> </message-driven-destination> </message-driven> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>DurableTopicBean</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar> 4. Write the jboss.xml deployment descriptor (this MUST allways be done with MDB in jboss) The destination-jndi-name element points to the queue Here are the one for the queue bean: <?xml version="1.0" encoding="Cp1252"?> <jboss> <enterprise-beans> <message-driven> <ejb-name>QueueBean</ejb-name> <configuration-name>Default MesageDriven Bean</configuration-name> <destination-jndi-name>queue/testQueue</destination-jndi-name> </message-driven> </enterprise-beans> <resource-managers /> <container-configurations> <container-configuration configuration-class="org.jboss.ejb.deployment.StatelessSessionContainerConfiguration"> <container-name>Default MesageDriven Bean</container-name> <container-invoker>org.jboss.ejb.plugins.jms.JMSContainerInvoker</container-invoker> <instance-pool>org.jboss.ejb.plugins.MessageDrivenInstancePool</instance-pool> <instance-cache></instance-cache> <persistence-manager></persistence-manager> <transaction-manager>org.jboss.tm.TxManager</transaction-manager> <container-invoker-conf> <Optimized>False</Optimized> <JMSProviderAdapterJNDI>DefaultJMSProvider</JMSProviderAdapterJNDI> <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI> <MaximumSize>15</MaximumSize> <MaxMessages>1</MaxMessages> </container-invoker-conf> <container-pool-conf> <MaximumSize>100</MaximumSize> <MinimumSize>10</MinimumSize> </container-pool-conf> </container-configuration> </container-configurations> </jboss> And here for the durable topic: <?xml version="1.0" encoding="Cp1252"?> <jboss> <enterprise-beans> <message-driven> <ejb-name>DurableTopicBean</ejb-name> <configuration-name>Default MesageDriven Bean</configuration-name> <destination-jndi-name>topic/testDurableTopic</destination-jndi-name> <mdb-user>john</mdb-user> <mdb-passwd>needle</mdb-passwd> <mdb-client-id>DurableSubscriberExample</mdb-client-id> </message-driven> <secure>false</secure> </enterprise-beans> <resource-managers /> <container-configurations> <container-configuration configuration-class="org.jboss.ejb.deployment.StatelessSessionContainerConfiguration"> <container-name>Default MesageDriven Bean</container-name> <container-invoker>org.jboss.ejb.plugins.jms.JMSContainerInvoker</container-invoker> <instance-pool>org.jboss.ejb.plugins.MessageDrivenInstancePool</instance-pool> <instance-cache></instance-cache> <persistence-manager></persistence-manager> <transaction-manager>org.jboss.tm.TxManager</transaction-manager> <container-invoker-conf> <Optimized>False</Optimized> <JMSProviderAdapterJNDI>DefaultJMSProvider</JMSProviderAdapterJNDI> <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI> <MaximumSize>15</MaximumSize> <MaxMessages>1</MaxMessages> </container-invoker-conf> <container-pool-conf> <MaximumSize>100</MaximumSize> <MinimumSize>10</MinimumSize> </container-pool-conf> </container-configuration> </container-configurations> </jboss> 5. Edit spyderMQ.xml in conf/default and ad the queue or topic Eg: <Queue> <Name>testQueue</Name> </Queue> For the queue, and <Topic> <Name>testDurableTopic</Name> </Topic> plus <User> <Name>john</Name> <Password>needle</Password> <Id>DurableSubscriberExample</Id> <DurableSubscription> <Name>DurableSubscriberExample</Name> <TopicName>testDurableTopic</TopicName> </DurableSubscription> </User> for the durable topic. 6.Deploy the bean, for example by packing it in a jar and copy it into the jboss deploy directory. This works for me at least. //Peter -- ------------------------------------------------------------ Peter Antman Technology in Media, Box 34105 100 26 Stockholm Systems Architect WWW: http://www.tim.se Email: [EMAIL PROTECTED] WWW: http://www.backsource.org Phone: +46-(0)8-506 381 11 Mobile: 070-675 3942 ------------------------------------------------------------ -- -------------------------------------------------------------- To subscribe: [EMAIL PROTECTED] To unsubscribe: [EMAIL PROTECTED] List Help?: [EMAIL PROTECTED]
