public void failoverComplete()
{
_logger.info("App got failover complete callback");
}
});
final Session session = (Session) _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
_logger.info("Service (queue) name is '" + serviceName + "'...");
AMQQueue destination = new AMQQueue(serviceName);
MessageConsumer consumer = session.createConsumer(destination,
100, true, false, null);
consumer.setMessageListener(new MessageListener()
{
private int _messageCount;
public void onMessage(Message message)
{
//_logger.info("Got message '" + message + "'");
TextMessage tm = (TextMessage) message;
try
{
Destination responseDest = tm.getJMSReplyTo();
if (responseDest == null)
{
_logger.info("Producer not created because the response destination is null.");
return;
}
if (!responseDest.equals(_responseDest))
{
_responseDest = responseDest;
_logger.info("About to create a producer");
_destinationProducer = session.createProducer(responseDest);
_destinationProducer.setDisableMessageTimestamp(true);
_destinationProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
_logger.info("After create a producer");
}
}
catch (JMSException e)
{
_logger.error("Error creating destination");
}
_messageCount++;
if (_messageCount % 1000 == 0)
{
_logger.info("Received message total: " + _messageCount);
_logger.info("Sending response to '" + _responseDest + "'");
}
try
{
String payload = "This is a response: sing together: 'Mahnah mahnah...'" + tm.getText();
TextMessage msg = session.createTextMessage(payload);
if (tm.propertyExists("timeSent"))
{
_logger.info("timeSent property set on message");
_logger.info("timeSent value is: " + tm.getLongProperty("timeSent"));
msg.setStringProperty("timeSent", tm.getStringProperty("timeSent"));