我试图了解在 JBoss 4.3 中运行的一些 EJB 3 代码。
我们已经在 JBoss 中配置了一个带有一些 MDB 配置的 ejb3-interceptors-aop.xml 文件,然后我们有了 MDB Java 类。
我想了解的是 MDB 何时以及如何“绑定”到 MQ?也就是说,MDB 何时/如何开始监听 MQ 队列?
JBoss 是否在启动时读取 ejb3-interceptors-aop.xml 文件,然后在启动时找到 AspectDomain 注释等于“GatewayMDB”并“绑定”到 MQ 队列的类?
ejb3-interceptors-aop.xml 中的 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 类:
@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) {
...
}
}