2011-05-09 111 views
1

這是How to stop message processing before undeploying?如何設置JMX通知監聽器?

我想配置取消部署事件JMX通知監聽器的後續,但我不知道如何正確設置的MBean名稱。我們目前正在使用JBoss 4.2.3。以下嘗試不會觸發任何通知。

<mbean code="jboss.example.NotificationListener" 
     name="jboss.example:name=NotificationListener"> 
    <attribute name="SubscriptionList"> 
     <subscription-list> 
      <mbean name="jboss.j2ee:service=EjbModule,type=jmx.attribute.change"> 
      </mbean> 
      <notification type="JBOSS_MONITOR_NOTIFICATION"></notification> 
     </subscription-list> 
    </attribute> 
</mbean> 

這裏是所有通知事件,其中上彈出取消部署的列表:

2011-05-05 09:06:09,020 INFO [org.jboss.ejb.EJBDeployer] Undeploying: file:/home/.../projects/jboss-server/local/server/dorun/tmp/deploy/tmp2721970726140354007mdb-simple.ear-contents/simple-mdb-ejb-1.0.0-SNAPSHOT.jar 
2011-05-05 09:06:09,022 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.j2ee:service=EjbModule,module=simple-mdb-ejb-1.0.0-SNAPSHOT.jar][type=jmx.attribute.change][message=EjbModule stopping], handback: null 
2011-05-05 09:06:10,032 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.j2ee:jndiName=local/[email protected],service=EJB][type=jmx.attribute.change][message=MessageDrivenContainer stopping], handback: null 
2011-05-05 09:06:11,050 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.j2ee:service=EJB,plugin=invoker,binding=message-driven-bean,jndiName=local/[email protected]][type=jmx.attribute.change][message=JMSContainerInvoker stopping], handback: null 
2011-05-05 09:06:12,061 INFO [STDOUT] Got notification: javax.management.Notification[source=jboss.j2ee:service=EJB,plugin=invoker,binding=message-driven-bean,jndiName=local/[email protected]][type=org.jboss.ejb.plugins.jms.DISCONNECTING][message=], handback: null 
2011-05-05 09:06:13,110 INFO [STDOUT] Got notification: javax.management.Notification[source=jboss.j2ee:service=EJB,plugin=invoker,binding=message-driven-bean,jndiName=local/[email protected]][type=org.jboss.ejb.plugins.jms.DISCONNECTED][message=], handback: null 
2011-05-05 09:06:14,119 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.j2ee:service=EJB,plugin=invoker,binding=message-driven-bean,jndiName=local/[email protected]][type=jmx.attribute.change][message=JMSContainerInvoker stopped], handback: null 
2011-05-05 09:06:15,128 INFO [STDOUT] Got notification: javax.management.Notification[source=jboss.system:service=ServiceController][type=org.jboss.system.ServiceMBean.stop][message=], handback: null 
2011-05-05 09:06:16,138 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.j2ee:service=EJB,plugin=pool,jndiName=local/[email protected]][type=jmx.attribute.change][message=MessageDrivenInstancePool stopping], handback: null 
2011-05-05 09:06:17,148 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.j2ee:service=EJB,plugin=pool,jndiName=local/[email protected]][type=jmx.attribute.change][message=MessageDrivenInstancePool stopped], handback: null 
2011-05-05 09:06:18,157 INFO [STDOUT] Got notification: javax.management.Notification[source=jboss.system:service=ServiceController][type=org.jboss.system.ServiceMBean.stop][message=], handback: null 
2011-05-05 09:06:19,166 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.j2ee:jndiName=local/[email protected],service=EJB][type=jmx.attribute.change][message=MessageDrivenContainer stopped], handback: null 
2011-05-05 09:06:20,175 INFO [STDOUT] Got notification: javax.management.Notification[source=jboss.system:service=ServiceController][type=org.jboss.system.ServiceMBean.stop][message=], handback: null 
2011-05-05 09:06:21,184 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.j2ee:service=EjbModule,module=simple-mdb-ejb-1.0.0-SNAPSHOT.jar][type=jmx.attribute.change][message=EjbModule stopped], handback: null 
2011-05-05 09:06:22,193 INFO [STDOUT] Got notification: javax.management.Notification[source=jboss.system:service=ServiceController][type=org.jboss.system.ServiceMBean.stop][message=], handback: null 
2011-05-05 09:06:23,202 INFO [STDOUT] Got notification: javax.management.Notification[source=jboss.ejb:service=EJBDeployer][type=org.jboss.deployment.SubDeployer.stop][message=], handback: null 
2011-05-05 09:06:24,211 INFO [org.jboss.deployment.ClientDeployer] Removing client ENC from: SimpleMessageClient 
2011-05-05 09:06:24,212 INFO [STDOUT] Got notification: javax.management.Notification[source=jboss.j2ee:service=ClientDeployer][type=org.jboss.deployment.SubDeployer.stop][message=], handback: null 
2011-05-05 09:06:25,221 INFO [STDOUT] Got notification: javax.management.Notification[source=jboss.management.local:ServiceModule=simple-mdb-sar-1.0.0-SNAPSHOT.sar,name=jboss.example%3aname%3dNotificationListener,J2EEServer=Local,J2EEApplication=null,j2eeType=MBean][type=j2ee.state.stopping][message=State changed], handback: null 
2011-05-05 09:06:26,229 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.example:name=NotificationListener][type=jmx.attribute.change][message=NotificationListener stopping], handback: null 
2011-05-05 09:06:27,236 INFO [STDOUT] Stop NotificationListener. 

