session.createQueue(address, queue, null, false);
session.createQueue(otherAddress, otherQueue, null, false);
ClientProducer producer = session.createProducer(address);
// send on queue
ClientMessage matchingMessage = session.createMessage(false);
matchingMessage.putLongProperty(key, matchingValue);
producer.send(matchingMessage);
ClientMessage unmatchingMessage = session.createMessage(false);
unmatchingMessage.putLongProperty(key, unmatchingValue);
producer.send(unmatchingMessage);
QueueControl queueControl = createManagementControl(address, queue);
Assert.assertEquals(2, queueControl.getMessageCount());
// moved matching messages to otherQueue
int movedMatchedMessagesCount = queueControl.moveMessages(key + " =" + matchingValue, otherQueue.toString());
Assert.assertEquals(1, movedMatchedMessagesCount);
Assert.assertEquals(1, queueControl.getMessageCount());
// consume the unmatched message from queue
ClientConsumer consumer = session.createConsumer(queue);
ClientMessage m = consumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals(unmatchingValue, m.getObjectProperty(key));
// consume the matched message from otherQueue
ClientConsumer otherConsumer = session.createConsumer(otherQueue);
m = otherConsumer.receive(500);
Assert.assertNotNull(m);
Assert.assertEquals(matchingValue, m.getObjectProperty(key));
m.acknowledge();
consumer.close();
session.deleteQueue(queue);
otherConsumer.close();
session.deleteQueue(otherQueue);