Search in sources :

Example 11 with AsyncMessageDeliveryRequest

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();
    }
}
Also used : AsyncMessageDeliveryRequest(com.swiftmq.jms.smqp.v500.AsyncMessageDeliveryRequest)

Aggregations

MessageEntry (com.swiftmq.swiftlet.queue.MessageEntry)4 JMSException (javax.jms.JMSException)4 AsyncMessageDeliveryRequest (com.swiftmq.jms.smqp.v600.AsyncMessageDeliveryRequest)2 AsyncMessageDeliveryRequest (com.swiftmq.jms.smqp.v610.AsyncMessageDeliveryRequest)2 AsyncMessageDeliveryRequest (com.swiftmq.jms.smqp.v630.AsyncMessageDeliveryRequest)2 AsyncMessageDeliveryRequest (com.swiftmq.jms.smqp.v750.AsyncMessageDeliveryRequest)2 AsyncMessageDeliveryRequest (com.swiftmq.jms.smqp.v400.AsyncMessageDeliveryRequest)1 AsyncMessageDeliveryRequest (com.swiftmq.jms.smqp.v500.AsyncMessageDeliveryRequest)1 AsyncMessageDeliveryRequest (com.swiftmq.jms.smqp.v510.AsyncMessageDeliveryRequest)1