yogananth Mahalingam [http://community.jboss.org/people/yogamaha] modified the 
document:

"How to configure EJB3 MDBs for IBM Websphere MQ"

To view the document, visit: http://community.jboss.org/docs/DOC-12944

--------------------------------------------------------------
You do not need deployment descriptors for ejb3.  The perferred method for 
configuring EJB3s would be with the annotations.

This is how you would define your ejb3 bean with all of the properties.

@MessageDriven( name="MyMDBName",
        activationConfig = 
        { 
            
@ActivationConfigProperty(propertyName="messagingType",propertyValue="javax.jms.MessageListener"),
            @ActivationConfigProperty(propertyName = 
"destinationType",propertyValue = "javax.jms.Queue"),
            @ActivationConfigProperty(propertyName = "destination", 
propertyValue = "queueA"),
            @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = 
"true"),
            @ActivationConfigProperty(propertyName = "channel", propertyValue = 
"SYSTEM.DEF.SVRCONN"),
            @ActivationConfigProperty(propertyName = "hostName", propertyValue 
= "devmq1sun"),
            @ActivationConfigProperty(propertyName = "queueManager", 
propertyValue = "DEVMQ1SUN"),
            @ActivationConfigProperty(propertyName = "port", propertyValue = 
"1416"),
            @ActivationConfigProperty(propertyName = "transportType", 
propertyValue = "CLIENT")
            @ActivationConfigProperty(propertyName = "username", propertyValue 
= "foo")
            @ActivationConfigProperty(propertyName = "password", propertyValue 
= "bar")
        }) 
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@ResourceAdapter(value = "wmq.jmsra2.rar")
 



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.

*Equivalent XML settings*

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

<?xml version="1.0" encoding="UTF-8"?>
<jboss
        xmlns="http://java.sun.com/xml/ns/javaee";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                            http://www.jboss.org/j2ee/schema/jboss_5_0.xsd";
        version="3.0">
   <enterprise-beans>
      <message-driven>
         <ejb-name>MyMDBName</ejb-name>
         <resource-adapter-name>wmq.jmsra2.rar</resource-adapter-name>
      </message-driven>
   </enterprise-beans>
</jboss>


and your ejb-jar.xml file will look similar to this..

<?xml version="1.0"?>
<ejb-jar
        xmlns="http://java.sun.com/xml/ns/javaee";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                            http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"; 
version="3.0">
    <enterprise-beans>
      <message-driven>
        <ejb-name>MyMDBName</ejb-name>
        <ejb-class>test.mdb.TestMDBBean</ejb-class>
        <messaging-type>javax.jms.MessageListener</messaging-type>
        <transaction-type>NotSupported</transaction-type>
        <activation-config>
          <activation-config-property>
          
<activation-config-property-name>messagingType</activation-config-property-name>
          
<activation-config-property-value>javax.jms.MessageListener</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          
<activation-config-property-name>destinationType</activation-config-property-name>
             
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          
<activation-config-property-name>destination</activation-config-property-name>
             
<activation-config-property-value>queueA</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          
<activation-config-property-name>useJNDI</activation-config-property-name>
          
<activation-config-property-value>true</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          
<activation-config-property-name>channel</activation-config-property-name>
             
<activation-config-property-value>SYSTEM.DEF.SVRCONN</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          
<activation-config-property-name>hostName</activation-config-property-name>
          
<activation-config-property-value>devmq1sun</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          
<activation-config-property-name>queueManager</activation-config-property-name>
             
<activation-config-property-value>DEVMQ1SUN</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          
<activation-config-property-name>port</activation-config-property-name>
             
<activation-config-property-value>1416</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          
<activation-config-property-name>transportType</activation-config-property-name>
             
<activation-config-property-value>CLIENT</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
             
<activation-config-property-name>username</activation-config-property-name>
          
<activation-config-property-value>foo</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          
<activation-config-property-name>password</activation-config-property-name>
          
<activation-config-property-value>bar</activation-config-property-value>
          </activation-config-property>
        </activation-config>
      </message-driven>



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.

The next logical question would be how do I take the Activation Configuration 
Properties out of the mdb and

How do I take those settings and move them out to a global place where I can 
define them for all MDBs?
-------------------------------------------------------------------------------------------------------

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">".

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")

Defining Properties in the domain.  Here is the domain we were talking about.

<domain name="Message Driven Bean">
      <bind pointcut="execution(public * 
@javax.annotation.security.RunAs->*(..))">
         <interceptor-ref 
name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
      </bind>
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref 
name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
         <interceptor-ref 
name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
         <interceptor-ref 
name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
      </bind>
      <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
         @org.jboss.annotation.ejb.PoolClass 
(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
      </annotation>
   </domain>



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.

This would be the completed IBMMQ Message Driven Bean domain configuration.

<domain name="IBMMQ Message Driven Bean" extends="Message Driven Bean" 
inheritBindings="true">
      <annotation 
expr="!class(@org.jboss.ejb3.annotation.DefaultActivationSpecs)">
         @org.jboss.ejb3.annotation.DefaultActivationSpecs 
({@javax.ejb.ActivationConfigProperty(propertyName = "channel", propertyValue = 
"SYSTEM.DEF.SVRCONN"),
             @javax.ejb.ActivationConfigProperty(propertyName = "hostName", 
propertyValue = "devmq1sun"),
             @javax.ejb.ActivationConfigProperty(propertyName = "queueManager", 
propertyValue = "DEVMQ1SUN"),
             @javax.ejb.ActivationConfigProperty(propertyName = "port", 
propertyValue = "1416"),
             @javax.ejb.ActivationConfigProperty(propertyName = 
"transportType", propertyValue = "CLIENT")})
      </annotation>
   </domain>

+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.+ 

and your completed mdb annotations would look something like this using the new 
domain configuration..

@MessageDriven( name="MyMDBName",
        activationConfig = 
        { 
            
@ActivationConfigProperty(propertyName="messagingType",propertyValue="javax.jms.MessageListener"),
            @ActivationConfigProperty(propertyName = 
"destinationType",propertyValue = "javax.jms.Queue"),
            @ActivationConfigProperty(propertyName = "destination", 
propertyValue = "queueA"),
            @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = 
"true"),
        }) 
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@ResourceAdapter(value = "wmq.jmsra2.rar")
@AspectDomain("IBMMQ Message Driven Bean")


References
[1] 
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/uj40080_.htm
  IBM outbound adapter properties
[2]  
http://www.ibm.com/developerworks/websphere/library/techarticles/0710_ritchie/0710_ritchie.html?ca=drs
 IBM EJB 2.x instructions
--------------------------------------------------------------

Comment by going to Community
[http://community.jboss.org/docs/DOC-12944]

Create a new document in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2029]
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to