use of com.swiftmq.swiftlet.queue.QueuePullTransaction in project swiftmq-ce by iitsoftware.
the class Session method visitDeliveryItem.
public void visitDeliveryItem(DeliveryItem item) {
if (closed || recoveryInProgress || item.request.getRecoveryEpoche() != recoveryEpoche)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitDeliveryItem, item= " + item);
QueuePullTransaction rt = (QueuePullTransaction) item.consumer.getReadTransaction();
QueuePullTransaction t = (QueuePullTransaction) item.consumer.getTransaction();
try {
item.request.setMessageEntry(item.messageEntry);
ctx.connectionOutboundQueue.enqueue(item.request);
} catch (Exception e) {
if (!closed) {
e.printStackTrace();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/handleDelivery, exception= " + e);
}
}
}
use of com.swiftmq.swiftlet.queue.QueuePullTransaction in project swiftmq-ce by iitsoftware.
the class Session method visitStartConsumerRequest.
public void visitStartConsumerRequest(StartConsumerRequest req) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitStartConsumerRequest");
int qcId = req.getQueueConsumerId();
Consumer consumer = (Consumer) consumerList.get(qcId);
if (consumer == null)
return;
int clientDispatchId = req.getClientDispatchId();
int clientListenerId = req.getClientListenerId();
try {
MessageProcessor mp = consumer.getMessageProcessor();
if (mp == null) {
mp = new AsyncMessageProcessor(this, ctx, consumer, req.getConsumerCacheSize(), recoveryEpoche);
consumer.setMessageListener(clientDispatchId, clientListenerId, mp);
}
QueuePullTransaction t = consumer.getReadTransaction();
if (t != null && !t.isClosed())
t.registerMessageProcessor(mp);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.swiftmq.swiftlet.queue.QueuePullTransaction in project swiftmq-ce by iitsoftware.
the class Session method visitDeliveryItem.
public void visitDeliveryItem(DeliveryItem item) {
if (closed || recoveryInProgress || item.request.getRecoveryEpoche() != recoveryEpoche)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitDeliveryItem, item= " + item);
QueuePullTransaction rt = (QueuePullTransaction) item.consumer.getReadTransaction();
QueuePullTransaction t = (QueuePullTransaction) item.consumer.getTransaction();
try {
item.request.setMessageEntry(item.messageEntry);
ctx.connectionOutboundQueue.enqueue(item.request);
} catch (Exception e) {
if (!closed) {
e.printStackTrace();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/handleDelivery, exception= " + e);
}
}
}
use of com.swiftmq.swiftlet.queue.QueuePullTransaction in project swiftmq-ce by iitsoftware.
the class NontransactedSession method visit.
public void visit(AcknowledgeMessageRequest req) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitAcknowledgeMessageRequest");
AcknowledgeMessageReply reply = null;
if (req.isReplyRequired()) {
reply = (AcknowledgeMessageReply) req.createReply();
reply.setOk(true);
}
if (ctx.ackMode == javax.jms.Session.CLIENT_ACKNOWLEDGE) {
Map ackConsumers = new HashMap();
for (Iterator iter = deliveredList.iterator(); iter.hasNext(); ) {
MessageDeliveredRequest request = (MessageDeliveredRequest) iter.next();
Consumer consumer = (Consumer) consumerList.get(request.getQueueConsumerId());
MessageIndex actIndex = request.getMessageIndex();
QueuePullTransaction t = consumer.getTransaction();
ConsumerAckEntry ackEntry = (ConsumerAckEntry) ackConsumers.get(consumer);
if (ackEntry == null) {
ackEntry = new ConsumerAckEntry(t);
ackConsumers.put(consumer, ackEntry);
}
ackEntry.ackList.add(actIndex);
}
deliveredList.clear();
boolean callbackRegistered = false;
MultiAckJoin join = new MultiAckJoin(reply);
for (Iterator iter = ackConsumers.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
Consumer consumer = (Consumer) entry.getKey();
ConsumerAckEntry ackEntry = (ConsumerAckEntry) entry.getValue();
try {
join.incNumberCallbacks();
ackEntry.transaction.acknowledgeMessages(ackEntry.ackList, new MultiAckCallback(join, consumer, ackEntry.ackList.size()));
callbackRegistered = true;
} catch (QueueTransactionClosedException e) {
}
}
join.setBlocked(false);
if (!callbackRegistered && reply != null)
reply.send();
} else {
MessageIndex ackIndex = req.getMessageIndex();
Consumer consumer = (Consumer) consumerList.get(req.getQueueConsumerId());
ackSingleMessage(reply, ackIndex, consumer);
}
}
use of com.swiftmq.swiftlet.queue.QueuePullTransaction in project swiftmq-ce by iitsoftware.
the class NontransactedSession method visit.
public void visit(AcknowledgeMessageRequest req) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitAcknowledgeMessageRequest");
AcknowledgeMessageReply reply = null;
if (req.isReplyRequired()) {
reply = (AcknowledgeMessageReply) req.createReply();
reply.setOk(true);
}
try {
MessageIndex ackIndex = req.getMessageIndex();
if (ctx.ackMode == javax.jms.Session.CLIENT_ACKNOWLEDGE) {
boolean found = false;
Iterator iter = deliveredList.iterator();
while (iter.hasNext()) {
MessageDeliveredRequest request = (MessageDeliveredRequest) iter.next();
Consumer consumer = (Consumer) consumerList.get(request.getQueueConsumerId());
MessageIndex actIndex = request.getMessageIndex();
QueuePullTransaction t = consumer.getTransaction();
try {
if (!t.isClosed())
t.acknowledgeMessage(actIndex);
} catch (Exception e) {
// temp queue might be deleted in the mean time
}
iter.remove();
}
} else {
Consumer consumer = (Consumer) consumerList.get(req.getQueueConsumerId());
QueuePullTransaction t = consumer.getReadTransaction();
try {
if (!t.isClosed())
t.acknowledgeMessage(ackIndex);
} catch (Exception e) {
// temp queue might be deleted in the mean time
}
}
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitAcknowledgeMessageRequest, exception: " + e);
if (reply != null) {
reply.setOk(false);
reply.setException(e);
}
}
if (reply != null)
reply.send();
}
Aggregations