use of com.swiftmq.amqp.v100.generated.messaging.message_format.Properties in project swiftmq-client by iitsoftware.
the class BeginFrame method decode.
private void decode() throws Exception {
List l = body.getValue();
AMQPType t = null;
int idx = 0;
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
remoteChannel = (AMQPUnsignedShort) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'remoteChannel' in 'Begin' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
if (t.getCode() == AMQPTypeDecoder.NULL)
throw new Exception("Mandatory field 'nextOutgoingId' in 'Begin' frame is NULL");
try {
nextOutgoingId = new TransferNumber(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'nextOutgoingId' in 'Begin' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
if (t.getCode() == AMQPTypeDecoder.NULL)
throw new Exception("Mandatory field 'incomingWindow' in 'Begin' frame is NULL");
try {
incomingWindow = (AMQPUnsignedInt) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'incomingWindow' in 'Begin' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
if (t.getCode() == AMQPTypeDecoder.NULL)
throw new Exception("Mandatory field 'outgoingWindow' in 'Begin' frame is NULL");
try {
outgoingWindow = (AMQPUnsignedInt) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'outgoingWindow' in 'Begin' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
handleMax = new Handle(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'handleMax' in 'Begin' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
offeredCapabilities = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'offeredCapabilities' in 'Begin' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
desiredCapabilities = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'desiredCapabilities' in 'Begin' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
properties = new Fields(((AMQPMap) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'properties' in 'Begin' frame: " + e);
}
}
use of com.swiftmq.amqp.v100.generated.messaging.message_format.Properties in project swiftmq-client by iitsoftware.
the class AMQPRepo method remove.
AMQPRepo remove(String appname) throws Exception {
AMQPMessage request = new AMQPMessage();
Map propMap = new HashMap();
propMap.put(new AMQPString("app"), new AMQPString(appname));
propMap.put(new AMQPString("operation"), new AMQPString("remove"));
request.setApplicationProperties(new ApplicationProperties(propMap));
Properties properties = new Properties();
properties.setReplyTo(replyQueue);
request.setProperties(properties);
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("Removed 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.Properties in project swiftmq-ce by iitsoftware.
the class Replier method serviceRequests.
public void serviceRequests() {
try {
for (int i = 0; i < nMsgs; i++) {
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);
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);
}
} 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++) {
AMQPMessage request = messageFactory.create(i);
Properties prop = new Properties();
prop.setReplyTo(tempDest);
request.setProperties(prop);
producer.send(request, persistent, 5, -1);
AMQPMessage reply = consumer.receive();
if (reply == null)
throw new Exception("Reply is null");
if (!reply.isSettled())
reply.accept();
}
} 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();
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);
if (rollback)
txc.rollback(txnIdIF);
else {
txc.commit(txnIdIF);
i++;
}
rollback = !rollback;
}
} catch (Exception e) {
fail("test failed: " + e);
}
}
Aggregations