use of com.swiftmq.amqp.v100.types.AMQPString 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);
}
}
use of com.swiftmq.amqp.v100.types.AMQPString in project swiftmq-ce by iitsoftware.
the class AMQPSequenceMessageFactory method createReplyMessage.
public AMQPMessage createReplyMessage(AMQPMessage request) throws Exception {
AMQPMessage reply = new AMQPMessage();
List list = request.getAmqpSequence();
((AmqpSequence) list.get(0)).getValue().add(new AMQPString("REPLY"));
for (int i = 0; i < list.size(); i++) reply.addAmqpSequence(((AmqpSequence) list.get(i)));
return reply;
}
use of com.swiftmq.amqp.v100.types.AMQPString in project swiftmq-ce by iitsoftware.
the class AMQPSequenceMessageFactory method create.
public AMQPMessage create(int sequenceNo) throws Exception {
AMQPMessage msg = new AMQPMessage();
List list = new ArrayList();
list.add(new AMQPString("key1"));
list.add(new AMQPLong(Integer.MAX_VALUE + 1));
list.add(new AMQPString("key3"));
list.add(new AMQPLong(Integer.MAX_VALUE + 2));
msg.addAmqpSequence(new AmqpSequence(list));
return msg;
}
use of com.swiftmq.amqp.v100.types.AMQPString in project swiftmq-ce by iitsoftware.
the class AMQPValueMapMessageFactory method createReplyMessage.
public AMQPMessage createReplyMessage(AMQPMessage request) throws Exception {
AMQPMessage reply = new AMQPMessage();
Map map = ((AMQPMap) request.getAmqpValue().getValue()).getValue();
map.put(new AMQPString("REPLY"), new AMQPString("REPLY"));
reply.setAmqpValue(new AmqpValue(new AMQPMap(map)));
return reply;
}
use of com.swiftmq.amqp.v100.types.AMQPString in project swiftmq-ce by iitsoftware.
the class AMQPValueStringMessageFactory method verify.
public void verify(AMQPMessage message) throws Exception {
AmqpValue value = message.getAmqpValue();
if (value == null)
throw new Exception(("verify - no AmqpValue section found!"));
AMQPString s = (AMQPString) value.getValue();
if (!s.getValue().startsWith("Message #"))
throw new Exception("verify - invalid value detected: " + s.getValue());
}
Aggregations