{
log.info("+++ testOnCreateMDBTimer");
InitialContext ctx = new InitialContext();
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
QueueConnection queConn = null;
QueueSession session = null;
QueueSender sender = null;
QueueReceiver receiver = null;
try
{
queConn = factory.createQueueConnection();
queConn.start();
Queue queueA = (Queue) ctx.lookup("queue/C");
Queue queueB = (Queue) ctx.lookup("queue/D");
session = queConn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
sender = session.createSender(queueA);
receiver = session.createReceiver(queueB);
while (receiver.receive(1000) != null)
{
// Empty the queue
}
TextMessage message = session.createTextMessage();
message.setText("testOnCreateMDBTimer");
message.setIntProperty("UNIQUE_ID", 123456788);
message.setJMSReplyTo(queueB);
sender.send(message);
// Get the initial onMessage ack
Message reply = receiver.receive(15000);
log.info("onMessage reply: " + reply);
assertTrue("onMessage reply != null", reply != null);
int id = reply.getIntProperty("UNIQUE_ID");
assertTrue("onMessage reply.id = 123456788", id == 123456788);
// Get the 10 ejbCreate timer replys
for(int n = 0; n < 10; n ++)
{
reply = receiver.receive(15000);
log.info("ejbTimeout reply: " + reply);
assertTrue("ejbTimeout reply != null", reply != null);
id = reply.getIntProperty("UNIQUE_ID");
assertTrue("onMessage reply.id = 123456788", id == 123456788);
long elapsed = reply.getLongProperty("Elapsed");
log.info("Elapsed: "+elapsed);
}
}
finally
{
if (receiver != null)
{
try
{
receiver.close();
} catch (JMSException ignore)
{
//
}
}
if (sender != null)
{
try
{
sender.close();
} catch (JMSException ignore)
{
//
}
}
if (session != null)
{
try
{
session.close();
} catch (JMSException ignore)
{
//
}
}
if (queConn != null)
{
try
{
queConn.close();
} catch (JMSException ignore)
{
//
}
}