Search in sources :

Example 1 with ActiveMQInternalErrorException

use of org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException in project activemq-artemis by apache.

the class ServerSessionPacketHandler method onCatchThrowableWhileHandlePacket.

private static Packet onCatchThrowableWhileHandlePacket(Throwable t, boolean requiresResponse, Packet response, ServerSession session) {
    session.markTXFailed(t);
    if (requiresResponse) {
        ActiveMQServerLogger.LOGGER.sendingUnexpectedExceptionToClient(t);
        ActiveMQException activeMQInternalErrorException = new ActiveMQInternalErrorException();
        activeMQInternalErrorException.initCause(t);
        response = new ActiveMQExceptionMessage(activeMQInternalErrorException);
    } else {
        ActiveMQServerLogger.LOGGER.caughtException(t);
    }
    return response;
}
Also used : ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQExceptionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException)

Example 2 with ActiveMQInternalErrorException

use of org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException in project activemq-artemis by apache.

the class JournalStorageManager method deleteLargeMessageFile.

// This should be accessed from this package only
void deleteLargeMessageFile(final LargeServerMessage largeServerMessage) throws ActiveMQException {
    if (largeServerMessage.getPendingRecordID() < 0) {
        try {
            // The delete file happens asynchronously
            // And the client won't be waiting for the actual file to be deleted.
            // We set a temporary record (short lived) on the journal
            // to avoid a situation where the server is restarted and pending large message stays on forever
            largeServerMessage.setPendingRecordID(storePendingLargeMessage(largeServerMessage.getMessageID(), largeServerMessage.getPendingRecordID()));
        } catch (Exception e) {
            throw new ActiveMQInternalErrorException(e.getMessage(), e);
        }
    }
    final SequentialFile file = largeServerMessage.getFile();
    if (file == null) {
        return;
    }
    if (largeServerMessage.isDurable() && isReplicated()) {
        readLock();
        try {
            if (isReplicated() && replicator.isSynchronizing()) {
                synchronized (largeMessagesToDelete) {
                    largeMessagesToDelete.add(Long.valueOf(largeServerMessage.getMessageID()));
                    confirmLargeMessage(largeServerMessage);
                }
                return;
            }
        } finally {
            readUnLock();
        }
    }
    Runnable deleteAction = new Runnable() {

        @Override
        public void run() {
            try {
                readLock();
                try {
                    if (replicator != null) {
                        replicator.largeMessageDelete(largeServerMessage.getMessageID(), JournalStorageManager.this);
                    }
                    file.delete();
                    // The confirm could only be done after the actual delete is done
                    confirmLargeMessage(largeServerMessage);
                } finally {
                    readUnLock();
                }
            } catch (Exception e) {
                ActiveMQServerLogger.LOGGER.journalErrorDeletingMessage(e, largeServerMessage.getMessageID());
            }
        }
    };
    if (executor == null) {
        deleteAction.run();
    } else {
        executor.execute(deleteAction);
    }
}
Also used : SequentialFile(org.apache.activemq.artemis.core.io.SequentialFile) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQIllegalStateException(org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException)

Example 3 with ActiveMQInternalErrorException

use of org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException in project activemq-artemis by apache.

the class LargeServerMessageImpl method validateFile.

// Private -------------------------------------------------------
public synchronized void validateFile() throws ActiveMQException {
    try {
        if (file == null) {
            if (messageID <= 0) {
                throw new RuntimeException("MessageID not set on LargeMessage");
            }
            file = createFile();
            openFile();
            bodySize = file.size();
        }
    } catch (Exception e) {
        // TODO: There is an IO_ERROR on trunk now, this should be used here instead
        throw new ActiveMQInternalErrorException(e.getMessage(), e);
    }
}
Also used : ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException) ActiveMQIOErrorException(org.apache.activemq.artemis.api.core.ActiveMQIOErrorException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException)

Example 4 with ActiveMQInternalErrorException

use of org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException in project activemq-artemis by apache.

the class ActiveMQPacketHandler method handleReattachSession.

