use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-client by iitsoftware.
the class PropertyChangedRequest method readContent.
public void readContent(DataInput in) throws IOException {
super.readContent(in);
byte set = in.readByte();
if (set == 1) {
context = new String[in.readInt()];
for (int i = 0; i < context.length; i++) {
context[i] = in.readUTF();
}
}
name = in.readUTF();
set = in.readByte();
if (set == 1) {
byte[] b = new byte[in.readInt()];
in.readFully(b);
DataByteArrayInputStream dbis = new DataByteArrayInputStream(b);
ObjectInputStream ois = new ObjectInputStream(dbis);
try {
value = ois.readObject();
} catch (ClassNotFoundException e) {
throw new IOException(e.toString());
}
ois.close();
}
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-client by iitsoftware.
the class PropertyChangedRequest method readContent.
public void readContent(DataInput in) throws IOException {
super.readContent(in);
byte set = in.readByte();
if (set == 1) {
context = new String[in.readInt()];
for (int i = 0; i < context.length; i++) {
context[i] = in.readUTF();
}
}
name = in.readUTF();
set = in.readByte();
if (set == 1) {
byte[] b = new byte[in.readInt()];
in.readFully(b);
DataByteArrayInputStream dbis = new DataByteArrayInputStream(b);
ObjectInputStream ois = new ObjectInputStream(dbis);
try {
value = ois.readObject();
} catch (ClassNotFoundException e) {
throw new IOException(e.toString());
}
ois.close();
}
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-client by iitsoftware.
the class Coder method readArray.
public static List readArray(DataInput in) throws IOException {
List list = new ArrayList();
DataByteArrayInputStream dbis = new DataByteArrayInputStream(readLongString(in));
while (dbis.available() > 0) list.add(readFieldValue(in));
return list;
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-ce by iitsoftware.
the class TransactedUnifiedSession method visit.
public void visit(CommitRequest req) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitCommitRequest");
CommitReply reply = (CommitReply) req.createReply();
reply.setOk(true);
try {
// first: produce all messages
List ml = req.getMessages();
ctx.incMsgsSent(ml.size());
req.setMessages(null);
long fcDelay = 0;
RingBuffer tempProducers = null;
for (int i = 0; i < ml.size(); i++) {
DataByteArrayInputStream dis = new DataByteArrayInputStream((byte[]) ml.get(i));
int producerId = dis.readInt();
int type = dis.readInt();
MessageImpl msg = MessageImpl.createInstance(type);
msg.readContent(dis);
dis.close();
long ttl = msg.getJMSExpiration();
if (ttl > 0)
msg.setJMSExpiration(System.currentTimeMillis() + ttl);
Producer producer = null;
if (producerId == -1) {
DestinationImpl destImpl = (DestinationImpl) msg.getJMSDestination();
switch(destImpl.getType()) {
case DestinationFactory.TYPE_QUEUE:
case DestinationFactory.TYPE_TEMPQUEUE:
String queueName = ((QueueImpl) destImpl).getQueueName();
if (!ctx.queueManager.isQueueRunning(queueName))
throw new InvalidDestinationException("Invalid destination: " + queueName);
producer = new QueueProducer(ctx, queueName);
break;
case DestinationFactory.TYPE_TOPIC:
case DestinationFactory.TYPE_TEMPTOPIC:
TopicImpl topic = (TopicImpl) msg.getJMSDestination();
if (topic.getType() != DestinationFactory.TYPE_TEMPTOPIC)
ctx.authSwiftlet.verifyTopicSenderSubscription(topic.getTopicName(), ctx.activeLogin.getLoginId());
producer = new TopicProducer(ctx, topic);
break;
}
if (tempProducers == null)
tempProducers = new RingBuffer(8);
tempProducers.add(producer);
transactionManager.addTransactionFactory(producer);
} else {
producer = (Producer) producerList.get(producerId);
}
QueuePushTransaction transaction = producer.getTransaction();
transaction.putMessage(msg);
fcDelay = Math.max(fcDelay, transaction.getFlowControlDelay());
if (producerId == -1)
producer.markForClose();
}
// Next: do the commit
transactionManager.commit();
if (tempProducers != null) {
int size = tempProducers.getSize();
for (int i = 0; i < size; i++) {
((Producer) tempProducers.remove()).close();
}
}
reply.setDelay(fcDelay);
purgeMarkedProducers();
purgeMarkedConsumers();
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/commit produced messages failed: " + e.getMessage());
reply.setOk(false);
reply.setException(e);
}
reply.send();
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-ce by iitsoftware.
the class TransactedTopicSession method visit.
public void visit(CommitRequest req) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitCommitRequest");
CommitReply reply = (CommitReply) req.createReply();
reply.setOk(true);
try {
// first: produce all messages
List ml = req.getMessages();
ctx.incMsgsSent(ml.size());
req.setMessages(null);
long fcDelay = 0;
RingBuffer tempProducers = null;
for (int i = 0; i < ml.size(); i++) {
DataByteArrayInputStream dis = new DataByteArrayInputStream((byte[]) ml.get(i));
int producerId = dis.readInt();
int type = dis.readInt();
MessageImpl msg = MessageImpl.createInstance(type);
msg.readContent(dis);
dis.close();
long ttl = msg.getJMSExpiration();
if (ttl > 0)
msg.setJMSExpiration(System.currentTimeMillis() + ttl);
Producer producer = null;
if (producerId == -1) {
TopicImpl topic = (TopicImpl) msg.getJMSDestination();
if (topic.getType() != DestinationFactory.TYPE_TEMPTOPIC)
ctx.authSwiftlet.verifyTopicSenderSubscription(topic.getTopicName(), ctx.activeLogin.getLoginId());
producer = new TopicProducer(ctx, topic);
if (tempProducers == null)
tempProducers = new RingBuffer(8);
tempProducers.add(producer);
transactionManager.addTransactionFactory(producer);
} else {
producer = (Producer) producerList.get(producerId);
}
QueuePushTransaction transaction = producer.getTransaction();
transaction.putMessage(msg);
fcDelay = Math.max(fcDelay, transaction.getFlowControlDelay());
if (producerId == -1)
producer.markForClose();
}
// Next: do the commit
transactionManager.commit();
if (tempProducers != null) {
int size = tempProducers.getSize();
for (int i = 0; i < size; i++) {
((Producer) tempProducers.remove()).close();
}
}
reply.setDelay(fcDelay);
purgeMarkedProducers();
purgeMarkedConsumers();
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/commit produced messages failed: " + e.getMessage());
reply.setOk(false);
reply.setException(e);
}
reply.send();
}
Aggregations