Search in sources :

Example 6 with ActiveMQExceptionMessage

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

the class ReplicationEndpoint method handlePacket.

@Override
public void handlePacket(final Packet packet) {
    if (logger.isTraceEnabled()) {
        logger.trace("handlePacket::handling " + packet);
    }
    PacketImpl response = new ReplicationResponseMessage();
    final byte type = packet.getType();
    try {
        if (!started) {
            if (logger.isTraceEnabled()) {
                logger.trace("handlePacket::ignoring " + packet);
            }
            return;
        }
        if (type == PacketImpl.REPLICATION_APPEND) {
            handleAppendAddRecord((ReplicationAddMessage) packet);
        } else if (type == PacketImpl.REPLICATION_APPEND_TX) {
            handleAppendAddTXRecord((ReplicationAddTXMessage) packet);
        } else if (type == PacketImpl.REPLICATION_DELETE) {
            handleAppendDelete((ReplicationDeleteMessage) packet);
        } else if (type == PacketImpl.REPLICATION_DELETE_TX) {
            handleAppendDeleteTX((ReplicationDeleteTXMessage) packet);
        } else if (type == PacketImpl.REPLICATION_PREPARE) {
            handlePrepare((ReplicationPrepareMessage) packet);
        } else if (type == PacketImpl.REPLICATION_COMMIT_ROLLBACK) {
            handleCommitRollback((ReplicationCommitMessage) packet);
        } else if (type == PacketImpl.REPLICATION_PAGE_WRITE) {
            handlePageWrite((ReplicationPageWriteMessage) packet);
        } else if (type == PacketImpl.REPLICATION_PAGE_EVENT) {
            handlePageEvent((ReplicationPageEventMessage) packet);
        } else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_BEGIN) {
            handleLargeMessageBegin((ReplicationLargeMessageBeginMessage) packet);
        } else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_WRITE) {
            handleLargeMessageWrite((ReplicationLargeMessageWriteMessage) packet);
        } else if (type == PacketImpl.REPLICATION_LARGE_MESSAGE_END) {
            handleLargeMessageEnd((ReplicationLargeMessageEndMessage) packet);
        } else if (type == PacketImpl.REPLICATION_START_FINISH_SYNC) {
            response = handleStartReplicationSynchronization((ReplicationStartSyncMessage) packet);
        } else if (type == PacketImpl.REPLICATION_SYNC_FILE) {
            handleReplicationSynchronization((ReplicationSyncFileMessage) packet);
        } else if (type == PacketImpl.REPLICATION_SCHEDULED_FAILOVER) {
            handleLiveStopping((ReplicationLiveIsStoppingMessage) packet);
        } else if (type == PacketImpl.BACKUP_REGISTRATION_FAILED) {
            handleFatalError((BackupReplicationStartFailedMessage) packet);
        } else {
            ActiveMQServerLogger.LOGGER.invalidPacketForReplication(packet);
        }
    } catch (ActiveMQException e) {
        logger.warn(e.getMessage(), e);
        ActiveMQServerLogger.LOGGER.errorHandlingReplicationPacket(e, packet);
        response = new ActiveMQExceptionMessage(e);
    } catch (Exception e) {
        logger.warn(e.getMessage(), e);
        ActiveMQServerLogger.LOGGER.errorHandlingReplicationPacket(e, packet);
        response = new ActiveMQExceptionMessage(ActiveMQMessageBundle.BUNDLE.replicationUnhandledError(e));
    }
    if (response != null) {
        if (logger.isTraceEnabled()) {
            logger.trace("Returning " + response);
        }
        channel.send(response);
    } else {
        logger.trace("Response is null, ignoring response");
    }
}
Also used : ReplicationPageEventMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationPageEventMessage) ReplicationAddTXMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationAddTXMessage) ReplicationCommitMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationCommitMessage) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ReplicationLargeMessageWriteMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLargeMessageWriteMessage) PacketImpl(org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl) ActiveMQExceptionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage) ReplicationDeleteTXMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationDeleteTXMessage) ReplicationLiveIsStoppingMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationLiveIsStoppingMessage) ReplicationResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReplicationResponseMessage) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) IOException(java.io.IOException)

