客户端监控连接ActiveMQ状态

1、spring配置文件中配置exceptionListener

<bean id="exceptionListener" class="test.TempExceptionListener">

</bean>

<bean id="listenerContainer"

class="org.springframework.jms.listener.DefaultMessageListenerContainer">

<property name="connectionFactory" ref="connectionFactory"></property>

<property name="destination" ref="messageListenerQueue"></property>

<property name="messageListener" ref="messageListener"></property>

<property name="exceptionListener" ref="exceptionListener"></property>

</bean>

2、创建TempExceptionListener实现javax.jms.ExceptionListener接口

@Override

    public void onException(JMSException e) {

        LOG.error("TempExceptionListener 收到消息:" + e);

        LOG.warn("发送监控告警~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

        

    }

猜你喜欢

转载自lvmlvy.iteye.com/blog/1904230
今日推荐