我認爲這將是最好趕在第一個事件,所以我要趕:

2011-05-05 09:06:09,022 INFO [STDOUT] Got notification: javax.management.AttributeChangeNotification[source=jboss.j2ee:service=EjbModule,module=simple-mdb-ejb-1.0.0-SNAPSHOT.jar][type=jmx.attribute.change][message=EjbModule stopping], handback: null 

有什麼建議嗎?使用示例的JBoss的NotificationListener和假定一個EJB3 MDB deploymentas

+1

嗨克里斯; 您使用的是EJB 2.x嗎?我問,因爲EJB 2.x MDB管理接口比EJB 3有點複雜,因爲它包含對象名稱中的序列號,當我在日誌摘錄中看到它時,它使我認爲您在EJB 2中:jndiName = local/SimpleMessageEJB @ 30208588 – Nicholas 2011-05-09 14:50:39

+0

哦,我使用了一個我在網上找到的示例項目。我會重構它。在真正的項目中,我們使用EJB3。 – 2011-05-10 06:07:46

回答

4

如下:

  • EAR:myear.ear
  • JAR:myjar.jar
  • MDB名稱:MyMDB

部署描述符聽者的MBean會是這樣:

<server> 
    <mbean code="jboss.example.NotificationListener" 
      name="jboss.example:name=NotificationListener"> 
     <attribute name="SubscriptionList">  
     <subscription-list> 
      <mbean name="jboss.j2ee:ear=myear.ear,jar=myjar.jar,service=EJB3,name=MyMDB" handback="MyMDB"> 
      <notification type="jmx.attribute.change"> 
      </mbean> 
     </subscription-list> 
     </attribute> 
    </mbean> 
    </server> 

如果你簡單地記錄通知的的toString停止MDB時,它會是這個樣子:

狀態3(入門) - >狀態1(停止)

NOTIFICATION:<[email protected] 
attributeName=State attributeType=java.lang.Integer **oldValue=3 newValue=1 
type=jmx.attribute.change** sequenceNumber=7 timeStamp=1305033720266 userData=null 
message=MdbDelegateWrapper stopping 
source=jboss.j2ee:ear=myear.ear,jar=myear.jar,name=MyMDB,service=EJB3 
source=jboss.j2ee:ear=myear.ear,jar=myear.jar,name=MyMDB,service=EJB3> 

狀態1(停止) - >狀態0(停止)

NOTIFICATION:<[email protected] attributeName=State 
attributeType=java.lang.Integer **oldValue=1 newValue=0 type=jmx.attribute.change** 
sequenceNumber=8 timeStamp=1305033720320 userData=null 
message=MdbDelegateWrapper stopped 
source=jboss.j2ee:ear=myear.ear,jar=myear.jar,name=MyMDB,service=EJB3 
source=jboss.j2ee:ear=myear.ear,jar=myear.jar,name=MyMDB,service=EJB3> 
+0

謝謝。你從哪裏得到你的知識?我搜索了幾個小時,但沒有找到訂閱列表元素的唯一解釋。 – 2011-05-10 14:31:50

+1

長時間jboss用戶:) – Nicholas 2011-05-10 14:38:54