Search in sources :

Example 11 with ActiveMQIOErrorException

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

the class NIOSequentialFile method open.

@Override
public void open(final int maxIO, final boolean useExecutor) throws IOException {
    try {
        rfile = new RandomAccessFile(getFile(), "rw");
        channel = rfile.getChannel();
        fileSize = channel.size();
    } catch (ClosedChannelException e) {
        throw e;
    } catch (IOException e) {
        factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this);
        throw e;
    }
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) ActiveMQIOErrorException(org.apache.activemq.artemis.api.core.ActiveMQIOErrorException) RandomAccessFile(java.io.RandomAccessFile) IOException(java.io.IOException)

Example 12 with ActiveMQIOErrorException

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

the class TemporaryQueueTest method testRecreateConsumerOverServerFailure.

@Test
public void testRecreateConsumerOverServerFailure() throws Exception {
    ServerLocator serverWithReattach = createInVMNonHALocator().setReconnectAttempts(30).setRetryInterval(1000).setConfirmationWindowSize(-1).setConnectionTTL(TemporaryQueueTest.CONNECTION_TTL).setClientFailureCheckPeriod(TemporaryQueueTest.CONNECTION_TTL / 3);
    ClientSessionFactory reattachSF = createSessionFactory(serverWithReattach);
    ClientSession session = reattachSF.createSession(false, false);
    session.createTemporaryQueue("tmpAd", "tmpQ");
    ClientConsumer consumer = session.createConsumer("tmpQ");
    ClientProducer prod = session.createProducer("tmpAd");
    session.start();
    RemotingConnectionImpl conn = (RemotingConnectionImpl) ((ClientSessionInternal) session).getConnection();
    conn.fail(new ActiveMQIOErrorException());
    prod.send(session.createMessage(false));
    session.commit();
    assertNotNull(consumer.receive(1000));
    session.close();
    reattachSF.close();
    serverWithReattach.close();
}
Also used : ActiveMQIOErrorException(org.apache.activemq.artemis.api.core.ActiveMQIOErrorException) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) RemotingConnectionImpl(org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Test(org.junit.Test)

Example 13 with ActiveMQIOErrorException

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

the class AbstractSequentialFile method copyTo.

@Override
public void copyTo(SequentialFile newFileName) throws Exception {
    try {
        ActiveMQJournalLogger.LOGGER.debug("Copying " + this + " as " + newFileName);
        if (!newFileName.isOpen()) {
            newFileName.open();
        }
        if (!isOpen()) {
            this.open();
        }
        ByteBuffer buffer = ByteBuffer.allocate(10 * 1024);
        FileIOUtil.copyData(this, newFileName, buffer);
        newFileName.close();
        this.close();
    } catch (ClosedChannelException e) {
        throw e;
    } catch (IOException e) {
        factory.onIOError(new ActiveMQIOErrorException(e.getMessage(), e), e.getMessage(), this);
        throw e;
    }
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) ActiveMQIOErrorException(org.apache.activemq.artemis.api.core.ActiveMQIOErrorException) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ActiveMQIOErrorException (org.apache.activemq.artemis.api.core.ActiveMQIOErrorException)13 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)7 ActiveMQQueueMaxConsumerLimitReached (org.apache.activemq.artemis.api.core.ActiveMQQueueMaxConsumerLimitReached)5 ActiveMQXAException (org.apache.activemq.artemis.core.exception.ActiveMQXAException)5 IOException (java.io.IOException)4 ByteBuffer (java.nio.ByteBuffer)3 ClosedChannelException (java.nio.channels.ClosedChannelException)3 NullResponseMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.NullResponseMessage)3 SequentialFile (org.apache.activemq.artemis.core.io.SequentialFile)2 Test (org.junit.Test)2 ByteBuf (io.netty.buffer.ByteBuf)1 RandomAccessFile (java.io.RandomAccessFile)1 List (java.util.List)1 ActiveMQInternalErrorException (org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException)1 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)1 Message (org.apache.activemq.artemis.api.core.Message)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)1 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1