Search in sources :

Example 11 with RMQJMSException

use of com.rabbitmq.jms.util.RMQJMSException in project rabbitmq-jms-client by rabbitmq.

the class RMQSession method rollback.

/**
 * {@inheritDoc}
 */
@Override
public void rollback() throws JMSException {
    logger.trace("rollback transaction on session {}", this);
    illegalStateExceptionIfClosed();
    if (!this.transacted)
        throw new IllegalStateException("Session is not transacted");
    if (this.enterCommittingBlock()) {
        try {
            // rollback the RabbitMQ transaction which may cause some messages to become unacknowledged
            this.channel.txRollback();
            // requeue all unacknowledged messages (not automatically done by RabbitMQ)
            // requeue
            this.channel.basicRecover(true);
        } catch (IOException x) {
            this.logger.error("RabbitMQ exception on channel.txRollback() or channel.basicRecover(true) in session {}", this, x);
            throw new RMQJMSException(x);
        } finally {
            this.leaveCommittingBlock();
        }
    }
}
Also used : IllegalStateException(javax.jms.IllegalStateException) RMQJMSException(com.rabbitmq.jms.util.RMQJMSException) IOException(java.io.IOException)

Example 12 with RMQJMSException

use of com.rabbitmq.jms.util.RMQJMSException in project rabbitmq-jms-client by rabbitmq.

the class RMQSession method commit.

/**
 * {@inheritDoc}
 */
@Override
public void commit() throws JMSException {
    logger.trace("commit transaction on session {}", this);
    illegalStateExceptionIfClosed();
    if (!this.transacted)
        throw new IllegalStateException("Session is not transacted");
    if (this.enterCommittingBlock()) {
        try {
            // Call commit on the channel.
            // All messages ought already to have been acked.
            this.channel.txCommit();
        } catch (Exception x) {
            this.logger.error("RabbitMQ exception on channel.txCommit() in session {}", this, x);
            throw new RMQJMSException(x);
        } finally {
            this.leaveCommittingBlock();
        }
    }
}
Also used : IllegalStateException(javax.jms.IllegalStateException) RMQJMSException(com.rabbitmq.jms.util.RMQJMSException) TimeoutException(java.util.concurrent.TimeoutException) RMQJMSSelectorException(com.rabbitmq.jms.util.RMQJMSSelectorException) IllegalStateException(javax.jms.IllegalStateException) JMSException(javax.jms.JMSException) RMQJMSException(com.rabbitmq.jms.util.RMQJMSException) ShutdownSignalException(com.rabbitmq.client.ShutdownSignalException) IOException(java.io.IOException) InvalidSelectorException(javax.jms.InvalidSelectorException)

Example 13 with RMQJMSException

use of com.rabbitmq.jms.util.RMQJMSException in project rabbitmq-jms-client by rabbitmq.

the class RMQObjectMessage method getObject.

public Serializable getObject(List<String> trustedPackages) throws JMSException {
    if (buf == null) {
        return null;
    } else {
        this.loggerDebugByteArray("Deserialising object from buffer {} for {}", this.buf, "RMQObjectMessage");
        ByteArrayInputStream bin = new ByteArrayInputStream(buf);
        try {
            WhiteListObjectInputStream in = new WhiteListObjectInputStream(bin, trustedPackages);
            return (Serializable) in.readObject();
        } catch (ClassNotFoundException x) {
            throw new RMQJMSException(x);
        } catch (IOException x) {
            throw new RMQJMSException(x);
        }
    }
}
Also used : Serializable(java.io.Serializable) RMQJMSException(com.rabbitmq.jms.util.RMQJMSException) ByteArrayInputStream(java.io.ByteArrayInputStream) WhiteListObjectInputStream(com.rabbitmq.jms.util.WhiteListObjectInputStream) IOException(java.io.IOException)

Example 14 with RMQJMSException

use of com.rabbitmq.jms.util.RMQJMSException in project rabbitmq-jms-client by rabbitmq.

the class RMQStreamMessage method clearBodyInternal.

/**
 * {@inheritDoc}
 */
@Override
public void clearBodyInternal() throws JMSException {
    this.bout = new ByteArrayOutputStream(RMQMessage.DEFAULT_MESSAGE_BODY_SIZE);
    try {
        this.out = new ObjectOutputStream(this.bout);
    } catch (IOException x) {
        throw new RMQJMSException(x);
    }
    this.bin = null;
    this.in = null;
    this.buf = null;
    this.readbuf = null;
    this.reading = false;
}
Also used : RMQJMSException(com.rabbitmq.jms.util.RMQJMSException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Example 15 with RMQJMSException

use of com.rabbitmq.jms.util.RMQJMSException in project rabbitmq-jms-client by rabbitmq.

the class RMQStreamMessage method reset.

/**
 * {@inheritDoc}
 */
@Override
public void reset() throws JMSException {
    this.readbuf = null;
    if (this.reading) {
        // beginning of the stream
        try {
            this.bin = new ByteArrayInputStream(buf);
            this.in = new ObjectInputStream(this.bin);
        } catch (IOException x) {
            throw new RMQJMSException(x);
        }
    } else {
        try {
            buf = null;
            if (this.out != null) {
                this.out.flush();
                buf = this.bout.toByteArray();
            } else {
                buf = new byte[0];
            }
            this.bin = new ByteArrayInputStream(buf);
            this.in = new ObjectInputStream(this.bin);
        } catch (IOException x) {
            throw new RMQJMSException(x);
        }
        this.reading = true;
        this.out = null;
        this.bout = null;
    }
}
Also used : RMQJMSException(com.rabbitmq.jms.util.RMQJMSException) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

RMQJMSException (com.rabbitmq.jms.util.RMQJMSException)16 IOException (java.io.IOException)15 JMSException (javax.jms.JMSException)6 ShutdownSignalException (com.rabbitmq.client.ShutdownSignalException)5 IllegalStateException (javax.jms.IllegalStateException)5 RMQJMSSelectorException (com.rabbitmq.jms.util.RMQJMSSelectorException)4 TimeoutException (java.util.concurrent.TimeoutException)4 InvalidSelectorException (javax.jms.InvalidSelectorException)4 AMQP (com.rabbitmq.client.AMQP)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 MessageEOFException (javax.jms.MessageEOFException)2 MessageNotWriteableException (javax.jms.MessageNotWriteableException)2 Channel (com.rabbitmq.client.Channel)1 RMQBytesMessage (com.rabbitmq.jms.client.message.RMQBytesMessage)1 RMQTextMessage (com.rabbitmq.jms.client.message.RMQTextMessage)1 RMQMessageFormatException (com.rabbitmq.jms.util.RMQMessageFormatException)1 WhiteListObjectInputStream (com.rabbitmq.jms.util.WhiteListObjectInputStream)1 EOFException (java.io.EOFException)1