Search in sources :

Example 1 with SessionConsumerFlowCreditMessage

use of org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionConsumerFlowCreditMessage in project activemq-artemis by apache.

the class ServerPacketDecoder method decodeSessionConsumerFlowCreditMessage.

private static SessionConsumerFlowCreditMessage decodeSessionConsumerFlowCreditMessage(final ActiveMQBuffer in, CoreRemotingConnection connection) {
    final SessionConsumerFlowCreditMessage sessionConsumerFlowCreditMessage = new SessionConsumerFlowCreditMessage();
    sessionConsumerFlowCreditMessage.decode(in);
    return sessionConsumerFlowCreditMessage;
}
Also used : SessionConsumerFlowCreditMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionConsumerFlowCreditMessage)

Example 2 with SessionConsumerFlowCreditMessage

use of org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionConsumerFlowCreditMessage in project activemq-artemis by apache.

the class ActiveMQSessionContext method recreateConsumerOnServer.

@Override
public void recreateConsumerOnServer(ClientConsumerInternal consumerInternal, long consumerId, boolean isSessionStarted) throws ActiveMQException {
    ClientSession.QueueQuery queueInfo = consumerInternal.getQueueInfo();
    // This allows e.g. JMS non durable subs and temporary queues to continue to be used after failover
    if (!queueInfo.isDurable()) {
        CreateQueueMessage_V2 createQueueRequest = new CreateQueueMessage_V2(queueInfo.getAddress(), queueInfo.getName(), queueInfo.getRoutingType(), queueInfo.getFilterString(), false, queueInfo.isTemporary(), queueInfo.getMaxConsumers(), queueInfo.isPurgeOnNoConsumers(), queueInfo.isAutoCreated(), false, queueInfo.isExclusive(), queueInfo.isLastValue());
        sendPacketWithoutLock(sessionChannel, createQueueRequest);
    }
    SessionCreateConsumerMessage createConsumerRequest = new SessionCreateConsumerMessage(getConsumerID(consumerInternal), consumerInternal.getQueueName(), consumerInternal.getFilterString(), consumerInternal.isBrowseOnly(), false);
    sendPacketWithoutLock(sessionChannel, createConsumerRequest);
    int clientWindowSize = consumerInternal.getClientWindowSize();
    if (clientWindowSize != 0) {
        SessionConsumerFlowCreditMessage packet = new SessionConsumerFlowCreditMessage(getConsumerID(consumerInternal), clientWindowSize);
        sendPacketWithoutLock(sessionChannel, packet);
    } else {
        // https://jira.jboss.org/browse/HORNETQ-522
        SessionConsumerFlowCreditMessage packet = new SessionConsumerFlowCreditMessage(getConsumerID(consumerInternal), 1);
        sendPacketWithoutLock(sessionChannel, packet);
    }
    // (in which case the consumer will wake up, thus avoid the infinite waiting).
    if (isSessionStarted && consumerInternal.getForceDeliveryCount() > 0) {
        SessionForceConsumerDelivery forceDel = new SessionForceConsumerDelivery(consumerId, consumerInternal.getForceDeliveryCount() - 1);
        sendPacketWithoutLock(sessionChannel, forceDel);
    }
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) SessionForceConsumerDelivery(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionForceConsumerDelivery) CreateQueueMessage_V2(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V2) SessionConsumerFlowCreditMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionConsumerFlowCreditMessage) SessionCreateConsumerMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionCreateConsumerMessage)

Example 3 with SessionConsumerFlowCreditMessage

use of org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionConsumerFlowCreditMessage in project activemq-artemis by apache.

the class ServerSessionPacketHandler method onSessionConsumerFlowCredit.

private void onSessionConsumerFlowCredit(Packet packet) {
    this.storageManager.setContext(session.getSessionContext());
    try {
        Packet response = null;
        boolean requiresResponse = false;
        try {
            SessionConsumerFlowCreditMessage message = (SessionConsumerFlowCreditMessage) packet;
            session.receiveConsumerCredits(message.getConsumerID(), message.getCredits());
        } catch (ActiveMQIOErrorException e) {
            response = onActiveMQIOErrorExceptionWhileHandlePacket(e, requiresResponse, response, this.session);
        } catch (ActiveMQXAException e) {
            response = onActiveMQXAExceptionWhileHandlePacket(e, requiresResponse, response);
        } catch (ActiveMQQueueMaxConsumerLimitReached e) {
            response = onActiveMQQueueMaxConsumerLimitReachedWhileHandlePacket(e, requiresResponse, response);
        } catch (ActiveMQException e) {
            response = onActiveMQExceptionWhileHandlePacket(e, requiresResponse, response);
        } catch (Throwable t) {
            response = onCatchThrowableWhileHandlePacket(t, requiresResponse, response, this.session);
        }
        sendResponse(packet, response, false, false);
    } finally {
        this.storageManager.clearContext();
    }
}
Also used : ActiveMQIOErrorException(org.apache.activemq.artemis.api.core.ActiveMQIOErrorException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) SessionConsumerFlowCreditMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionConsumerFlowCreditMessage) ActiveMQXAException(org.apache.activemq.artemis.core.exception.ActiveMQXAException) ActiveMQQueueMaxConsumerLimitReached(org.apache.activemq.artemis.api.core.ActiveMQQueueMaxConsumerLimitReached)

Aggregations

SessionConsumerFlowCreditMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionConsumerFlowCreditMessage)3 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 ActiveMQIOErrorException (org.apache.activemq.artemis.api.core.ActiveMQIOErrorException)1 ActiveMQQueueMaxConsumerLimitReached (org.apache.activemq.artemis.api.core.ActiveMQQueueMaxConsumerLimitReached)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1 ActiveMQXAException (org.apache.activemq.artemis.core.exception.ActiveMQXAException)1 CreateQueueMessage_V2 (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V2)1 SessionCreateConsumerMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionCreateConsumerMessage)1 SessionForceConsumerDelivery (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionForceConsumerDelivery)1