public void testMoveIndividualMessagesWithDuplicateIDSetUsingI() throws Exception
{
String otherQueueName = RandomUtil.randomString();
serverManager.createQueue(false, otherQueueName, null, true, otherQueueName);
HornetQDestination otherQueue = (HornetQDestination)HornetQJMSClient.createQueue(otherQueueName);
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession(true, true);
ClientProducer prod1 = session.createProducer(queue.getAddress());
ClientProducer prod2 = session.createProducer(otherQueue.getAddress());
String [] ids = new String[10];
for (int i = 0; i < 10; i++)
{
ClientMessage msg = session.createMessage(true);
msg.putStringProperty(org.hornetq.api.core.Message.HDR_DUPLICATE_DETECTION_ID, new SimpleString("dupl-" + i));
msg.setUserID(UUIDGenerator.getInstance().generateUUID());
prod1.send(msg);
ids[i] = "ID:" + msg.getUserID().toString();
if (i < 5)
{
msg.setUserID(UUIDGenerator.getInstance().generateUUID());
prod2.send(msg);
}
}
session.commit();
JMSQueueControl queueControl = createManagementControl();
JMSQueueControl otherQueueControl = ManagementControlHelper.createJMSQueueControl((HornetQQueue)otherQueue,
mbeanServer);
Assert.assertEquals(10, queueControl.getMessageCount());
for (int i = 0 ; i < 10; i++)
{
queueControl.moveMessage(ids[i], otherQueueName, true);
}
assertEquals(0, queueControl.getDeliveringCount());
session.start();
ClientConsumer cons1 = session.createConsumer(queue.getAddress());
assertNull(cons1.receiveImmediate());
cons1.close();
ClientConsumer cons2 = session.createConsumer(otherQueue.getAddress());
for (int i = 0; i < 10; i++)
{
ClientMessage msg = cons2.receive(10000);