private void handleReattachSession(final ReattachSessionMessage request) {
    Packet response = null;
    try {
        if (!server.isStarted()) {
            response = new ReattachSessionResponseMessage(-1, false);
        }
        logger.debug("Reattaching request from " + connection.getRemoteAddress());
        ServerSessionPacketHandler sessionHandler = protocolManager.getSessionHandler(request.getName());
        // HORNETQ-720 XXX ataylor?
        if (/*!server.checkActivate() || */
        sessionHandler == null) {
            response = new ReattachSessionResponseMessage(-1, false);
        } else {
            if (sessionHandler.getChannel().getConfirmationWindowSize() == -1) {
                // Even though session exists, we can't reattach since confi window size == -1,
                // i.e. we don't have a resend cache for commands, so we just close the old session
                // and let the client recreate
                ActiveMQServerLogger.LOGGER.reattachRequestFailed(connection.getRemoteAddress());
                sessionHandler.closeListeners();
                sessionHandler.close();
                response = new ReattachSessionResponseMessage(-1, false);
            } else {
                // Reconnect the channel to the new connection
                int serverLastConfirmedCommandID = sessionHandler.transferConnection(connection, request.getLastConfirmedCommandID());
                response = new ReattachSessionResponseMessage(serverLastConfirmedCommandID, true);
            }
        }
    } catch (Exception e) {
        ActiveMQServerLogger.LOGGER.failedToReattachSession(e);
        response = new ActiveMQExceptionMessage(new ActiveMQInternalErrorException());
    }
    channel1.send(response);
}
Also used : ServerSessionPacketHandler(org.apache.activemq.artemis.core.protocol.core.ServerSessionPacketHandler) Packet(org.apache.activemq.artemis.core.protocol.core.Packet) ActiveMQExceptionMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException) ReattachSessionResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ReattachSessionResponseMessage) 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)

Example 5 with ActiveMQInternalErrorException

use of org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException in project activemq-artemis by apache.

the class CloseDestroyedConnectionTest method testCloseDestroyedConnection.

/*
    * Closing a connection that is destroyed should cleanly close everything without throwing exceptions
    */
@Test
public void testCloseDestroyedConnection() throws Exception {
    long connectionTTL = 500;
    cf.setClientFailureCheckPeriod(connectionTTL / 2);
    // Need to set connection ttl to a low figure so connections get removed quickly on the server
    cf.setConnectionTTL(connectionTTL);
    conn = cf.createConnection();
    Assert.assertEquals(1, server.getRemotingService().getConnections().size());
    Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    // Give time for the initial ping to reach the server before we fail (it has connection TTL in it)
    Thread.sleep(500);
    String queueName = "myqueue";
    Queue queue = ActiveMQJMSClient.createQueue(queueName);
    super.createQueue(queueName);
    sess.createConsumer(queue);
    sess.createProducer(queue);
    sess.createBrowser(queue);
    // Now fail the underlying connection
    ClientSessionInternal sessi = (ClientSessionInternal) ((ActiveMQSession) sess).getCoreSession();
    RemotingConnection rc = sessi.getConnection();
    rc.fail(new ActiveMQInternalErrorException());
    // Now close the connection
    conn.close();
    long start = System.currentTimeMillis();
    while (true) {
        int cons = server.getRemotingService().getConnections().size();
        if (cons == 0) {
            break;
        }
        long now = System.currentTimeMillis();
        if (now - start > 10000) {
            throw new Exception("Timed out waiting for connections to close");
        }
        Thread.sleep(50);
    }
}
Also used : ClientSessionInternal(org.apache.activemq.artemis.core.client.impl.ClientSessionInternal) RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException) Queue(javax.jms.Queue) JMSException(javax.jms.JMSException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) Session(javax.jms.Session) ActiveMQSession(org.apache.activemq.artemis.jms.client.ActiveMQSession) Test(org.junit.Test)

Aggregations

ActiveMQInternalErrorException (org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException)11 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)8 Test (org.junit.Test)5 ClientSessionInternal (org.apache.activemq.artemis.core.client.impl.ClientSessionInternal)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 Packet (org.apache.activemq.artemis.core.protocol.core.Packet)3 ActiveMQExceptionMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage)3 RemotingConnection (org.apache.activemq.artemis.spi.core.protocol.RemotingConnection)3 Connection (javax.jms.Connection)2 Session (javax.jms.Session)2 ActiveMQClusterSecurityException (org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException)2 ActiveMQSecurityException (org.apache.activemq.artemis.api.core.ActiveMQSecurityException)2 ServerSessionPacketHandler (org.apache.activemq.artemis.core.protocol.core.ServerSessionPacketHandler)2 ActiveMQConnection (org.apache.activemq.artemis.jms.client.ActiveMQConnection)2 ActiveMQSession (org.apache.activemq.artemis.jms.client.ActiveMQSession)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 JMSException (javax.jms.JMSException)1 Queue (javax.jms.Queue)1 ActiveMQIOErrorException (org.apache.activemq.artemis.api.core.ActiveMQIOErrorException)1