locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
locator.setConsumerWindowSize(0);
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession(false, false, false);
QueueImpl queue = (QueueImpl)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(false, false, 0);
session.start();
ClientConsumer consumer = session.createConsumer(ADDRESS);
// number of references without paging
int numberOfRefs = queue.getNumberOfReferences();
// consume all non-paged references
for (int ref = 0; ref < numberOfRefs; ref++)
{
ClientMessage msg = consumer.receive(5000);
assertNotNull(msg);
msg.acknowledge();
}
session.commit();
session.close();
session = sf.createSession(false, false, 0);
session.start();
consumer = session.createConsumer(ADDRESS);
ClientMessage msg = consumer.receive(5000);
assertNotNull(msg);
int msgIDRolledBack = msg.getIntProperty("id").intValue();
msg.acknowledge();
session.rollback();
msg = consumer.receive(5000);
assertNotNull(msg);
assertEquals(msgIDRolledBack, msg.getIntProperty("id").intValue());
session.rollback();
session.close();
sf.close();
locator.close();
server.stop();
server.start();
locator = createInVMNonHALocator();
locator.setClientFailureCheckPeriod(1000);
locator.setConnectionTTL(2000);
locator.setReconnectAttempts(0);
locator.setBlockOnNonDurableSend(true);
locator.setBlockOnDurableSend(true);
locator.setBlockOnAcknowledge(true);
locator.setConsumerWindowSize(0);
sf = locator.createSessionFactory();
session = sf.createSession(false, false, 0);
session.start();
consumer = session.createConsumer(ADDRESS);