use of com.swiftmq.amqp.v100.types.AMQPType in project swiftmq-client by iitsoftware.
the class Rejected method decode.
private void decode() throws Exception {
List l = getValue();
AMQPType t = null;
int idx = 0;
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
error = new Error(((AMQPList) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'error' in 'Rejected' type: " + e);
}
}
use of com.swiftmq.amqp.v100.types.AMQPType in project swiftmq-client by iitsoftware.
the class Header method decode.
private void decode() throws Exception {
List l = getValue();
AMQPType t = null;
int idx = 0;
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
durable = (AMQPBoolean) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'durable' in 'Header' type: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
priority = (AMQPUnsignedByte) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'priority' in 'Header' type: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
ttl = new Milliseconds(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'ttl' in 'Header' type: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
firstAcquirer = (AMQPBoolean) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'firstAcquirer' in 'Header' type: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
deliveryCount = (AMQPUnsignedInt) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'deliveryCount' in 'Header' type: " + e);
}
}
use of com.swiftmq.amqp.v100.types.AMQPType in project swiftmq-client by iitsoftware.
the class SessionDispatcher method visit.
public void visit(POAttachProducer po) {
if (pTracer.isEnabled())
pTracer.trace(toString(), ", visit, po=" + po + " ...");
String name = null;
DeliveryMemory deliveryMemory = po.getDeliveryMemory();
if (deliveryMemory.getLinkName() != null)
name = deliveryMemory.getLinkName();
else {
name = uniqueSessionId + "/" + po.getTarget() + "/" + (nextLinkId++);
deliveryMemory.setLinkName(name);
}
Producer producer = new Producer(mySession, po.getTarget(), name, po.getQoS(), deliveryMemory);
int handle = ArrayListTool.setFirstFreeOrExpand(handles, producer);
producer.setHandle(handle);
po.setLink(producer);
waitingPO.put(name, po);
try {
AttachFrame attachFrame = new AttachFrame(mySession.getChannel());
attachFrame.setName(new AMQPString(name));
attachFrame.setHandle(new Handle(handle));
attachFrame.setRole(Role.SENDER);
switch(producer.getQoS()) {
case QoS.AT_LEAST_ONCE:
attachFrame.setRcvSettleMode(ReceiverSettleMode.FIRST);
break;
case QoS.AT_MOST_ONCE:
attachFrame.setSndSettleMode(SenderSettleMode.SETTLED);
break;
case QoS.EXACTLY_ONCE:
attachFrame.setRcvSettleMode(ReceiverSettleMode.SECOND);
break;
}
Source source = new Source();
source.setAddress(new AddressString(name));
source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
source.setTimeout(new Seconds(0));
attachFrame.setSource(source);
String t = po.getTarget();
if (t.equals(Coordinator.DESCRIPTOR_NAME)) {
Coordinator coordinator = new Coordinator();
coordinator.setCapabilities(new AMQPArray(AMQPTypeDecoder.SYM8, new AMQPType[] { TxnCapability.LOCAL_TRANSACTIONS }));
attachFrame.setTarget(coordinator);
} else {
Target target = new Target();
target.setAddress(new AddressString(t));
target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
target.setTimeout(new Seconds(0));
attachFrame.setTarget(target);
}
attachFrame.setInitialDeliveryCount(new SequenceNo(producer.getDeliveryCountSnd()));
attachFrame.setUnsettled(getUnsettledMap(producer.getDeliveryMemory()));
outboundHandler.send(attachFrame);
} catch (Exception e) {
e.printStackTrace();
}
if (pTracer.isEnabled())
pTracer.trace(toString(), ", visit, po=" + po + " done");
}
use of com.swiftmq.amqp.v100.types.AMQPType in project swiftmq-client by iitsoftware.
the class Producer method recover.
protected void recover(AMQPMap remoteUnsettled) {
try {
if (remoteUnsettled != null) {
Map<AMQPType, AMQPType> map = remoteUnsettled.getValue();
for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
final DeliveryTag deliveryTag = new DeliveryTag(((AMQPBinary) entry.getKey()).getValue());
final AMQPList deliveryState = (AMQPList) entry.getValue();
if (deliveryState != null) {
try {
DeliveryStateFactory.create(deliveryState).accept(new DeliveryStateVisitorAdapter() {
public void visit(Accepted impl) {
deliveryMemory.deliverySettled(deliveryTag);
mySession.dispatch(new POSendResumedTransfer(Producer.this, deliveryTag));
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
if (deliveryMemory.getNumberUnsettled() > 0) {
Collection<UnsettledDelivery> unsettled = deliveryMemory.getUnsettled();
for (Iterator<UnsettledDelivery> iter = unsettled.iterator(); iter.hasNext(); ) {
UnsettledDelivery unsettledDelivery = iter.next();
if (unsettledDelivery.getMessage() != null) {
AMQPMessage msg = unsettledDelivery.getMessage();
if (msg.getTxnIdIF() == null) {
POSendMessage po = new POSendMessage(null, this, msg, null, unsettledDelivery.getDeliveryTag());
po.setRecovery(true);
mySession.dispatch(po);
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.swiftmq.amqp.v100.types.AMQPType in project swiftmq-client by iitsoftware.
the class Source method decode.
private void decode() throws Exception {
List l = getValue();
AMQPType t = null;
int idx = 0;
// Factory : AddressFactory
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
if (t.getCode() != AMQPTypeDecoder.NULL)
address = AddressFactory.create(t);
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
durable = new TerminusDurability(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'durable' in 'Source' type: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
expiryPolicy = new TerminusExpiryPolicy(((AMQPSymbol) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'expiryPolicy' in 'Source' type: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
timeout = new Seconds(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'timeout' in 'Source' type: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
dynamic = (AMQPBoolean) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'dynamic' in 'Source' type: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
dynamicNodeProperties = new NodeProperties(((AMQPMap) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'dynamicNodeProperties' in 'Source' type: " + e);
}
// Factory : DistributionModeFactory
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
if (t.getCode() != AMQPTypeDecoder.NULL)
distributionMode = DistributionModeFactory.create(t);
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
filter = new FilterSet(((AMQPMap) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'filter' in 'Source' type: " + e);
}
// Factory : OutcomeFactory
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
if (t.getCode() != AMQPTypeDecoder.NULL)
defaultOutcome = OutcomeFactory.create(t);
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
outcomes = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'outcomes' in 'Source' type: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
capabilities = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'capabilities' in 'Source' type: " + e);
}
}
Aggregations