sessionNonTX.start();
for (int i = 0; i < 50; i++)
{
System.out.println("Sending " + i);
ClientMessage message = sessionNonTX.createMessage(true);
message.getBodyBuffer().writeBytes(body);
message.putIntProperty(new SimpleString("id"), i);
message.putStringProperty(new SimpleString("tst"), new SimpleString("i=" + i));
producerTransacted.send(message);
if (i % 2 == 0)
{
System.out.println("Sending 20 msgs to make it page");
for (int j = 0; j < 20; j++)
{
ClientMessage msgSend = sessionNonTX.createMessage(true);
msgSend.putStringProperty(new SimpleString("tst"), new SimpleString("i=" + i + ", j=" + j));
msgSend.getBodyBuffer().writeBytes(new byte[10 * 1024]);
producerNonTransacted.send(msgSend);
}
assertTrue(server.getPostOffice().getPagingManager().getPageStore(PagingTest.ADDRESS).isPaging());
}
else
{
System.out.println("Consuming 20 msgs to make it page");
ClientConsumer consumer = sessionNonTX.createConsumer(PagingTest.ADDRESS);
for (int j = 0; j < 20; j++)
{
ClientMessage msgReceived = consumer.receive(10000);
assertNotNull(msgReceived);
msgReceived.acknowledge();
}
consumer.close();
}
}
ClientConsumer consumerNonTX = sessionNonTX.createConsumer(PagingTest.ADDRESS);
while (true)
{
ClientMessage msgReceived = consumerNonTX.receive(1000);
if (msgReceived == null)
{
break;
}
msgReceived.acknowledge();
}
consumerNonTX.close();
ClientConsumer consumer = sessionNonTX.createConsumer(PagingTest.ADDRESS);
Assert.assertNull(consumer.receiveImmediate());
sessionTransacted.commit();
sessionTransacted.close();
for (int i = 0; i < 50; i++)
{
ClientMessage message = consumer.receive(PagingTest.RECEIVE_TIMEOUT);
Assert.assertNotNull(message);
Integer messageID = (Integer)message.getObjectProperty(new SimpleString("id"));
// System.out.println(messageID);
Assert.assertNotNull(messageID);
Assert.assertEquals("message received out of order", i, messageID.intValue());
System.out.println("MessageID = " + messageID);
message.acknowledge();
}
Assert.assertNull(consumer.receiveImmediate());
consumer.close();