I have a project coded using Spring-hibernate-activeMq
What I would like to know is if I configured activeMq like I explained below, how should I implement the exception listener class of it? I know you don’t understand well now but please give a look to my samples below.
Let me know if I implemented exception listener right or not. If not, please give an example how it must be. Thanks in advance.
Application context: (note that I didn’t declare any bean for exception listener except the one the property of connectionFactory)
<bean id="connectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory"
depends-on="broker">
<constructor-arg ref="amqConnectionFactory"/>
<property name="reconnectOnException" value="true"/>
<property name="exceptionListener" ref="jmsExceptionListener"/>
<property name="sessionCacheSize" value="100"/>
</bean>
Jms exception listener class: (Note that I am trying to inject ConnectionFactory, I am not sure whether it is possible or not.. And the last thing, please check the constructor arguments of it, I am also not sure of it..)
@Component("jmsExceptionListener")
public class JMSExceptionListener implements ExceptionListener {
private final static Logger logger = LoggerFactory.getLogger(JMSExceptionListener.class);
@Autowired
private CachingConnectionFactory connection;
// private Connection connection = null;
private ExceptionListener exceptionListener = null;
public JMSExceptionListener() {
}
public JMSExceptionListener(CachingConnectionFactory connection, ExceptionListener exceptionListener) {
super();
this.connection = connection;
this.exceptionListener = exceptionListener;
}
public void onException(JMSException arg0) {
logger.error("JMS exception has occured.. ", arg0);
if(connection != null){
connection.onException(arg0);
}
if (exceptionListener != null) {
exceptionListener.onException(arg0);
}
}
}
I have manipulated exceptionListener class like the following:
}