我想了解一些在JBoss 4.3中運行的EJB 3代碼。JBoss EJB3 MDB配置
我們已經在JBoss中配置了ejb3-interceptors-aop.xml文件,並配置了一些MDB配置,然後我們獲得了MDB Java類。
我想了解的是MDB何時以及如何「綁定」MQ?也就是說,MDB何時/如何開始監聽MQ隊列?
JBoss在啓動時是否讀取ejb3-interceptors-aop.xml文件,然後在啓動時找到AspectDomain註釋等於「GatewayMDB」和「綁定」到MQ隊列的類?
XML在EJB3攔截器-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類:
@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) {
...
}
}