Example 7 with ActiveMQExceptionMessage

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

the class ChannelImpl method returnBlocking.

@Override
public void returnBlocking(Throwable cause) {
    lock.lock();
    try {
        response = new ActiveMQExceptionMessage(ActiveMQClientMessageBundle.BUNDLE.unblockingACall(cause));
        sendCondition.signal();
    } finally {
        lock.unlock();
    }
}
Also used : ActiveMQExceptionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage)

Example 8 with ActiveMQExceptionMessage

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

the class ServerSessionPacketHandler method onActiveMQIOErrorExceptionWhileHandlePacket.

private static Packet onActiveMQIOErrorExceptionWhileHandlePacket(ActiveMQIOErrorException e, boolean requiresResponse, Packet response, ServerSession session) {
    session.markTXFailed(e);
    if (requiresResponse) {
        logger.debug("Sending exception to client", e);
        response = new ActiveMQExceptionMessage(e);
    } else {
        ActiveMQServerLogger.LOGGER.caughtException(e);
    }
    return response;
}
Also used : ActiveMQExceptionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage)

Example 9 with ActiveMQExceptionMessage

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

the class ServerSessionPacketHandler method onActiveMQQueueMaxConsumerLimitReachedWhileHandlePacket.

private static Packet onActiveMQQueueMaxConsumerLimitReachedWhileHandlePacket(ActiveMQQueueMaxConsumerLimitReached e, boolean requiresResponse, Packet response) {
    if (requiresResponse) {
        logger.debug("Sending exception to client", e);
        response = new ActiveMQExceptionMessage(e);
    } else {
        ActiveMQServerLogger.LOGGER.caughtException(e);
    }
    return response;
}
Also used : ActiveMQExceptionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage)

Example 10 with ActiveMQExceptionMessage

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

the class ActiveMQPacketHandler method handleCreateSession.

