use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-client by iitsoftware.
the class Versionable method create.
private Object create(VEntry entry) throws Exception {
DataByteArrayInputStream dis = new DataByteArrayInputStream();
dis.setBuffer(entry.versioned.getPayload(), 0, entry.versioned.getLength());
Object obj = null;
if (entry.version == -1) {
obj = DestinationFactory.createDestination(dis);
} else {
DumpableFactory factory = null;
if (classLoader == null)
factory = (DumpableFactory) Class.forName(entry.factoryClass).newInstance();
else
factory = (DumpableFactory) classLoader.loadClass(entry.factoryClass).newInstance();
Dumpable d = factory.createDumpable(dis.readInt());
d.readContent(dis);
obj = d;
}
return obj;
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-ce by iitsoftware.
the class RouteRequest method getRoute.
public Route getRoute(DumpableFactory factory) throws Exception {
DataByteArrayInputStream dbis = new DataByteArrayInputStream(buffer);
route = (Route) factory.createDumpable(dbis.readInt());
if (route == null)
throw new Exception("Unable to create Route!");
route.readContent(dbis);
return route;
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-ce by iitsoftware.
the class SourceLink method verifyLocalAddress.
public void verifyLocalAddress() throws AuthenticationException, QueueException, TopicException, InvalidSelectorException {
if (!dynamic) {
// This is for the case of reconnecting to a Durable Subscriber without specifying a Source in the attach frame.
if (localAddress == null) {
String topicName = ctx.topicManager.getDurableTopicName(getName(), mySessionHandler.getVersionedConnection().getActiveLogin());
if (topicName != null)
localAddress = new AddressString(topicName);
durability = TerminusDurability.CONFIGURATION;
}
super.verifyLocalAddress();
}
if (receiver == null) {
MessageSelector msel = null;
if (messageSelector != null) {
msel = new MessageSelector(messageSelector);
msel.compile();
}
if (dynamic) {
expiryPolicy = TerminusExpiryPolicy.LINK_DETACH;
durability = TerminusDurability.NONE;
// sndSettleMode = SenderSettleMode.SETTLED.getValue(); // SETTLED is only possible with temp queues because bulk mode in message proc do not delete from persistent store
queueName = ctx.queueManager.createTemporaryQueue();
receiver = ctx.queueManager.createQueueReceiver(queueName, mySessionHandler.getVersionedConnection().getActiveLogin(), msel);
} else {
if (isQueue) {
expiryPolicy = TerminusExpiryPolicy.LINK_DETACH;
durability = TerminusDurability.CONFIGURATION;
// sndSettleMode = SenderSettleMode.UNSETTLED.getValue();
receiver = ctx.queueManager.createQueueReceiver(getLocalAddress().getValueString(), mySessionHandler.getVersionedConnection().getActiveLogin(), msel);
} else {
if (durability.getValue() == TerminusDurability.CONFIGURATION.getValue() || durability.getValue() == TerminusDurability.UNSETTLED_STATE.getValue()) {
if (!expiryPolicy.getValue().equals(TerminusExpiryPolicy.LINK_DETACH.getValue()))
expiryPolicy = TerminusExpiryPolicy.NEVER;
durability = TerminusDurability.CONFIGURATION;
// sndSettleMode = SenderSettleMode.UNSETTLED.getValue();
queueName = ctx.topicManager.subscribeDurable(name, (TopicImpl) getLocalDestination(), msel, noLocal, mySessionHandler.getVersionedConnection().getActiveLogin());
} else {
expiryPolicy = TerminusExpiryPolicy.LINK_DETACH;
queueName = ctx.queueManager.createTemporaryQueue();
// sndSettleMode = SenderSettleMode.SETTLED.getValue(); // SETTLED is only possible with temp queues because bulk mode in message proc do not delete from persistent store
subscriberId = ctx.topicManager.subscribe((TopicImpl) localDestination, msel, noLocal, queueName, mySessionHandler.getVersionedConnection().getActiveLogin());
}
receiver = ctx.queueManager.createQueueReceiver(queueName, mySessionHandler.getVersionedConnection().getActiveLogin(), null);
}
}
}
if (remoteUnsettled != null) {
final AbstractQueue aq = ctx.queueManager.getQueueForInternalUse(receiver.getQueueName());
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/recovery, abstractQueue=" + aq);
DataByteArrayInputStream dbis = new DataByteArrayInputStream();
for (Iterator iter = remoteUnsettled.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
AMQPBinary deliveryTag = (AMQPBinary) entry.getKey();
DeliveryStateIF deliveryStateIF = null;
try {
deliveryStateIF = DeliveryStateFactory.create((AMQPList) entry.getValue());
} catch (Exception e) {
throw new QueueException("Unable to create delivery tag");
}
final MessageIndex messageIndex = new MessageIndex();
dbis.setBuffer(deliveryTag.getValue());
try {
messageIndex.readContent(dbis);
} catch (IOException e) {
throw new QueueException("Unable to convert delivery tag into a message index");
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/recovery, messageIndex=" + messageIndex + ", deliveryStateIF=" + deliveryStateIF);
if (deliveryStateIF != null) {
deliveryStateIF.accept(new DeliveryStateVisitorAdapter() {
public void visit(Accepted accepted) {
try {
if (aq != null) {
MessageIndex indexEntry = aq.getIndexEntry(messageIndex);
if (indexEntry != null) {
aq.removeMessageByIndex(indexEntry);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/recovery, messageIndex=" + indexEntry + ", removed");
} else {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/recovery, messageIndex=" + messageIndex + ", NOT FOUND!");
}
}
} catch (QueueException e) {
e.printStackTrace();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.amqpSwiftlet.getName(), toString() + "/recovery, messageIndex=" + messageIndex + ", exception=" + e);
}
}
});
}
}
}
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-ce by iitsoftware.
the class AuthRequest method readContent.
public void readContent(DataInput input) throws IOException {
super.readContent(input);
byte[] b = new byte[input.readInt()];
input.readFully(b);
DataByteArrayInputStream dbis = new DataByteArrayInputStream(b);
ObjectInputStream ois = new ObjectInputStream(dbis);
try {
response = (Serializable) ois.readObject();
} catch (ClassNotFoundException e) {
throw new IOException(e.toString());
}
ois.close();
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-ce by iitsoftware.
the class RouteRequest method getRoute.
public Route getRoute(DumpableFactory factory) throws Exception {
DataByteArrayInputStream dbis = new DataByteArrayInputStream(buffer);
route = (Route) factory.createDumpable(dbis.readInt());
if (route == null)
throw new Exception("Unable to create Route!");
route.readContent(dbis);
return route;
}
Aggregations