use of com.swiftmq.amqp.v100.generated.messaging.message_format.Properties in project swiftmq-ce by iitsoftware.
the class Replier method serviceRequests.
public void serviceRequests() {
try {
for (int i = 0; i < nMsgs; i++) {
TxnIdIF txnIdIF = txc.createTxnId();
consumer.acquire(1, txnIdIF);
AMQPMessage request = consumer.receive();
if (request != null) {
messageFactory.verify(request);
if (!request.isSettled())
request.accept();
Properties prop = request.getProperties();
if (prop == null)
throw new Exception("Properties not set in request: " + request);
AddressIF replyTo = prop.getReplyTo();
if (replyTo == null)
throw new Exception("replyTo not set in request: " + request);
Producer p = getSession().createProducer(replyTo.getValueString(), qos);
AMQPMessage reply = messageFactory.createReplyMessage(request);
reply.setTxnIdIF(txnIdIF);
Properties prop2 = new Properties();
prop2.setTo(replyTo);
prop2.setCorrelationId(prop.getMessageId());
reply.setProperties(prop2);
p.send(reply);
p.close();
} else
throw new Exception("Msg == null at i=" + i);
txc.commit(txnIdIF);
}
} catch (Exception e) {
fail("test failed: " + e);
}
}
use of com.swiftmq.amqp.v100.generated.messaging.message_format.Properties in project swiftmq-ce by iitsoftware.
the class Requestor method sendRequests.
public void sendRequests() {
try {
AddressIF tempDest = consumer.getRemoteAddress();
for (int i = 0; i < nMsgs; i++) {
TxnIdIF txnIdIF = txc.createTxnId();
AMQPMessage request = messageFactory.create(i);
request.setTxnIdIF(txnIdIF);
Properties prop = new Properties();
prop.setReplyTo(tempDest);
request.setProperties(prop);
producer.send(request, persistent, 5, -1);
txc.commit(txnIdIF);
txnIdIF = txc.createTxnId();
consumer.acquire(1, txnIdIF);
AMQPMessage reply = consumer.receive();
if (reply == null)
throw new Exception("Reply is null");
if (!reply.isSettled())
reply.accept();
txc.commit(txnIdIF);
}
} catch (Exception e) {
fail("test failed: " + e);
}
}
use of com.swiftmq.amqp.v100.generated.messaging.message_format.Properties in project swiftmq-ce by iitsoftware.
the class Requestor method sendRequests.
public void sendRequests() {
try {
AddressIF tempDest = consumer.getRemoteAddress();
for (int i = 0; i < nMsgs; i++) {
TxnIdIF txnIdIF = txc.createTxnId();
AMQPMessage request = messageFactory.create(i);
request.setTxnIdIF(txnIdIF);
Properties prop = new Properties();
prop.setReplyTo(tempDest);
request.setProperties(prop);
producer.send(request, persistent, 5, -1);
txc.commit(txnIdIF);
txnIdIF = txc.createTxnId();
consumer.acquire(1, txnIdIF);
AMQPMessage reply = consumer.receive();
if (reply == null)
throw new Exception("Reply is null");
if (!reply.isSettled())
reply.accept();
txc.commit(txnIdIF);
}
} catch (Exception e) {
fail("test failed: " + e);
}
}
use of com.swiftmq.amqp.v100.generated.messaging.message_format.Properties in project swiftmq-ce by iitsoftware.
the class Replier method serviceRequests.
public void serviceRequests() {
try {
boolean rollback = false;
int i = 0;
while (i < nMsgs) {
TxnIdIF txnIdIF = txc.createTxnId();
AMQPMessage request = consumer.receive();
request.setTxnIdIF(txnIdIF);
if (request != null) {
messageFactory.verify(request);
if (!request.isSettled())
request.accept();
Properties prop = request.getProperties();
if (prop == null)
throw new Exception("Properties not set in request: " + request);
AddressIF replyTo = prop.getReplyTo();
if (replyTo == null)
throw new Exception("replyTo not set in request: " + request);
Producer p = getSession().createProducer(replyTo.getValueString(), qos);
AMQPMessage reply = messageFactory.createReplyMessage(request);
reply.setTxnIdIF(txnIdIF);
Properties prop2 = new Properties();
prop2.setTo(replyTo);
prop2.setCorrelationId(prop.getMessageId());
reply.setProperties(prop2);
p.send(reply);
p.close();
} else
throw new Exception("Msg == null at i=" + i);
if (rollback) {
txc.rollback(txnIdIF);
TxnIdIF tx2 = txc.createTxnId();
request.setTxnIdIF(tx2);
request.reject();
txc.commit(tx2);
} else {
txc.commit(txnIdIF);
i++;
}
rollback = !rollback;
}
} catch (Exception e) {
fail("test failed: " + e);
}
}
use of com.swiftmq.amqp.v100.generated.messaging.message_format.Properties in project swiftmq-ce by iitsoftware.
the class Requestor method sendRequests.
public void sendRequests() {
try {
AddressIF tempDest = consumer.getRemoteAddress();
for (int i = 0; i < nMsgs; i++) {
TxnIdIF txnIdIF = txc.createTxnId();
AMQPMessage request = messageFactory.create(i);
request.setTxnIdIF(txnIdIF);
Properties prop = new Properties();
prop.setReplyTo(tempDest);
request.setProperties(prop);
producer.send(request, persistent, 5, -1);
txc.commit(txnIdIF);
txnIdIF = txc.createTxnId();
AMQPMessage reply = consumer.receive();
if (reply == null)
throw new Exception("Reply is null");
if (!reply.isSettled())
reply.accept();
txc.commit(txnIdIF);
}
} catch (Exception e) {
fail("test failed: " + e);
}
}
Aggregations