use of com.swiftmq.amqp.v100.types.AMQPMap 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.AMQPMap 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);
}
}
use of com.swiftmq.amqp.v100.types.AMQPMap in project swiftmq-client by iitsoftware.
the class Target 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 'Target' 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 'Target' 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 'Target' 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 'Target' 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 'Target' 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 'Target' type: " + e);
}
}
use of com.swiftmq.amqp.v100.types.AMQPMap in project swiftmq-client by iitsoftware.
the class FlowFrame 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)
nextIncomingId = new TransferNumber(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'nextIncomingId' in 'Flow' 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 'Flow' frame is NULL");
try {
incomingWindow = (AMQPUnsignedInt) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'incomingWindow' in 'Flow' 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 'Flow' frame is NULL");
try {
nextOutgoingId = new TransferNumber(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'nextOutgoingId' in 'Flow' 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 'Flow' frame is NULL");
try {
outgoingWindow = (AMQPUnsignedInt) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'outgoingWindow' in 'Flow' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
handle = new Handle(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'handle' in 'Flow' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
deliveryCount = new SequenceNo(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'deliveryCount' in 'Flow' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
linkCredit = (AMQPUnsignedInt) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'linkCredit' in 'Flow' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
available = (AMQPUnsignedInt) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'available' in 'Flow' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
drain = (AMQPBoolean) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'drain' in 'Flow' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
echo = (AMQPBoolean) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'echo' in 'Flow' 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 'Flow' frame: " + e);
}
}
use of com.swiftmq.amqp.v100.types.AMQPMap in project swiftmq-client by iitsoftware.
the class OpenFrame 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++);
if (t.getCode() == AMQPTypeDecoder.NULL)
throw new Exception("Mandatory field 'containerId' in 'Open' frame is NULL");
try {
containerId = (AMQPString) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'containerId' in 'Open' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
hostname = (AMQPString) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'hostname' in 'Open' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
maxFrameSize = (AMQPUnsignedInt) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'maxFrameSize' in 'Open' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
channelMax = (AMQPUnsignedShort) t;
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'channelMax' in 'Open' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
idleTimeOut = new Milliseconds(((AMQPUnsignedInt) t).getValue());
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'idleTimeOut' in 'Open' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
outgoingLocales = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'outgoingLocales' in 'Open' frame: " + e);
}
// Factory : ./.
if (idx >= l.size())
return;
t = (AMQPType) l.get(idx++);
try {
if (t.getCode() != AMQPTypeDecoder.NULL)
incomingLocales = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
} catch (ClassCastException e) {
throw new Exception("Invalid type of field 'incomingLocales' in 'Open' 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 'Open' 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 'Open' 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 'Open' frame: " + e);
}
}
Aggregations