Queue q1 = server.createQueue(ADDRESS, ADDRESS, null, true, false);
Queue q2 = server.createQueue(ADDRESS, new SimpleString("inactive"), 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));
}
final AtomicInteger errors = new AtomicInteger(0);
Thread t1 = new Thread()
{
public void run()
{
try
{
ServerLocator sl = createInVMNonHALocator();
ClientSessionFactory sf = sl.createSessionFactory();
ClientSession sess = sf.createSession(true, true, 0);
sess.start();
ClientConsumer cons = sess.createConsumer(ADDRESS);
for (int i = 0; i < numberOfMessages; i++)
{
ClientMessage msg = cons.receive(5000);
assertNotNull(msg);
assertEquals(i, msg.getIntProperty("id").intValue());
msg.acknowledge();
}
assertNull(cons.receiveImmediate());
sess.close();
sl.close();
}
catch (Throwable e)
{
e.printStackTrace();
errors.incrementAndGet();
}
}
};
t1.start();
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 % 20 == 0)
{
session.commit();
}
}