2011-03-30 134 views
0

當服務器啓動時,我可以看到它檢查消息,但有時它不會再嘗試抓取消息。我不知道它的確切時間,但我知道它甚至沒有試圖檢查,因爲我在調試模式下,並沒有看到消息命令被執行;排隊的消息也不會被消息驅動抓取。爲什麼我的消息驅動Bean停止處理消息?

這裏是我的ejb-jar.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<ejb-jar id="ejb-jar_ID" 
     version="3.0" 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"> 
<display-name>MessageEJB</display-name> 
<enterprise-beans> 
    <message-driven> 
    <display-name>MessageBean</display-name> 
    <ejb-name>MessageBean</ejb-name> 
    <ejb-class>com.ecomm.ejb.mdb.MessageBean</ejb-class> 
    <messaging-type>javax.jms.MessageListener</messaging-type> 
    <transaction-type>Container</transaction-type> 
    <message-destination-type>javax.jms.Queue</message-destination-type> 
    <activation-config> 
    <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>/queue/ExpiryQueue</activation-config-property-value> 
    </activation-config-property> 
    </activation-config> 
    </message-driven> 
</enterprise-beans> 

而且jboss.xml中:

<?xml version="1.0"?> 
<jboss> 
<enterprise-beans> 
    <message-driven> 
    <ejb-name>MessageBean</ejb-name> 
    <destination-jndi-name>/queue/ExpiryQueue</destination-jndi-name> 
    <resource-ref> 
    <res-ref-name>MessageBean</res-ref-name> 
    <jndi-name>/queue/ExpiryQueue</jndi-name> 
    </resource-ref> 
    </message-driven> 
</enterprise-beans> 
</jboss> 

和EJB:

/** 
* Message-Driven Bean implementation class for: MeaageBean 
* 
*/ 
@MessageDriven(
    mappedName = "/queue/ExpiryQueue", 
    activationConfig = { 
     @ActivationConfigProperty(
      propertyName = "acknowledgeMode", 
      propertyValue = "Auto-acknowledge" 
     ), 
     @ActivationConfigProperty(
      propertyName = "destinationType", 
      propertyValue = "javax.jms.Queue" 
     ) 
    } 
) 
public class MessageBean implements MessageListener { 

回答

0

Haii,

我我是MessageListener的初學者,但我擁有自己完美的impl ementation ... 我使用JBoss 5.1 HornetQ的 我覺得你已經失蹤您的實現 也許這一個註解....:

@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/ExpiryQueue") 

但在這種情況下,我不知道爲什麼會被有時候會發送一條消息....

我希望這可以幫助U和