use of com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue in project swiftmq-ce by iitsoftware.
the class AMQPValueMapMessageFactory method create.
public AMQPMessage create(int sequenceNo) throws Exception {
AMQPMessage msg = new AMQPMessage();
Map map = new HashMap();
map.put(new AMQPString("key1"), new AMQPString("value1"));
map.put(new AMQPLong(Integer.MAX_VALUE + 1), new AMQPLong(200));
map.put(new AMQPString("key3"), new AMQPString("value1"));
map.put(new AMQPLong(Integer.MAX_VALUE + 2), new AMQPLong(400));
msg.setAmqpValue(new AmqpValue(new AMQPMap(map)));
return msg;
}
use of com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue in project swiftmq-ce by iitsoftware.
the class AMQPValueStringMessageFactory method createReplyMessage.
public AMQPMessage createReplyMessage(AMQPMessage request) throws Exception {
AMQPMessage reply = new AMQPMessage();
reply.setAmqpValue(new AmqpValue(new AMQPString("RE: " + ((AMQPString) request.getAmqpValue().getValue()).getValue())));
return reply;
}
use of com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue in project swiftmq-ce by iitsoftware.
the class AMQPValueStringMessageFactory method create.
public AMQPMessage create(int sequenceNo) throws Exception {
AMQPMessage msg = new AMQPMessage();
msg.setAmqpValue(new AmqpValue(new AMQPString("Message #" + sequenceNo)));
return msg;
}
use of com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue in project swiftmq-client by iitsoftware.
the class AMQPRepo method add.
AMQPRepo add(File file, String appname) throws Exception {
String filename = file.getName();
String content = loadFile(file);
AMQPMessage request = new AMQPMessage();
Map propMap = new HashMap();
propMap.put(new AMQPString("app"), new AMQPString(appname));
propMap.put(new AMQPString("file"), new AMQPString(filename));
propMap.put(new AMQPString("operation"), new AMQPString("add"));
request.setApplicationProperties(new ApplicationProperties(propMap));
Properties properties = new Properties();
properties.setReplyTo(replyQueue);
request.setProperties(properties);
request.setAmqpValue(new AmqpValue(new AMQPString(content)));
producer.send(request);
AMQPMessage reply = consumer.receive(TIMEOUT);
if (reply == null)
throw new Exception("Timeout occurred while waiting for a reply!");
AMQPMap body = (AMQPMap) reply.getAmqpValue().getValue();
boolean success = ((AMQPBoolean) (body.getValue().get(new AMQPString("success")))).getValue();
if (success)
System.out.println(filename + " added to repository " + appname);
else {
String result = ((AMQPString) (body.getValue().get(new AMQPString("result")))).getValue();
System.out.println(result);
}
return this;
}
use of com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue in project swiftmq-client by iitsoftware.
the class TransactionController method createTxnId.
/**
* Creates a new transaction id.
*
* @return transaction id
* @throws AMQPException on error
*/
public synchronized TxnIdIF createTxnId() throws AMQPException {
if (producer == null) {
producer = mySession.createProducer(Coordinator.DESCRIPTOR_NAME, QoS.AT_LEAST_ONCE);
producer.setTransactionController(true);
Set capa = producer.getDestinationCapabilities();
if (capa != null) {
if (capa.contains(TxnCapability.LOCAL_TRANSACTIONS.getValue()))
supportLocalTransactions = true;
supportDistributedTransactions = capa.contains(TxnCapability.DISTRIBUTED_TRANSACTIONS.getValue());
supportPromotableTransactions = capa.contains(TxnCapability.PROMOTABLE_TRANSACTIONS.getValue());
supportMultiTxnsPerSsn = capa.contains(TxnCapability.MULTI_TXNS_PER_SSN.getValue());
supportMultiSsnsPerTxn = capa.contains(TxnCapability.MULTI_SSNS_PER_TXN.getValue());
}
}
AMQPMessage msg = new AMQPMessage();
msg.setAmqpValue(new AmqpValue(new Declare()));
Declared declared = (Declared) producer.send(msg);
return declared == null ? null : declared.getTxnId();
}
Aggregations