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("发送监控告警~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}