<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
How to configure EJB3 MDBs for IBM Websphere MQ
</h3>
<span style="margin-bottom: 10px;">
modified by <a href="http://community.jboss.org/people/yogamaha">yogananth Mahalingam</a> in <i>EJB3</i> - <a href="http://community.jboss.org/docs/DOC-12944">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>You do not need deployment descriptors for ejb3.  The perferred method for configuring EJB3s would be with the annotations.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This is how you would define your ejb3 bean with all of the properties.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-java">@MessageDriven( name=<font color="red">"MyMDBName"</font>,
        activationConfig =
        <font color="navy">{</font>
            @ActivationConfigProperty(propertyName=<font color="red">"messagingType"</font>,propertyValue=<font color="red">"javax.jms.MessageListener"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"destinationType"</font>,propertyValue = <font color="red">"javax.jms.Queue"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"destination"</font>, propertyValue = <font color="red">"queueA"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"useJNDI"</font>, propertyValue = <font color="red">"true"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"channel"</font>, propertyValue = <font color="red">"SYSTEM.DEF.SVRCONN"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"hostName"</font>, propertyValue = <font color="red">"devmq1sun"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"queueManager"</font>, propertyValue = <font color="red">"DEVMQ1SUN"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"port"</font>, propertyValue = <font color="red">"1416"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"transportType"</font>, propertyValue = <font color="red">"CLIENT"</font>)
            @ActivationConfigProperty(propertyName = <font color="red">"username"</font>, propertyValue = <font color="red">"foo"</font>)
            @ActivationConfigProperty(propertyName = <font color="red">"password"</font>, propertyValue = <font color="red">"bar"</font>)
        <font color="navy">}</font>)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@ResourceAdapter(value = <font color="red">"wmq.jmsra2.rar"</font>)
 
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>You can get rid of your desployment descriptors as the annotations take their place.(ejb-jar.xml, jboss.xml).  The above example uses your resource adapter and all of your activation configuration properties.  I think I got them all in there.  I did notice however that you are using the "wmq.jmsra2.rar" in your ejb descriptor, but your depends in the ds.xml file is using "wmq.jmsra.rar".  You may want to fix that to get the dependencies correct.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong>Equivalent XML settings</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>If you wanted to deploy the same thing using xml files instead of annotations, your IBM adapter will be added to your jboss.xml file</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><?xml version="1.0" encoding="UTF-8"?></span>
<span class="jive-xml-tag"><span><jboss
        xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>"
        xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"
        xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>
                            </span><a class="jive-link-external-small" href="http://www.jboss.org/j2ee/schema/jboss_5_0.xsd" target="_blank">http://www.jboss.org/j2ee/schema/jboss_5_0.xsd</a><span>"
        version="3.0"></span></span>
   <span class="jive-xml-tag"><enterprise-beans></span>
      <span class="jive-xml-tag"><message-driven></span>
         <span class="jive-xml-tag"><ejb-name></span>MyMDBName<span class="jive-xml-tag"></ejb-name></span>
         <span class="jive-xml-tag"><resource-adapter-name></span>wmq.jmsra2.rar<span class="jive-xml-tag"></resource-adapter-name></span>
      <span class="jive-xml-tag"></message-driven></span>
   <span class="jive-xml-tag"></enterprise-beans></span>
