Search in sources :

Example 6 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v750.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();
        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.v600.AsyncMessageDeliveryRequest) JMSException(javax.jms.JMSException)

Example 7 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v750.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 = false;
    if (maxBulkSize != -1) {
        maxBulkSize -= getCurrentBulkSize();
        restart = deliveryCount >= consumerCacheSize - lowWaterMark || maxBulkSize <= 0;
    } else
        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;
        maxBulkSize = -1;
        started = false;
    }
}
Also used : AsyncMessageDeliveryRequest(com.swiftmq.jms.smqp.v750.AsyncMessageDeliveryRequest)

Example 8 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v750.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(), me.getMessage().getJMSMessageID());
        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.v750.AsyncMessageDeliveryRequest) JMSException(javax.jms.JMSException)

Example 9 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v750.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.v610.AsyncMessageDeliveryRequest) JMSException(javax.jms.JMSException)

Example 10 with AsyncMessageDeliveryRequest

use of com.swiftmq.jms.smqp.v750.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.v400.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