private void handleCreateSession(final CreateSessionMessage request) {
    boolean incompatibleVersion = false;
    Packet response;
    try {
        Version version = server.getVersion();
        if (!version.isCompatible(request.getVersion())) {
            throw ActiveMQMessageBundle.BUNDLE.incompatibleClientServer();
        }
        if (!server.isStarted()) {
            throw ActiveMQMessageBundle.BUNDLE.serverNotStarted();
        }
        if (connection.getChannelVersion() == 0) {
            connection.setChannelVersion(request.getVersion());
        } else if (connection.getChannelVersion() != request.getVersion()) {
            ActiveMQServerLogger.LOGGER.incompatibleVersionAfterConnect(request.getVersion(), connection.getChannelVersion());
        }
        Channel channel = connection.getChannel(request.getSessionChannelID(), request.getWindowSize());
        ActiveMQPrincipal activeMQPrincipal = null;
        if (request.getUsername() == null) {
            activeMQPrincipal = connection.getDefaultActiveMQPrincipal();
        }
        OperationContext sessionOperationContext = server.newOperationContext();
        Map<SimpleString, RoutingType> routingTypeMap = protocolManager.getPrefixes();
        CoreSessionCallback sessionCallback = new CoreSessionCallback(request.getName(), protocolManager, channel, connection);
        ServerSession session = server.createSession(request.getName(), activeMQPrincipal == null ? request.getUsername() : activeMQPrincipal.getUserName(), activeMQPrincipal == null ? request.getPassword() : activeMQPrincipal.getPassword(), request.getMinLargeMessageSize(), connection, request.isAutoCommitSends(), request.isAutoCommitAcks(), request.isPreAcknowledge(), request.isXA(), request.getDefaultAddress(), sessionCallback, true, sessionOperationContext, routingTypeMap);
        ServerProducer serverProducer = new ServerProducerImpl(session.getName(), "CORE", request.getDefaultAddress());
        session.addProducer(serverProducer);
        ServerSessionPacketHandler handler = new ServerSessionPacketHandler(server, protocolManager, session, server.getStorageManager(), channel);
        channel.setHandler(handler);
        sessionCallback.setSessionHandler(handler);
        // TODO - where is this removed?
        protocolManager.addSessionHandler(request.getName(), handler);
        response = new CreateSessionResponseMessage(server.getVersion().getIncrementingVersion());
    } catch (ActiveMQClusterSecurityException | ActiveMQSecurityException e) {
        ActiveMQServerLogger.LOGGER.securityProblemWhileCreatingSession(e.getMessage());
        response = new ActiveMQExceptionMessage(e);
    } catch (ActiveMQException e) {
        if (e.getType() == ActiveMQExceptionType.INCOMPATIBLE_CLIENT_SERVER_VERSIONS) {
            incompatibleVersion = true;
            logger.debug("Sending ActiveMQException after Incompatible client", e);
        } else {
            ActiveMQServerLogger.LOGGER.failedToCreateSession(e);
        }
        response = new ActiveMQExceptionMessage(e);
    } catch (Exception e) {
        ActiveMQServerLogger.LOGGER.failedToCreateSession(e);
        response = new ActiveMQExceptionMessage(new ActiveMQInternalErrorException());
    }
    // are not compatible
    if (incompatibleVersion) {
        channel1.sendAndFlush(response);
    } else {
        channel1.send(response);
    }
}
Also used : OperationContext(org.apache.activemq.artemis.core.persistence.OperationContext) ServerSessionPacketHandler(org.apache.activemq.artemis.core.protocol.core.ServerSessionPacketHandler) Packet(org.apache.activemq.artemis.core.protocol.core.Packet) ServerSession(org.apache.activemq.artemis.core.server.ServerSession) ActiveMQPrincipal(org.apache.activemq.artemis.core.security.ActiveMQPrincipal) CreateSessionResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSessionResponseMessage) Channel(org.apache.activemq.artemis.core.protocol.core.Channel) ActiveMQExceptionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage) ActiveMQClusterSecurityException(org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException) ServerProducer(org.apache.activemq.artemis.core.server.ServerProducer) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQClusterSecurityException(org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException) ActiveMQSecurityException(org.apache.activemq.artemis.api.core.ActiveMQSecurityException) ServerProducerImpl(org.apache.activemq.artemis.core.server.impl.ServerProducerImpl) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) Version(org.apache.activemq.artemis.core.version.Version) ActiveMQSecurityException(org.apache.activemq.artemis.api.core.ActiveMQSecurityException) RoutingType(org.apache.activemq.artemis.api.core.RoutingType)

Aggregations

ActiveMQExceptionMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage)10 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)6 ActiveMQInternalErrorException (org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException)3 ActiveMQClusterSecurityException (org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException)2 ActiveMQSecurityException (org.apache.activemq.artemis.api.core.ActiveMQSecurityException)2 Packet (org.apache.activemq.artemis.core.protocol.core.Packet)2 ServerSessionPacketHandler (org.apache.activemq.artemis.core.protocol.core.ServerSessionPacketHandler)2 IOException (java.io.IOException)1 List (java.util.List)1 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)1 ActiveMQIOErrorException (org.apache.activemq.artemis.api.core.ActiveMQIOErrorException)1 ActiveMQInterruptedException (org.apache.activemq.artemis.api.core.ActiveMQInterruptedException)1 ActiveMQQueueMaxConsumerLimitReached (org.apache.activemq.artemis.api.core.ActiveMQQueueMaxConsumerLimitReached)1 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ActiveMQXAException (org.apache.activemq.artemis.core.exception.ActiveMQXAException)1 OperationContext (org.apache.activemq.artemis.core.persistence.OperationContext)1 Channel (org.apache.activemq.artemis.core.protocol.core.Channel)1 PacketImpl (org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl)1 CreateAddressMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateAddressMessage)1