<span class="jive-xml-tag"></jboss></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>and your ejb-jar.xml file will look similar to this..</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><?xml version="1.0"?></span>
<span class="jive-xml-tag"><span><ejb-jar
        xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>"
        xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"
        xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>
                            </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" target="_blank">http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd</a><span>" version="3.0"></span></span>
    <span class="jive-xml-tag"><enterprise-beans></span>
      <span class="jive-xml-tag"><message-driven></span>
        <span class="jive-xml-tag"><ejb-name></span>MyMDBName<span class="jive-xml-tag"></ejb-name></span>
        <span class="jive-xml-tag"><ejb-class></span>test.mdb.TestMDBBean<span class="jive-xml-tag"></ejb-class></span>
        <span class="jive-xml-tag"><messaging-type></span>javax.jms.MessageListener<span class="jive-xml-tag"></messaging-type></span>
        <span class="jive-xml-tag"><transaction-type></span>NotSupported<span class="jive-xml-tag"></transaction-type></span>
        <span class="jive-xml-tag"><activation-config></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>messagingType<span class="jive-xml-tag"></activation-config-property-name></span>
          <span class="jive-xml-tag"><activation-config-property-value></span>javax.jms.MessageListener<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>destinationType<span class="jive-xml-tag"></activation-config-property-name></span>
             <span class="jive-xml-tag"><activation-config-property-value></span>javax.jms.Queue<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>destination<span class="jive-xml-tag"></activation-config-property-name></span>
             <span class="jive-xml-tag"><activation-config-property-value></span>queueA<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>useJNDI<span class="jive-xml-tag"></activation-config-property-name></span>
          <span class="jive-xml-tag"><activation-config-property-value></span>true<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>channel<span class="jive-xml-tag"></activation-config-property-name></span>
             <span class="jive-xml-tag"><activation-config-property-value></span>SYSTEM.DEF.SVRCONN<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>hostName<span class="jive-xml-tag"></activation-config-property-name></span>
          <span class="jive-xml-tag"><activation-config-property-value></span>devmq1sun<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>queueManager<span class="jive-xml-tag"></activation-config-property-name></span>
             <span class="jive-xml-tag"><activation-config-property-value></span>DEVMQ1SUN<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>port<span class="jive-xml-tag"></activation-config-property-name></span>
             <span class="jive-xml-tag"><activation-config-property-value></span>1416<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>transportType<span class="jive-xml-tag"></activation-config-property-name></span>
             <span class="jive-xml-tag"><activation-config-property-value></span>CLIENT<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
             <span class="jive-xml-tag"><activation-config-property-name></span>username<span class="jive-xml-tag"></activation-config-property-name></span>
          <span class="jive-xml-tag"><activation-config-property-value></span>foo<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property></span>
          <span class="jive-xml-tag"><activation-config-property-name></span>password<span class="jive-xml-tag"></activation-config-property-name></span>
          <span class="jive-xml-tag"><activation-config-property-value></span>bar<span class="jive-xml-tag"></activation-config-property-value></span>
          <span class="jive-xml-tag"></activation-config-property></span>
        <span class="jive-xml-tag"></activation-config></span>
      <span class="jive-xml-tag"></message-driven></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>So this is how you would deploy one mdb with the queued defined as an Admin object in your ds.xml file.  The useJNDI argument makes sure that the queue will be looked up in jndi.  The IBM adapter takes an Admin Object as a queue and will make the appropriate arrangements to connect to it.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The next logical question would be how do I take the Activation Configuration Properties out of the mdb and</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>How do I take those settings and move them out to a global place where I can define them for all MDBs?<br/>-------------------------------------------------------------------------------------------------------</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>JBoss EJB3's work similar to EJB2.x, but not quite.  In EJB3, the file that governs the interceptors and global settings is *NOT* the standard-jboss.xml file anymore.  EJB3 now uses the deploy/ejb3-interceptors-aop.xml file.  The default configuration(now it's called a domain) for all MDBs is "<domain name="Message Driven Bean">".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Defining your own domains.  You can define your own domains if you wish.  So if you wanted to you could copy the "Message Driven Bean" domain and rename it to something like "IBMMQ Message Driven Bean".  You could add a class annotation that looks like @AspectDomain("IBMMQ Message Driven Bean")</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Defining Properties in the domain.  Here is the domain we were talking about.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-java"><domain name=<font color="red">"Message Driven Bean"</font>>
      <bind pointcut=<font color="red">"execution(public * @javax.annotation.security.RunAs->*(..))"</font>>
         <interceptor-ref name=<font color="red">"org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"</font>/>
      </bind>
      <bind pointcut=<font color="red">"execution(public * *->*(..))"</font>>
         <interceptor-ref name=<font color="red">"org.jboss.ejb3.stateless.StatelessInstanceInterceptor"</font>/>
         <interceptor-ref name=<font color="red">"org.jboss.ejb3.tx.TxInterceptorFactory"</font>/>
         <interceptor-ref name=<font color="red">"org.jboss.ejb3.AllowedOperationsInterceptor"</font>/>
         <interceptor-ref name=<font color="red">"org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"</font>/>
         <interceptor-ref name=<font color="red">"org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"</font>/>
      </bind>
      <annotation expr=<font color="red">"!class(@org.jboss.annotation.ejb.PoolClass)"</font>>
         @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
      </annotation>
   </domain>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><br/>Please notice that the <annotation> tag actaully inserts a new PoolClass annotation into each MDB.  This is so that you don't have to define the pool for each mdb.  We are going to do the same with your other defaults.  One more thing to note, the annotation expression, "<annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">" will look to see if there is a class annotation called PoolClass.  If the expression is true, then the contained PoolClass annotation is inserted.  This is an important point, becuase when we put our defaults in, we can't use activationConfig, because it is already being used in the mdb.  If we insert it and we already have one we will have problems.  So we have to come up with another annoation to insert default activationconfig properties, called DefaultActivationSpecs.  This is so that we can have some defaults along with the original activation specs that are in the mdb itself.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This would be the completed IBMMQ Message Driven Bean domain configuration.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-java"><domain name=<font color="red">"IBMMQ Message Driven Bean"</font> extends=<font color="red">"Message Driven Bean"</font> inheritBindings=<font color="red">"true"</font>>
      <annotation expr=<font color="red">"!class(@org.jboss.ejb3.annotation.DefaultActivationSpecs)"</font>>
         @org.jboss.ejb3.annotation.DefaultActivationSpecs (<font color="navy">{</font>@javax.ejb.ActivationConfigProperty(propertyName = <font color="red">"channel"</font>, propertyValue = <font color="red">"SYSTEM.DEF.SVRCONN"</font>),
             @javax.ejb.ActivationConfigProperty(propertyName = <font color="red">"hostName"</font>, propertyValue = <font color="red">"devmq1sun"</font>),
             @javax.ejb.ActivationConfigProperty(propertyName = <font color="red">"queueManager"</font>, propertyValue = <font color="red">"DEVMQ1SUN"</font>),
             @javax.ejb.ActivationConfigProperty(propertyName = <font color="red">"port"</font>, propertyValue = <font color="red">"1416"</font>),
             @javax.ejb.ActivationConfigProperty(propertyName = <font color="red">"transportType"</font>, propertyValue = <font color="red">"CLIENT"</font>)<font color="navy">}</font>)
      </annotation>
   </domain>
