use of com.swiftmq.swiftlet.queue.MessageProcessor in project swiftmq-ce by iitsoftware.
the class Session method visit.
public void visit(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.MessageProcessor in project swiftmq-ce by iitsoftware.
the class NontransactedSession method visit.
public void visit(RecoverSessionRequest req) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitRecoverSessionRequest");
recoveryInProgress = true;
RecoverSessionReply reply = (RecoverSessionReply) req.createReply();
reply.setRecoveryEpoche(req.getRecoveryEpoche());
reply.setOk(true);
for (int i = 0; i < consumerList.size(); i++) {
Consumer consumer = (Consumer) consumerList.get(i);
if (consumer != null) {
try {
MessageProcessor mp = consumer.getMessageProcessor();
if (mp != null) {
mp.stop();
consumer.getReadTransaction().unregisterMessageProcessor(mp);
}
consumer.getReadTransaction().rollback();
consumer.getTransaction().rollback();
} catch (Exception e) {
reply.setOk(false);
reply.setException(e);
break;
}
}
}
deliveredList.clear();
GenericRequest gr = new GenericRequest(-1, false, reply);
ctx.sessionQueue.enqueue(gr);
}
use of com.swiftmq.swiftlet.queue.MessageProcessor in project swiftmq-ce by iitsoftware.
the class NontransactedSession method visitRecoverSessionRequest.
public void visitRecoverSessionRequest(RecoverSessionRequest req) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitRecoverSessionRequest");
recoveryInProgress = true;
RecoverSessionReply reply = (RecoverSessionReply) req.createReply();
reply.setOk(true);
for (int i = 0; i < consumerList.size(); i++) {
Consumer consumer = (Consumer) consumerList.get(i);
if (consumer != null) {
try {
MessageProcessor mp = consumer.getMessageProcessor();
if (mp != null) {
mp.stop();
}
consumer.getReadTransaction().rollback();
consumer.getTransaction().rollback();
} catch (Exception e) {
reply.setOk(false);
reply.setException(new javax.jms.JMSException(e.toString()));
break;
}
}
}
deliveredList.clear();
GenericRequest gr = new GenericRequest(-1, false, reply);
ctx.sessionQueue.enqueue(gr);
}
use of com.swiftmq.swiftlet.queue.MessageProcessor 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.MessageProcessor in project swiftmq-ce by iitsoftware.
the class TransactedSession method visitRollbackRequest.
public void visitRollbackRequest(RollbackRequest req) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace("sys$jms", ctx.tracePrefix + "/visitRollbackRequest");
recoveryInProgress = true;
RollbackReply reply = (RollbackReply) req.createReply();
reply.setOk(true);
for (int i = 0; i < consumerList.size(); i++) {
Consumer consumer = (Consumer) consumerList.get(i);
if (consumer != null) {
try {
MessageProcessor mp = consumer.getMessageProcessor();
if (mp != null) {
mp.stop();
consumer.getReadTransaction().unregisterMessageProcessor(mp);
}
consumer.getReadTransaction().rollback();
} catch (Exception e) {
reply.setOk(false);
reply.setException(new javax.jms.JMSException(e.toString()));
break;
}
}
}
GenericRequest gr = new GenericRequest(-1, false, reply);
ctx.sessionQueue.enqueue(gr);
}
Aggregations