Search in sources :

Example 1 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v630.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 - lowWaterMark;
    MessageEntry[] buffer = getBulkBuffer();
    if (isAutoCommit()) {
        MessageEntry[] bulk = new MessageEntry[numberMessages];
        System.arraycopy(buffer, 0, bulk, 0, numberMessages);
        AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), null, bulk, session.dispatchId, restart, recoveryEpoche);
        ctx.connectionOutboundQueue.enqueue(request);
    } else {
        for (int i = 0; i < numberMessages; i++) {
            AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), buffer[i], null, session.dispatchId, i == numberMessages - 1 && restart, recoveryEpoche);
            DeliveryItem item = new DeliveryItem();
            item.messageEntry = buffer[i];
            item.consumer = consumer;
            item.request = request;
            ctx.sessionQueue.enqueue(item);
        }
    }
    if (!restart)
        ctx.sessionQueue.enqueue(registerRequest);
    else
        deliveryCount = 0;
}
Also used : AsyncMessageDeliveryRequest(com.swiftmq.jms.smqp.v610.AsyncMessageDeliveryRequest)

Example 2 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v630.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()) {
        MessageEntry[] bulk = new MessageEntry[numberMessages];
        System.arraycopy(buffer, 0, bulk, 0, numberMessages);
        AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), null, bulk, session.dispatchId, restart, recoveryEpoche);
        ctx.connectionOutboundQueue.enqueue(request);
    } else {
        for (int i = 0; i < numberMessages; i++) {
            AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), buffer[i], null, session.dispatchId, i == numberMessages - 1 && restart, recoveryEpoche);
            DeliveryItem item = new DeliveryItem();
            item.messageEntry = buffer[i];
            item.consumer = consumer;
            item.request = request;
            ctx.sessionQueue.enqueue(item);
        }
    }
    if (!restart)
        ctx.sessionQueue.enqueue(registerRequest);
    else
        deliveryCount = 0;
}
Also used : AsyncMessageDeliveryRequest(com.swiftmq.jms.smqp.v600.AsyncMessageDeliveryRequest)

Example 3 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v630.AsyncMessageDeliveryRequest in project swiftmq-client by iitsoftware.

the class ConnectionConsumerImpl method processRequest.

public void processRequest(AsyncMessageDeliveryRequest request, boolean hasNext) {
    if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
        if (MessageTracker.enabled) {
            MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return");
        }
        return;
    }
    if (request.getConnectionId() != myConnection.getConnectionId()) {
        if (MessageTracker.enabled) {
            MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, invalid connectionId (" + request.getConnectionId() + " vs " + myConnection.getConnectionId() + ")");
        }
        return;
    }
    try {
        if (currentServerSession == null) {
            currentServerSession = serverSessionPool.getServerSession();
            if (currentServerSession.getSession() instanceof XASessionImpl)
                currentSession = ((XASessionImpl) currentServerSession.getSession()).session;
            else
                currentSession = (SessionImpl) currentServerSession.getSession();
            nCurrent = 0;
            if (!currentSession.isShadowConsumerCreated())
                currentSession.createShadowConsumer(getQueueName());
            currentSession.setConnectionConsumer(this);
            if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
                if (MessageTracker.enabled) {
                    MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return (2)");
                }
                return;
            }
        }
        if (MessageTracker.enabled) {
            MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, " + request.getConnectionId() + " / " + myConnection.getConnectionId());
        }
        MessageEntry me = request.getMessageEntry();
        checkInProgress(me.getMessage());
        if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
            if (MessageTracker.enabled) {
                MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return (3)");
            }
            return;
        }
        me.setConnectionId(request.getConnectionId());
        currentSession.addMessageChunk(me);
        nCurrent++;
        if (nCurrent == maxMessages || !hasNext) {
            currentServerSession.start();
            currentServerSession = null;
            currentSession = null;
            nCurrent = 0;
        }
    } catch (Exception e) {
        e.printStackTrace();
    // TODO: Handle it some way like InvalidateConsumerRequest!!!
    }
    if (request.isRequiresRestart())
        fillCache();
}
Also used : MessageEntry(com.swiftmq.swiftlet.queue.MessageEntry) AsyncMessageDeliveryRequest(com.swiftmq.jms.smqp.v630.AsyncMessageDeliveryRequest) JMSException(javax.jms.JMSException)

Example 4 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v630.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 - lowWaterMark;
    MessageEntry[] buffer = getBulkBuffer();
    if (isAutoCommit()) {
        MessageEntry[] bulk = new MessageEntry[numberMessages];
        System.arraycopy(buffer, 0, bulk, 0, numberMessages);
        AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), null, bulk, session.dispatchId, restart, recoveryEpoche);
        ctx.connectionOutboundQueue.enqueue(request);
    } else {
        for (int i = 0; i < numberMessages; i++) {
            AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), buffer[i], null, session.dispatchId, i == numberMessages - 1 && restart, recoveryEpoche);
            DeliveryItem item = new DeliveryItem();
            item.messageEntry = buffer[i];
            item.consumer = consumer;
            item.request = request;
            ctx.sessionQueue.enqueue(item);
        }
    }
    if (!restart)
        ctx.sessionQueue.enqueue(registerRequest);
    else
        deliveryCount = 0;
}
Also used : AsyncMessageDeliveryRequest(com.swiftmq.jms.smqp.v630.AsyncMessageDeliveryRequest)

Example 5 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v630.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()) {
        MessageEntry[] bulk = new MessageEntry[numberMessages];
        System.arraycopy(buffer, 0, bulk, 0, numberMessages);
        AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), null, bulk, session.dispatchId, restart, recoveryEpoche);
        ctx.connectionOutboundQueue.enqueue(request);
    } else {
        for (int i = 0; i < numberMessages; i++) {
            AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), buffer[i], null, session.dispatchId, i == numberMessages - 1 && restart, 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.v510.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