</code></pre><p><em>Note:  All annotations must use the full class names.  If you look in the EJB itself, you don't need to put the full classname because of the import.  When you are injecting annotations into a class there is no import, so you must use the full classname in the ejb3-interceptors-aop.xml file. </em></p><p><br/>and your completed mdb annotations would look something like this using the new domain configuration..</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code jive-java">@MessageDriven( name=<font color="red">"MyMDBName"</font>,
        activationConfig =
        <font color="navy">{</font>
            @ActivationConfigProperty(propertyName=<font color="red">"messagingType"</font>,propertyValue=<font color="red">"javax.jms.MessageListener"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"destinationType"</font>,propertyValue = <font color="red">"javax.jms.Queue"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"destination"</font>, propertyValue = <font color="red">"queueA"</font>),
            @ActivationConfigProperty(propertyName = <font color="red">"useJNDI"</font>, propertyValue = <font color="red">"true"</font>),
        <font color="navy">}</font>)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@ResourceAdapter(value = <font color="red">"wmq.jmsra2.rar"</font>)
@AspectDomain(<font color="red">"IBMMQ Message Driven Bean"</font>)
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>References</p><p>[1]<a class="jive-link-external-small" href="http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/uj40080_.htm"> IBM outbound adapter properties</a></p><p>[2] <a class="jive-link-external-small" href="http://www.ibm.com/developerworks/websphere/library/techarticles/0710_ritchie/0710_ritchie.html?ca=drs">IBM EJB 2.x instructions</a></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-12944">going to Community</a></p>
        <p style="margin: 0;">Create a new document in EJB3 at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2029">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>