locator.setBlockOnAcknowledge(true);
locator.setConsumerWindowSize(1024 * 1024);
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession(false, false, false);
Queue queue = server.createQueue(ADDRESS, ADDRESS, null, true, false);
ClientProducer producer = session.createProducer(PagingTest.ADDRESS);
byte[] body = new byte[messageSize];
ByteBuffer bb = ByteBuffer.wrap(body);
for (int j = 1; j <= messageSize; j++)
{
bb.put(getSamplebyte(j));
}
for (int i = 0; i < numberOfMessages; i++)
{
ClientMessage message = session.createMessage(persistentMessages);
HornetQBuffer bodyLocal = message.getBodyBuffer();
bodyLocal.writeBytes(body);
message.putIntProperty(new SimpleString("id"), i);
producer.send(message);
if (i % 1000 == 0)
{
session.commit();
}
}
session.commit();
session.close();
session = sf.createSession(true, true, 0);
session.start();
ClientConsumer consumer = session.createConsumer(ADDRESS);
for (int i = 0; i < numberOfMessages / 2; i++)
{
ClientMessage message = consumer.receive(5000);
assertNotNull(message);
assertEquals(i, message.getIntProperty("id").intValue());
if (i < 100)
{
// Do not consume the last one so we could restart
message.acknowledge();
}
}
session.close();
session = null;
sf.close();
sf = locator.createSessionFactory();
locator = createInVMNonHALocator();
session = sf.createSession(true, true, 0);
session.start();
consumer = session.createConsumer(ADDRESS);
for (int i = 100; i < numberOfMessages; i++)
{
ClientMessage message = consumer.receive(5000);
assertNotNull(message);
assertEquals(i, message.getIntProperty("id").intValue());
message.acknowledge();
}
session.close();
sf.close();
}
catch (Throwable e)