Here are snippets from my Java code. Please let me know if this is enough.
/*
-------------------------------------------------------------------------------------*/
/* Code used to send the message
*/
/*
-------------------------------------------------------------------------------------*/
public void publishEndMatchEvent(SilexEventMessage eventMessage) throws
PubSubException {
try {
Destination destination =
getSession().createQueue(END_MATCH_QUEUE);
TextMessage message =
getSession().createTextMessage(eventMessage.toString());
getProducer().send(destination, message);
String messageId = message.getJMSMessageID();
if (LOG.isDebugEnabled()) {
LOG.debug("Sent " + message + " id: " + messageId + " to "
+ destination);
}
} catch (JMSException e) {
throw new PubSubException(e);
}
}
private Session getSession() throws JMSException {
if (mSession == null) {
mSession = getConnection().createSession(
false, Session.AUTO_ACKNOWLEDGE);
}
return mSession;
}
private Connection getConnection() throws JMSException {
if (mConnection == null) {
mConnection = getFactory().createConnection();
mConnection.start();
}
return mConnection;
}
private MessageProducer getProducer() throws JMSException {
if (mProducer == null) {
mProducer = getSession().createProducer(null);
mProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
mProducer.setTimeToLive(MSG_TIME_TO_LIVE);
}
return mProducer;
}
/*
-------------------------------------------------------------------------------------*/
/* Code used to receive the message
*/
/*
-------------------------------------------------------------------------------------*/
public MatchPostProcessingListener(XMLConfiguration config,
AmqPubSubProviderFactory providerFactory) throws ServletException {
LOG.info("Starting post match processor");
try {
/* Start listening on end of match events */
mConnectionFactory = providerFactory.getFactory();
Destination destination =
getSession().createQueue(END_MATCH_QUEUE);
mConsumer = getSession().createConsumer(destination);
mConsumer.setMessageListener(this);
} catch (JMSException e) {
throw new ServletException(e);
} catch (SilexResourceException e) {
throw new ServletException(e);
}
}
private Session getSession() throws JMSException {
if (mSession == null) {
mSession = getConnection().createSession(
false, Session.AUTO_ACKNOWLEDGE);
}
return mSession;
}
private Connection getConnection() throws JMSException {
if (mConnection == null) {
mConnection = getFactory().createConnection();
mConnection.start();
}
return mConnection;
}
public void onMessage(Message message) {
try {
mMatchReporter.report(((TextMessage) message).getText());
} catch (JMSException e) {
LOG.error("Unable to store audit trace for a match", e);
} catch (MatchReporterException e) {
LOG.error("Unable to store audit trace for a match", e);
}
}
Thanks
Fady
That sounds wonky - whats your Java code look like?
--
View this message in context:
http://www.nabble.com/Messages-are-not-removed-from-queue-after-onMessage-is-fired-tp15018971s2354p15024679.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.