0

I am trying to understand some EJB 3 code running in JBoss 4.3.

We've got an ejb3-interceptors-aop.xml file configured in JBoss with some MDB configuration and then we've got the MDB Java class.

What I'd like to understand is when and how does the MDB get "bound" to the MQ? That is, when/how does the MDB start listening to the MQ queue?

Does JBoss at startup read the ejb3-interceptors-aop.xml file and then find the class with the AspectDomain annotation equal to "GatewayMDB" and "bind" to the MQ queue at startup?


XML in ejb3-interceptors-aop.xml:

   <domain name="GatewayMDB">
      <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>
      <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 = "10.10.10.10"), @javax.ejb.ActivationConfigProperty(propertyName = "queueManager", propertyValue = "QM"), @javax.ejb.ActivationConfigProperty(propertyName = "port", propertyValue = "1419"),@javax.ejb.ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT")})
      </annotation>
   </domain>

MDB class:

@MessageDriven(name = "BridgeMDB", activationConfig = {
        @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "true"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "TO.WLS.LQUEUE.BG"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "maxPoolDepth", propertyValue = "1") })
@ResourceAdapter("wmq.jmsra.rar")
@AspectDomain("GatewayMDB") 
@Interceptors(SpringBeanAutowiringInterceptor.class)
@TransactionManagement(TransactionManagementType.CONTAINER)
public class BridgeMDB implements MessageListener {
    private static Logger logger = Logger.getLogger(BridgeMDB.class);


    @Autowired
    private MessageProcessor messageProcessor;
    @Autowired
    private MessageTranslator messageTranslator;

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void onMessage(Message message) {
        ...
    }

}
Fionnuala
  • 90,370
  • 7
  • 114
  • 152
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429

2 Answers2

0

Disclaimer: this is a supposition, since I don't know the jboss code.


The common way of processing class files in java is to read them through the class path (in this case it would be at load-time) and construct some sort of metadata for each class.

Then, when the application bootstraps the container will read the class's metadatada to wire/inject/configure the appropriate attributes that were defined within the class.

As for the xml, most of the jboss configuration is static AFAIK, ie, you have to restart the app server in order for changes to take effect.

So all in all, I would say that your observation is correct.

Miguel Ping
  • 18,082
  • 23
  • 88
  • 136
0

For a clear understanding of this process, your best bet would be to read the JCA specification. It is a clearly and easily understandable spec.

IBM provides their JCA adapter which is deployed to JBoss. When JBoss deploys your MDB, an "activation specification" is passed to the IBM JCA. The IBM JCA then creates a managed connection factory for the MDB instances. Note that this is separate and distinct from any connection factories as configured in the JBoss server configuration.

Part of the activation spec is the number of JMS sessions. The IBM JCA creates and manages these sessions. The IBM JCA also create JMS message listeners on these sessions.

When a message is received, the IBM JCA creates a message driven context, requests an MDB instance from the JBoss managed instance pool, provides the message driven context to the MDB instance and calls the MDB onMessage() method.

Doug Grove
  • 962
  • 5
  • 5