use of com.swiftmq.amqp.v100.types.AMQPInt in project swiftmq-ce by iitsoftware.
the class ReceiveTester method test.
public void test() {
try {
Connection connection = Util.createConnection();
Session session = Util.createSession(connection);
Producer producer = session.createProducer(address, qos);
for (int i = 0; i < nMsgs; i++) {
AMQPMessage msg = messageFactory.create(i);
Map map = new HashMap();
map.put(new AMQPString(PROPNAME), new AMQPInt(i));
msg.setApplicationProperties(new ApplicationProperties(map));
producer.send(msg, persistent, 5, -1);
}
Consumer consumer = session.createConsumer(address, 500, qos, true, null);
for (int i = 0; i < nMsgs; i++) {
AMQPMessage msg = consumer.receive(1000);
if (msg != null) {
messageFactory.verify(msg);
if (!msg.isSettled())
msg.accept();
receiveVerifier.add(msg);
} else
throw new Exception("message is null");
}
connection.close();
DeliveryMemory deliveryMemory = consumer.getDeliveryMemory();
System.out.println("Unsettled: " + deliveryMemory.getNumberUnsettled());
connection = Util.createConnection();
session = Util.createSession(connection);
Consumer consumerRecover = session.createConsumer(address, 500, qos, true, null, deliveryMemory);
consumerRecover.close();
session.close();
connection.close();
connection = Util.createConnection();
session = Util.createSession(connection);
consumer = session.createConsumer(address, 500, qos, true, null);
for (; ; ) {
AMQPMessage msg = consumer.receive(1000);
if (msg != null) {
messageFactory.verify(msg);
if (!msg.isSettled())
msg.accept();
receiveVerifier.add(msg);
} else
break;
}
consumer.close();
session.close();
connection.close();
receiveVerifier.verify();
} catch (Exception e) {
e.printStackTrace();
fail("test failed: " + e);
}
}
use of com.swiftmq.amqp.v100.types.AMQPInt in project swiftmq-ce by iitsoftware.
the class SendTester method test.
public void test() {
try {
Connection connection = Util.createConnection();
Session session = Util.createSession(connection);
Producer producer = session.createProducer(address, qos);
for (int i = 0; i < nMsgs; i++) {
AMQPMessage msg = messageFactory.create(i);
Map map = new HashMap();
map.put(new AMQPString(PROPNAME), new AMQPInt(i));
msg.setApplicationProperties(new ApplicationProperties(map));
producer.send(msg, persistent, 5, -1);
}
connection.close();
DeliveryMemory deliveryMemory = producer.getDeliveryMemory();
System.out.println("Unsettled: " + deliveryMemory.getNumberUnsettled());
connection = Util.createConnection();
session = Util.createSession(connection);
Producer producerRecover = session.createProducer(address, qos, deliveryMemory);
producerRecover.close();
session.close();
connection.close();
connection = Util.createConnection();
session = Util.createSession(connection);
Consumer consumer = session.createConsumer(address, 500, qos, true, null);
for (; ; ) {
AMQPMessage msg = consumer.receive(1000);
if (msg != null) {
messageFactory.verify(msg);
if (!msg.isSettled())
msg.accept();
receiveVerifier.add(msg);
} else
break;
}
consumer.close();
session.close();
connection.close();
receiveVerifier.verify();
} catch (Exception e) {
e.printStackTrace();
fail("test failed: " + e);
}
}
Aggregations