如何设置JMX通知侦听器? [英] How to setup a JMX Notification Listener?

查看:175
本文介绍了如何设置JMX通知侦听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是如何在取消部署之前停止邮件处理的后续行动?

我想为取消部署事件配置JMX Notification Listener,但我不知道如何正确设置mbean名称。我们目前正在使用JBoss 4.2.3。以下尝试不会触发任何通知。

I want to configure a JMX Notification Listener for undeployment events, but I don't know how to set the mbean name correctly. We are currently using JBoss 4.2.3. The following attempt won't trigger any notification.

<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>

以下是取消部署时弹出的所有通知事件的列表:

Here is a list of all notification events, which pop up on undeployment:

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/SimpleMessageEJB@30208588,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/SimpleMessageEJB@30208588][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/SimpleMessageEJB@30208588][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/SimpleMessageEJB@30208588][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/SimpleMessageEJB@30208588][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/SimpleMessageEJB@30208588][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/SimpleMessageEJB@30208588][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/SimpleMessageEJB@30208588,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.

我认为最好赶上第一个事件,所以我想抓住:

I thought it would be best to catch the very first event, so I want to catch:

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部署如下:

Using the example JBoss NotificationListener and assuming an EJB3 MDB deploymentas follows:


  • EAR :myear.ear

  • JAR :myjar.jar

  • MDB名称:MyMDB

  • EAR: myear.ear
  • JAR: myjar.jar
  • MDB Name: MyMDB

侦听器MBean的部署描述符如下所示:

the deployment descriptor for the listener MBean would be like this:

  <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,它看起来像这样:

If you were to simply log the toString of the notification when stopping the MDB, it would look something like this:

状态3(已开始) - >状态1(停止)

    NOTIFICATION:<javax.management.AttributeChangeNotification@60de8209
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:<javax.management.AttributeChangeNotification@296e41ab 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>

这篇关于如何设置JMX通知侦听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