prod1.send(msg);
}
session.commit();
ClientConsumer consumer = session.createConsumer("q1", true);
session.start();
assertNotNull(consumer.receive(5000));
consumer.close();
QueueControl q1Control = ManagementControlHelper.createQueueControl(new SimpleString("q1"),
new SimpleString("q1"),
mbeanServer);
QueueControl q2Control = ManagementControlHelper.createQueueControl(new SimpleString("q2"),
new SimpleString("q2"),
mbeanServer);
assertEquals(NUMBER_OF_MSGS, q1Control.moveMessages(null, "q2"));
long messageIDs[] = new long[NUMBER_OF_MSGS];
consumer = session.createConsumer("q2", true);
for (int i = 0 ; i < NUMBER_OF_MSGS; i++)
{
ClientMessage msg = consumer.receive(5000);
assertNotNull(msg);
messageIDs[i] = msg.getMessageID();
}
assertNull(consumer.receiveImmediate());
consumer.close();
for (int i = 0 ; i < NUMBER_OF_MSGS; i++)
{
q2Control.moveMessage(messageIDs[i], "q1");
}
session.start();
consumer = session.createConsumer("q1");
for (int i = 0; i < NUMBER_OF_MSGS; i++)
{
ClientMessage msg = consumer.receive(5000);
System.out.println("msg = " + msg);
assertNotNull(msg);
msg.acknowledge();
}
consumer.close();
session.deleteQueue("q1");
session.deleteQueue("q2");