use of com.swiftmq.jms.smqp.v610.AsyncMessageDeliveryRequest in project swiftmq-ce by iitsoftware.
the class AsyncMessageProcessor method run.
public void run() {
if (!isValid())
return;
ctx.incMsgsReceived(numberMessages);
deliveryCount += numberMessages;
boolean restart = deliveryCount >= consumerCacheSize;
MessageEntry[] buffer = getBulkBuffer();
if (isAutoCommit()) {
AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), buffer, numberMessages, session.dispatchId);
request.setRequiresRestart(restart);
request.setRecoveryEpoche(recoveryEpoche);
ctx.connectionOutboundQueue.enqueue(request);
} else {
for (int i = 0; i < numberMessages; i++) {
AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), buffer[i], session.dispatchId);
request.setRequiresRestart(i == numberMessages - 1 && restart);
request.setRecoveryEpoche(recoveryEpoche);
DeliveryItem item = new DeliveryItem();
item.messageEntry = buffer[i];
item.consumer = consumer;
item.request = request;
ctx.sessionQueue.enqueue(item);
}
}
try {
if (!restart) {
QueuePullTransaction t = consumer.getReadTransaction();
if (t != null && !t.isClosed()) {
try {
t.registerMessageProcessor(this);
} catch (QueueTransactionClosedException e) {
}
}
} else
deliveryCount = 0;
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations