use of com.swiftmq.amqp.v100.client.InvalidStateException in project swiftmq-client by iitsoftware.
the class AMQPMessage method accept.
/**
* Accepts delivery of this message. This is part of settlement with QoS modes at-least-once and exactly-once.
*
* @throws InvalidStateException If the state is invalid to perform this operation
*/
public void accept() throws InvalidStateException {
if (consumer == null)
throw new InvalidStateException("Message not associated with a consumer");
if (settled && txnIdIF == null)
throw new InvalidStateException("Accept not required; message has already been settled");
DeliveryStateIF deliveryStateIF = null;
if (txnIdIF == null)
deliveryStateIF = new Accepted();
else {
TransactionalState transactionalState = new TransactionalState();
transactionalState.setTxnId(txnIdIF);
transactionalState.setOutcome(new Accepted());
deliveryStateIF = transactionalState;
}
consumer.sendDisposition(this, deliveryStateIF);
}
use of com.swiftmq.amqp.v100.client.InvalidStateException in project swiftmq-client by iitsoftware.
the class AMQPMessage method reject.
/**
* <p>Rejects delivery of this message. This is part of settlement with QoS modes at-least-once and exactly-once.
* </p>
* <p>
* This operation causes the delivery count to be incremented and the message to be redelivered to this or other
* competing consumers.
* </p>
*
* @throws InvalidStateException If the state is invalid to perform this operation
*/
public void reject() throws InvalidStateException {
if (consumer == null)
throw new InvalidStateException("Message not associated with a consumer");
if (settled && txnIdIF == null)
throw new InvalidStateException("Reject not possible; message has already been settled");
DeliveryStateIF deliveryStateIF = null;
if (txnIdIF == null)
deliveryStateIF = new Rejected();
else {
TransactionalState transactionalState = new TransactionalState();
transactionalState.setTxnId(txnIdIF);
transactionalState.setOutcome(new Rejected());
deliveryStateIF = transactionalState;
}
consumer.sendDisposition(this, deliveryStateIF);
}
Aggregations