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();
}
}
}
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();
}
}
}
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);
}
}
}
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;
}
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;
}
}
Aggregations