[jboss-user] [JNDI and Naming] - Re: Using JNDI to connect to Websphere MQ, without hardcoded info

Stuart Clayton do-not-reply at jboss.com
Fri Aug 12 06:16:17 EDT 2011


Stuart Clayton [http://community.jboss.org/people/stuartclayton22] created the discussion

"Re: Using JNDI to connect to Websphere MQ, without hardcoded info"

To view the discussion, visit: http://community.jboss.org/message/620786#620786

--------------------------------------------------------------
[Let's see if this formatting works:]

I just had exactly the same problem with incoming MDBs (receive messages from MQ), with the same versions of JBoss and MQ. I solved it by following the  http://community.jboss.org/docs/DOC-12944 http://community.jboss.org/wiki/HowToConfigureEJB3MDBsForIBMWebsphereMQ hint for creating an "aop domain", with an important correction.

This "domain" contains all the context (host, port etc) that we currently have either in the annotations, the ejb-jar.xml or the jboss.xml (there seems to be no difference between the last two files, as far as where the activationSpecs are for queue MDBs). This "domain" arranges for yet another ( ! ) set of "activationSpec annotations" to be injected into the MDB class code, but indirectly instead of having to put annotations explicity in the class source.

Here is what the additional code in the JBoss deploy/ejb3-interceptors-aop.xml file looks like (note that the @org.jboss.annotation.ejb.DefaultActivationSpecs ({ ...  stuff has to be on one line, without CRLFs ):

{code}
   <domain name="IBMMQ Message Driven Bean" extends="Intercepted Bean" inheritBindings="true">
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
      </bind>
      <!-- TODO: Authorization? -->
      <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
         <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
         <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
         <!-- interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/ -->
         <stack-ref name="EJBInterceptors"/>
      </bind>

      <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Pool)">
         @org.jboss.ejb3.annotation.Pool (value="StrictMaxPool", maxSize=15, timeout=10000)
      </annotation>
      <annotation expr="!class(@org.jboss.annotation.ejb.DefaultActivationSpecs)">
         @org.jboss.annotation.ejb.DefaultActivationSpecs ({@javax.ejb.ActivationConfigProperty(propertyName = "channel", propertyValue = "SYSTEM.DEF.SVRCONN"), @javax.ejb.ActivationConfigProperty(propertyName = "hostName", propertyValue = "127.0.0.1"), @javax.ejb.ActivationConfigProperty(propertyName = "queueManager", propertyValue = "QM_APPLE"), @javax.ejb.ActivationConfigProperty(propertyName = "port", propertyValue = "1415"), @javax.ejb.ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT")})
      </annotation>  
{code}

The MDB declaration now looks like this:

{code}
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "messagingType", propertyValue = "javax.jms.MessageListener"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@ResourceAdapter(value = "wmq.jmsra.rar")
@AspectDomain("IBMMQ Message Driven Bean")
public class ReadMQAgent implements MessageListener {
{code}

The ejb-jar.xml now looks like this:

{code}
<ejb-jar xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance" xmlns=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee" xmlns:ejb=" http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
  <enterprise-beans>
    <message-driven>
      <ejb-name>ReadMQAgent</ejb-name>
      <ejb-class>com.fleetboard.agw.calculator.msgproc.impl.ReadMQAgent</ejb-class>        
      <activation-config>
        <activation-config-property>
          <activation-config-property-name>useJNDI</activation-config-property-name>
          <activation-config-property-value>false</activation-config-property-value>
        </activation-config-property>   
        <activation-config-property>
          <activation-config-property-name>destination</activation-config-property-name>
          <activation-config-property-value>Q1</activation-config-property-value>
        </activation-config-property>  
       </activation-config>
    </message-driven>
  </enterprise-beans>
</ejb-jar>
{code}

In the AOP "domain" declaration from the link given above, the annotation class is specified as @org.jboss.annotation.ejb.DefaultActivationSpecs. Somewhere (can't find it now) there was a user comment on this example, pointing out that the class should be @org.jboss.ejb3.annotation.DefaultActivationSpecs. After I changed this accordingly, the whole business finally worked. Before this last change, I was getting an MQ error about "Q1" not being defined.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/620786#620786]

Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110812/de91bc37/attachment-0001.html 


More information about the jboss-user mailing list