Package com.rabbitmq.client.impl
Class ChannelN
- java.lang.Object
-
- com.rabbitmq.client.impl.ShutdownNotifierComponent
-
- com.rabbitmq.client.impl.AMQChannel
-
- com.rabbitmq.client.impl.ChannelN
-
- All Implemented Interfaces:
Channel
,ShutdownNotifier
,java.lang.AutoCloseable
- Direct Known Subclasses:
RecoveryAwareChannelN
public class ChannelN extends AMQChannel implements Channel
Main interface to AMQP protocol functionality. Public API - Implementation of all AMQChannels except channel zero.To open a channel,
Connection
conn = ...;ChannelN
ch1 = conn.createChannel
();
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.rabbitmq.client.impl.AMQChannel
AMQChannel.BlockingRpcContinuation<T>, AMQChannel.RpcContinuation, AMQChannel.SimpleBlockingRpcContinuation
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,Consumer>
_consumers
Map from consumer tag toConsumer
instance.private java.util.Collection<ConfirmListener>
confirmListeners
The ConfirmListener collection.private boolean
confirmSelectActivated
Whether the confirm select method has been successfully activatedprivate Consumer
defaultConsumer
The current default consumer, or null if there is none.private ConsumerDispatcher
dispatcher
Dispatcher of consumer work for this channelprivate java.util.concurrent.CountDownLatch
finishedShutdownFlag
Future boolean for shutting downprivate static org.slf4j.Logger
LOGGER
private static int
MAX_UNSIGNED_SHORT
protected MetricsCollector
metricsCollector
private long
nextPublishSeqNo
Sequence number of next published message requiring confirmation.private ObservationCollector
observationCollector
private boolean
onlyAcksReceived
Whether any nacks have been received since the last waitForConfirms().private java.util.Collection<ReturnListener>
returnListeners
The ReturnListener collection.private java.util.SortedSet<java.lang.Long>
unconfirmedSet
Set of currently unconfirmed messages (i.e.private static java.lang.String
UNSPECIFIED_OUT_OF_BAND
-
Fields inherited from class com.rabbitmq.client.impl.AMQChannel
_blockContent, _channelLock, _channelLockCondition, _rpcTimeout, NO_RPC_TIMEOUT
-
-
Constructor Summary
Constructors Constructor Description ChannelN(AMQConnection connection, int channelNumber, ConsumerWorkService workService)
Construct a new channel on the given connection with the given channel number.ChannelN(AMQConnection connection, int channelNumber, ConsumerWorkService workService, MetricsCollector metricsCollector, ObservationCollector observationCollector)
Construct a new channel on the given connection with the given channel number.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Public API - Abort this channel with theAMQP.REPLY_SUCCESS
close code and message 'OK'.void
abort(int closeCode, java.lang.String closeMessage)
Public API - Abort this channel.ConfirmListener
addConfirmListener(ConfirmCallback ackCallback, ConfirmCallback nackCallback)
Add a lambda-basedConfirmListener
.void
addConfirmListener(ConfirmListener listener)
Add aConfirmListener
.ReturnListener
addReturnListener(ReturnCallback returnCallback)
Add a lambda-basedReturnListener
.void
addReturnListener(ReturnListener listener)
Add aReturnListener
.java.util.concurrent.CompletableFuture<Command>
asyncCompletableRpc(Method method)
Asynchronously send a method over this channel.void
asyncRpc(Method method)
Asynchronously send a method over this channel.private void
asyncShutdown(Command command)
void
basicAck(long deliveryTag, boolean multiple)
Public API - Acknowledge one or several received messages.void
basicCancel(java.lang.String consumerTag)
Public API - Cancel a consumer.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, Consumer callback)
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, DeliverCallback deliverCallback, CancelCallback cancelCallback)
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, boolean noLocal, boolean exclusive, java.util.Map<java.lang.String,java.lang.Object> arguments, Consumer callback)
Public API - Start a consumer.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, boolean noLocal, boolean exclusive, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, CancelCallback cancelCallback)
Public API - Start a consumer.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, boolean noLocal, boolean exclusive, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Start a consumer.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, boolean noLocal, boolean exclusive, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Public API - Start a consumer.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, Consumer callback)
Public API - Start a non-nolocal, non-exclusive consumer.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, DeliverCallback deliverCallback, CancelCallback cancelCallback)
Public API - Start a non-nolocal, non-exclusive consumer.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Public API - Start a non-nolocal, non-exclusive consumer.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Public API - Start a non-nolocal, non-exclusive consumer.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.util.Map<java.lang.String,java.lang.Object> arguments, Consumer callback)
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag and specified arguments.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, CancelCallback cancelCallback)
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag and specified arguments.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag and specified arguments.java.lang.String
basicConsume(java.lang.String queue, boolean autoAck, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag and specified arguments.java.lang.String
basicConsume(java.lang.String queue, Consumer callback)
Public API - Start a non-nolocal, non-exclusive consumer, with explicit acknowledgement and a server-generated consumerTag.java.lang.String
basicConsume(java.lang.String queue, DeliverCallback deliverCallback, CancelCallback cancelCallback)
Public API - Start a non-nolocal, non-exclusive consumer, with explicit acknowledgement and a server-generated consumerTag.java.lang.String
basicConsume(java.lang.String queue, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Public API - Start a non-nolocal, non-exclusive consumer, with explicit acknowledgement and a server-generated consumerTag.java.lang.String
basicConsume(java.lang.String queue, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
Public API - Start a non-nolocal, non-exclusive consumer, with explicit acknowledgement and a server-generated consumerTag.GetResponse
basicGet(java.lang.String queue, boolean autoAck)
Public API - Retrieve a message from a queue usingAMQP.Basic.Get
void
basicNack(long deliveryTag, boolean multiple, boolean requeue)
Public API - Reject one or several received messages.void
basicPublish(java.lang.String exchange, java.lang.String routingKey, boolean mandatory, boolean immediate, AMQP.BasicProperties props, byte[] body)
Public API - Publish a message.void
basicPublish(java.lang.String exchange, java.lang.String routingKey, boolean mandatory, AMQP.BasicProperties props, byte[] body)
Public API - Publish a message.void
basicPublish(java.lang.String exchange, java.lang.String routingKey, AMQP.BasicProperties props, byte[] body)
Public API - Publish a message.void
basicQos(int prefetchCount)
Public API - Request a specific prefetchCount "quality of service" settings for this channel.void
basicQos(int prefetchCount, boolean global)
Public API - Request a specific prefetchCount "quality of service" settings for this channel.void
basicQos(int prefetchSize, int prefetchCount, boolean global)
Public API - Request specific "quality of service" settings.AMQImpl.Basic.RecoverOk
basicRecover()
Public API - Ask the broker to resend unacknowledged messages.AMQImpl.Basic.RecoverOk
basicRecover(boolean requeue)
Public API - Ask the broker to resend unacknowledged messages.void
basicReject(long deliveryTag, boolean requeue)
Public API - Reject a message.private void
broadcastShutdownSignal(ShutdownSignalException signal)
Sends a ShutdownSignal to all active consumers.private void
callConfirmListeners(Command command, AMQImpl.Basic.Ack ack)
private void
callConfirmListeners(Command command, AMQImpl.Basic.Nack nack)
private void
callReturnListeners(Command command, AMQImpl.Basic.Return basicReturn)
void
clearConfirmListeners()
Remove allConfirmListener
s.void
clearReturnListeners()
Remove allReturnListener
s.void
close()
Public API - Close this channel with theAMQP.REPLY_SUCCESS
close code and message 'OK'.void
close(int closeCode, java.lang.String closeMessage)
Public API - Close this channel.protected void
close(int closeCode, java.lang.String closeMessage, boolean initiatedByApplication, java.lang.Throwable cause, boolean abort)
Protected API - Close channel with code and message, indicating the source of the closure and a causing exception (null if none).AMQImpl.Confirm.SelectOk
confirmSelect()
Public API - Enables publisher acknowledgements on this channel.long
consumerCount(java.lang.String queue)
Public API - Returns the number of consumers on a queue.private Consumer
consumerFromDeliverCancelCallbacks(DeliverCallback deliverCallback, CancelCallback cancelCallback)
private Consumer
consumerFromDeliverCancelShutdownCallbacks(DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
private Consumer
consumerFromDeliverShutdownCallbacks(DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
void
enqueueRpc(AMQChannel.RpcContinuation k)
AMQImpl.Exchange.BindOk
exchangeBind(java.lang.String destination, java.lang.String source, java.lang.String routingKey)
Public API - Bind an exchange to an exchange, with no extra arguments.AMQImpl.Exchange.BindOk
exchangeBind(java.lang.String destination, java.lang.String source, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Bind an exchange to an exchange.void
exchangeBindNoWait(java.lang.String destination, java.lang.String source, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - LikeChannel.exchangeBind(String, String, String, java.util.Map)
but sets nowait parameter to true and returns void (as there will be no response from the server).AMQImpl.Exchange.DeclareOk
exchangeDeclare(java.lang.String exchange, BuiltinExchangeType type)
Public API - Actively declare a non-autodelete, non-durable exchange with no extra argumentsAMQImpl.Exchange.DeclareOk
exchangeDeclare(java.lang.String exchange, BuiltinExchangeType type, boolean durable)
Public API - Actively declare a non-autodelete exchange with no extra argumentsAMQImpl.Exchange.DeclareOk
exchangeDeclare(java.lang.String exchange, BuiltinExchangeType type, boolean durable, boolean autoDelete, boolean internal, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Declare an exchange, via an interface that allows the complete set of arguments.AMQImpl.Exchange.DeclareOk
exchangeDeclare(java.lang.String exchange, BuiltinExchangeType type, boolean durable, boolean autoDelete, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Declare an exchange.AMQImpl.Exchange.DeclareOk
exchangeDeclare(java.lang.String exchange, java.lang.String type)
Public API - Actively declare a non-autodelete, non-durable exchange with no extra argumentsAMQImpl.Exchange.DeclareOk
exchangeDeclare(java.lang.String exchange, java.lang.String type, boolean durable)
Public API - Actively declare a non-autodelete exchange with no extra argumentsAMQImpl.Exchange.DeclareOk
exchangeDeclare(java.lang.String exchange, java.lang.String type, boolean durable, boolean autoDelete, boolean internal, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Declare an exchange, via an interface that allows the complete set of arguments.AMQImpl.Exchange.DeclareOk
exchangeDeclare(java.lang.String exchange, java.lang.String type, boolean durable, boolean autoDelete, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Declare an exchange.void
exchangeDeclareNoWait(java.lang.String exchange, BuiltinExchangeType type, boolean durable, boolean autoDelete, boolean internal, java.util.Map<java.lang.String,java.lang.Object> arguments)
LikeChannel.exchangeDeclare(String, String, boolean, boolean, java.util.Map)
but sets nowait parameter to true and returns nothing (as there will be no response from the server).void
exchangeDeclareNoWait(java.lang.String exchange, java.lang.String type, boolean durable, boolean autoDelete, boolean internal, java.util.Map<java.lang.String,java.lang.Object> arguments)
LikeChannel.exchangeDeclare(String, String, boolean, boolean, java.util.Map)
but sets nowait parameter to true and returns nothing (as there will be no response from the server).AMQImpl.Exchange.DeclareOk
exchangeDeclarePassive(java.lang.String exchange)
Public API - Declare an exchange passively; that is, check if the named exchange exists.AMQImpl.Exchange.DeleteOk
exchangeDelete(java.lang.String exchange)
Public API - Delete an exchange, without regard for whether it is in use or notAMQImpl.Exchange.DeleteOk
exchangeDelete(java.lang.String exchange, boolean ifUnused)
Public API - Delete an exchangevoid
exchangeDeleteNoWait(java.lang.String exchange, boolean ifUnused)
Public API - LikeChannel.exchangeDelete(String, boolean)
but sets nowait parameter to true and returns void (as there will be no response from the server).AMQImpl.Exchange.UnbindOk
exchangeUnbind(java.lang.String destination, java.lang.String source, java.lang.String routingKey)
Public API - Unbind an exchange from an exchange, with no extra arguments.AMQImpl.Exchange.UnbindOk
exchangeUnbind(java.lang.String destination, java.lang.String source, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Unbind an exchange from an exchange.void
exchangeUnbindNoWait(java.lang.String destination, java.lang.String source, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Same asChannel.exchangeUnbind(String, String, String, java.util.Map)
but sets no-wait parameter to true and returns nothing (as there will be no response from the server).private void
finishProcessShutdownSignal()
Finish shutdown processing -- idempotentConsumer
getDefaultConsumer()
Returns the current default consumer.long
getNextPublishSeqNo()
Public API - When in confirm mode, returns the sequence number of the next message to be published.(package private) java.util.concurrent.CountDownLatch
getShutdownLatch()
private void
handleAckNack(long seqNo, boolean multiple, boolean nack)
protected void
markRpcFinished()
long
messageCount(java.lang.String queue)
Public API - Returns the number of messages in a queue ready to be delivered to consumers.void
open()
Package method: open the channel.boolean
processAsync(Command command)
Protected API - Filters the inbound command stream, processing Basic.Deliver, Basic.Return and Channel.Close specially.protected void
processDelivery(Command command, AMQImpl.Basic.Deliver method)
void
processShutdownSignal(ShutdownSignalException signal, boolean ignoreClosed, boolean notifyRpc)
Protected API - overridden to quiesce consumer work and broadcast the signal to all consumers after calling the superclass's method.AMQImpl.Queue.BindOk
queueBind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey)
Public API - Bind a queue to an exchange, with no extra arguments.AMQImpl.Queue.BindOk
queueBind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Bind a queue to an exchange.void
queueBindNoWait(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Same asChannel.queueBind(String, String, String, java.util.Map)
but sets nowait parameter to true and returns void (as there will be no response from the server).AMQP.Queue.DeclareOk
queueDeclare()
Public API - Actively declare a server-named exclusive, autodelete, non-durable queue.AMQImpl.Queue.DeclareOk
queueDeclare(java.lang.String queue, boolean durable, boolean exclusive, boolean autoDelete, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Declare a queuevoid
queueDeclareNoWait(java.lang.String queue, boolean durable, boolean exclusive, boolean autoDelete, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - LikeChannel.queueDeclare(String, boolean, boolean, boolean, java.util.Map)
but sets nowait flag to true and returns no result (as there will be no response from the server).AMQImpl.Queue.DeclareOk
queueDeclarePassive(java.lang.String queue)
Public API - Declare a queue passively; i.e., check if it exists.AMQImpl.Queue.DeleteOk
queueDelete(java.lang.String queue)
Public API - Delete a queue, without regard for whether it is in use or has messages on itAMQImpl.Queue.DeleteOk
queueDelete(java.lang.String queue, boolean ifUnused, boolean ifEmpty)
Public API - Delete a queuevoid
queueDeleteNoWait(java.lang.String queue, boolean ifUnused, boolean ifEmpty)
LikeChannel.queueDelete(String, boolean, boolean)
but sets nowait parameter to true and returns nothing (as there will be no response from the server).AMQImpl.Queue.PurgeOk
queuePurge(java.lang.String queue)
Public API - Purges the contents of the given queue.AMQImpl.Queue.UnbindOk
queueUnbind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey)
Public API - Unbinds a queue from an exchange, with no extra arguments.AMQImpl.Queue.UnbindOk
queueUnbind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments)
Public API - Unbind a queue from an exchange.private void
releaseChannel()
boolean
removeConfirmListener(ConfirmListener listener)
Remove aConfirmListener
.boolean
removeReturnListener(ReturnListener listener)
Remove aReturnListener
.AMQCommand
rpc(Method method)
Protected API - sends aMethod
to the broker and waits for the next in-bound Command from the broker: only for use from non-connection-MainLoop threads!void
setDefaultConsumer(Consumer consumer)
Sets the current default consumer.private void
startProcessShutdownSignal(ShutdownSignalException signal, boolean ignoreClosed, boolean notifyRpc)
Start to shutdown -- defer rest of processing until readyAMQImpl.Tx.CommitOk
txCommit()
Public API - Commits a TX transaction on this channel.AMQImpl.Tx.RollbackOk
txRollback()
Public API - Rolls back a TX transaction on this channel.AMQImpl.Tx.SelectOk
txSelect()
Public API - Enables TX mode on this channel.private static void
validateQueueNameLength(java.lang.String queue)
boolean
waitForConfirms()
Wait until all messages published since the last call have been either ack'd or nack'd by the broker.boolean
waitForConfirms(long timeout)
Wait until all messages published since the last call have been either ack'd or nack'd by the broker; or until timeout elapses.void
waitForConfirmsOrDie()
Wait until all messages published since the last call have been either ack'd or nack'd by the broker.void
waitForConfirmsOrDie(long timeout)
Wait until all messages published since the last call have been either ack'd or nack'd by the broker; or until timeout elapses.-
Methods inherited from class com.rabbitmq.client.impl.AMQChannel
asyncRpc, connectionInfo, enqueueAsyncRpc, ensureIsOpen, exnWrappingAsyncRpc, exnWrappingRpc, getChannelNumber, getConnection, handleCompleteInboundCommand, handleFrame, isOutstandingRpc, nextOutstandingRpc, notifyOutstandingRpc, quiescingAsyncRpc, quiescingRpc, quiescingTransmit, quiescingTransmit, rpc, rpc, toString, transmit, transmit, wrap, wrap, wrapTimeoutException
-
Methods inherited from class com.rabbitmq.client.impl.ShutdownNotifierComponent
addShutdownListener, getCloseReason, isOpen, notifyListeners, removeShutdownListener, setShutdownCauseIfOpen
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.rabbitmq.client.Channel
getChannelNumber, getConnection
-
Methods inherited from interface com.rabbitmq.client.ShutdownNotifier
addShutdownListener, getCloseReason, isOpen, notifyListeners, removeShutdownListener
-
-
-
-
Field Detail
-
MAX_UNSIGNED_SHORT
private static final int MAX_UNSIGNED_SHORT
- See Also:
- Constant Field Values
-
UNSPECIFIED_OUT_OF_BAND
private static final java.lang.String UNSPECIFIED_OUT_OF_BAND
- See Also:
- Constant Field Values
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
_consumers
private final java.util.Map<java.lang.String,Consumer> _consumers
Map from consumer tag toConsumer
instance. Note that, in general, this map should ONLY ever be accessed from the connection's reader thread. We go to some pains to ensure this is the case - see the use of BlockingRpcContinuation to inject code into the reader thread in basicConsume and basicCancel.
-
returnListeners
private final java.util.Collection<ReturnListener> returnListeners
The ReturnListener collection.
-
confirmListeners
private final java.util.Collection<ConfirmListener> confirmListeners
The ConfirmListener collection.
-
nextPublishSeqNo
private long nextPublishSeqNo
Sequence number of next published message requiring confirmation.
-
defaultConsumer
private volatile Consumer defaultConsumer
The current default consumer, or null if there is none.
-
dispatcher
private final ConsumerDispatcher dispatcher
Dispatcher of consumer work for this channel
-
finishedShutdownFlag
private volatile java.util.concurrent.CountDownLatch finishedShutdownFlag
Future boolean for shutting down
-
unconfirmedSet
private final java.util.SortedSet<java.lang.Long> unconfirmedSet
Set of currently unconfirmed messages (i.e. messages that have not been ack'd or nack'd by the server yet.
-
confirmSelectActivated
private boolean confirmSelectActivated
Whether the confirm select method has been successfully activated
-
onlyAcksReceived
private volatile boolean onlyAcksReceived
Whether any nacks have been received since the last waitForConfirms().
-
metricsCollector
protected final MetricsCollector metricsCollector
-
observationCollector
private final ObservationCollector observationCollector
-
-
Constructor Detail
-
ChannelN
public ChannelN(AMQConnection connection, int channelNumber, ConsumerWorkService workService)
Construct a new channel on the given connection with the given channel number. Usually not called directly - call Connection.createChannel instead.- Parameters:
connection
- The connection associated with this channelchannelNumber
- The channel number to be associated with this channelworkService
- service for managing this channel's consumer callbacks- See Also:
Connection.createChannel()
-
ChannelN
public ChannelN(AMQConnection connection, int channelNumber, ConsumerWorkService workService, MetricsCollector metricsCollector, ObservationCollector observationCollector)
Construct a new channel on the given connection with the given channel number. Usually not called directly - call Connection.createChannel instead.- Parameters:
connection
- The connection associated with this channelchannelNumber
- The channel number to be associated with this channelworkService
- service for managing this channel's consumer callbacksmetricsCollector
- service for managing metrics- See Also:
Connection.createChannel()
-
-
Method Detail
-
open
public void open() throws java.io.IOException
Package method: open the channel. This is only called fromChannelManager
.- Throws:
java.io.IOException
- if any problem is encountered
-
addReturnListener
public void addReturnListener(ReturnListener listener)
Description copied from interface:Channel
Add aReturnListener
.- Specified by:
addReturnListener
in interfaceChannel
- Parameters:
listener
- the listener to add
-
addReturnListener
public ReturnListener addReturnListener(ReturnCallback returnCallback)
Description copied from interface:Channel
Add a lambda-basedReturnListener
.- Specified by:
addReturnListener
in interfaceChannel
- Parameters:
returnCallback
- the callback when the message is returned- Returns:
- the listener that wraps the callback
- See Also:
ReturnListener
,ReturnCallback
,Return
-
removeReturnListener
public boolean removeReturnListener(ReturnListener listener)
Description copied from interface:Channel
Remove aReturnListener
.- Specified by:
removeReturnListener
in interfaceChannel
- Parameters:
listener
- the listener to remove- Returns:
true
if the listener was found and removed,false
otherwise
-
clearReturnListeners
public void clearReturnListeners()
Description copied from interface:Channel
Remove allReturnListener
s.- Specified by:
clearReturnListeners
in interfaceChannel
-
addConfirmListener
public void addConfirmListener(ConfirmListener listener)
Description copied from interface:Channel
Add aConfirmListener
.- Specified by:
addConfirmListener
in interfaceChannel
- Parameters:
listener
- the listener to add
-
addConfirmListener
public ConfirmListener addConfirmListener(ConfirmCallback ackCallback, ConfirmCallback nackCallback)
Description copied from interface:Channel
Add a lambda-basedConfirmListener
.- Specified by:
addConfirmListener
in interfaceChannel
- Parameters:
ackCallback
- callback on acknackCallback
- call on nack (negative ack)- Returns:
- the listener that wraps the callbacks
- See Also:
ConfirmListener
,ConfirmCallback
-
removeConfirmListener
public boolean removeConfirmListener(ConfirmListener listener)
Description copied from interface:Channel
Remove aConfirmListener
.- Specified by:
removeConfirmListener
in interfaceChannel
- Parameters:
listener
- the listener to remove- Returns:
true
if the listener was found and removed,false
otherwise
-
clearConfirmListeners
public void clearConfirmListeners()
Description copied from interface:Channel
Remove allConfirmListener
s.- Specified by:
clearConfirmListeners
in interfaceChannel
-
waitForConfirms
public boolean waitForConfirms() throws java.lang.InterruptedException
Wait until all messages published since the last call have been either ack'd or nack'd by the broker. Note, when called on a non-Confirm channel, waitForConfirms throws an IllegalStateException.- Specified by:
waitForConfirms
in interfaceChannel
- Returns:
- whether all the messages were ack'd (and none were nack'd)
- Throws:
java.lang.InterruptedException
-
waitForConfirms
public boolean waitForConfirms(long timeout) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
Wait until all messages published since the last call have been either ack'd or nack'd by the broker; or until timeout elapses. If the timeout expires a TimeoutException is thrown. When called on a non-Confirm channel, waitForConfirms throws an IllegalStateException.- Specified by:
waitForConfirms
in interfaceChannel
- Returns:
- whether all the messages were ack'd (and none were nack'd)
- Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
waitForConfirmsOrDie
public void waitForConfirmsOrDie() throws java.io.IOException, java.lang.InterruptedException
Wait until all messages published since the last call have been either ack'd or nack'd by the broker. If any of the messages were nack'd, waitForConfirmsOrDie will throw an IOException. When called on a non-Confirm channel, it will throw an IllegalStateException.- Specified by:
waitForConfirmsOrDie
in interfaceChannel
- Throws:
java.io.IOException
java.lang.InterruptedException
-
waitForConfirmsOrDie
public void waitForConfirmsOrDie(long timeout) throws java.io.IOException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Wait until all messages published since the last call have been either ack'd or nack'd by the broker; or until timeout elapses. If the timeout expires a TimeoutException is thrown. If any of the messages were nack'd, waitForConfirmsOrDie will throw an IOException. When called on a non-Confirm channel, it will throw an IllegalStateException.- Specified by:
waitForConfirmsOrDie
in interfaceChannel
- Throws:
java.io.IOException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
getDefaultConsumer
public Consumer getDefaultConsumer()
Returns the current default consumer.- Specified by:
getDefaultConsumer
in interfaceChannel
- Returns:
- an interface to the current default consumer.
-
setDefaultConsumer
public void setDefaultConsumer(Consumer consumer)
Sets the current default consumer. A null argument is interpreted to mean "do not use a default consumer".- Specified by:
setDefaultConsumer
in interfaceChannel
- Parameters:
consumer
- the consumer to use, or null indicating "don't use one".
-
broadcastShutdownSignal
private void broadcastShutdownSignal(ShutdownSignalException signal)
Sends a ShutdownSignal to all active consumers. Idempotent.- Parameters:
signal
- an exception signalling channel shutdown
-
startProcessShutdownSignal
private void startProcessShutdownSignal(ShutdownSignalException signal, boolean ignoreClosed, boolean notifyRpc)
Start to shutdown -- defer rest of processing until ready
-
finishProcessShutdownSignal
private void finishProcessShutdownSignal()
Finish shutdown processing -- idempotent
-
processShutdownSignal
public void processShutdownSignal(ShutdownSignalException signal, boolean ignoreClosed, boolean notifyRpc)
Protected API - overridden to quiesce consumer work and broadcast the signal to all consumers after calling the superclass's method.- Overrides:
processShutdownSignal
in classAMQChannel
- Parameters:
signal
- the signal to handleignoreClosed
- the flag indicating whether to ignore the AlreadyClosedException thrown when the channel is already closednotifyRpc
- the flag indicating whether any remaining rpc continuation should be notified with the given signal
-
getShutdownLatch
java.util.concurrent.CountDownLatch getShutdownLatch()
-
releaseChannel
private void releaseChannel()
-
processAsync
public boolean processAsync(Command command) throws java.io.IOException
Protected API - Filters the inbound command stream, processing Basic.Deliver, Basic.Return and Channel.Close specially. If we're in quiescing mode, all inbound commands are ignored, except for Channel.Close and Channel.CloseOk.- Specified by:
processAsync
in classAMQChannel
- Parameters:
command
- the command to handle asynchronously- Returns:
- true if we handled the command; otherwise the caller should consider it "unhandled"
- Throws:
java.io.IOException
-
processDelivery
protected void processDelivery(Command command, AMQImpl.Basic.Deliver method)
-
callReturnListeners
private void callReturnListeners(Command command, AMQImpl.Basic.Return basicReturn)
-
callConfirmListeners
private void callConfirmListeners(Command command, AMQImpl.Basic.Ack ack)
-
callConfirmListeners
private void callConfirmListeners(Command command, AMQImpl.Basic.Nack nack)
-
asyncShutdown
private void asyncShutdown(Command command) throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException, java.util.concurrent.TimeoutException
Public API - Close this channel with theAMQP.REPLY_SUCCESS
close code and message 'OK'.
-
close
public void close(int closeCode, java.lang.String closeMessage) throws java.io.IOException, java.util.concurrent.TimeoutException
Public API - Close this channel.- Specified by:
close
in interfaceChannel
- Parameters:
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connection- Throws:
java.io.IOException
- if an error is encounteredjava.util.concurrent.TimeoutException
-
abort
public void abort() throws java.io.IOException
Public API - Abort this channel with theAMQP.REPLY_SUCCESS
close code and message 'OK'. Forces the channel to close and waits for the close operation to complete. Any encountered exceptions in the close operation are silently discarded.
-
abort
public void abort(int closeCode, java.lang.String closeMessage) throws java.io.IOException
Public API - Abort this channel. Forces the channel to close and waits for the close operation to complete. Any encountered exceptions in the close operation are silently discarded.
-
close
protected void close(int closeCode, java.lang.String closeMessage, boolean initiatedByApplication, java.lang.Throwable cause, boolean abort) throws java.io.IOException, java.util.concurrent.TimeoutException
Protected API - Close channel with code and message, indicating the source of the closure and a causing exception (null if none).- Parameters:
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connectioninitiatedByApplication
- true if this comes from an API call, false otherwisecause
- exception triggering closeabort
- true if we should close and ignore errors- Throws:
java.io.IOException
- if an error is encounteredjava.util.concurrent.TimeoutException
-
basicQos
public void basicQos(int prefetchSize, int prefetchCount, boolean global) throws java.io.IOException
Public API - Request specific "quality of service" settings.These settings impose limits on the amount of data the server will deliver to consumers before requiring acknowledgements. Thus they provide a means of consumer-initiated flow control.
Note the prefetch count must be between 0 and 65535 (unsigned short in AMQP 0-9-1).
- Specified by:
basicQos
in interfaceChannel
- Parameters:
prefetchSize
- maximum amount of content (measured in octets) that the server will deliver, 0 if unlimitedprefetchCount
- maximum number of messages that the server will deliver, 0 if unlimitedglobal
- true if the settings should be applied to the entire channel rather than each consumer- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Qos
-
basicQos
public void basicQos(int prefetchCount, boolean global) throws java.io.IOException
Public API - Request a specific prefetchCount "quality of service" settings for this channel.Note the prefetch count must be between 0 and 65535 (unsigned short in AMQP 0-9-1).
- Specified by:
basicQos
in interfaceChannel
- Parameters:
prefetchCount
- maximum number of messages that the server will deliver, 0 if unlimitedglobal
- true if the settings should be applied to the entire channel rather than each consumer- Throws:
java.io.IOException
- if an error is encountered- See Also:
Channel.basicQos(int, int, boolean)
-
basicQos
public void basicQos(int prefetchCount) throws java.io.IOException
Public API - Request a specific prefetchCount "quality of service" settings for this channel.Note the prefetch count must be between 0 and 65535 (unsigned short in AMQP 0-9-1).
- Specified by:
basicQos
in interfaceChannel
- Parameters:
prefetchCount
- maximum number of messages that the server will deliver, 0 if unlimited- Throws:
java.io.IOException
- if an error is encountered- See Also:
Channel.basicQos(int, int, boolean)
-
basicPublish
public void basicPublish(java.lang.String exchange, java.lang.String routingKey, AMQP.BasicProperties props, byte[] body) throws java.io.IOException
Public API - Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations ofChannel#basicPublish
will eventually block if a resource-driven alarm is in effect.- Specified by:
basicPublish
in interfaceChannel
- Parameters:
exchange
- the exchange to publish the message toroutingKey
- the routing keyprops
- other properties for the message - routing headers etcbody
- the message body- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Publish
, Resource-driven alarms
-
basicPublish
public void basicPublish(java.lang.String exchange, java.lang.String routingKey, boolean mandatory, AMQP.BasicProperties props, byte[] body) throws java.io.IOException
Public API - Publish a message. Invocations ofChannel#basicPublish
will eventually block if a resource-driven alarm is in effect.- Specified by:
basicPublish
in interfaceChannel
- Parameters:
exchange
- the exchange to publish the message toroutingKey
- the routing keymandatory
- true if the 'mandatory' flag is to be setprops
- other properties for the message - routing headers etcbody
- the message body- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Publish
, Resource-driven alarms
-
basicPublish
public void basicPublish(java.lang.String exchange, java.lang.String routingKey, boolean mandatory, boolean immediate, AMQP.BasicProperties props, byte[] body) throws java.io.IOException
Public API - Publish a message. Publishing to a non-existent exchange will result in a channel-level protocol exception, which closes the channel. Invocations ofChannel#basicPublish
will eventually block if a resource-driven alarm is in effect.- Specified by:
basicPublish
in interfaceChannel
- Parameters:
exchange
- the exchange to publish the message toroutingKey
- the routing keymandatory
- true if the 'mandatory' flag is to be setimmediate
- true if the 'immediate' flag is to be set. Note that the RabbitMQ server does not support this flag.props
- other properties for the message - routing headers etcbody
- the message body- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Publish
, Resource-driven alarms
-
exchangeDeclare
public AMQImpl.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, java.lang.String type, boolean durable, boolean autoDelete, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Declare an exchange.- Specified by:
exchangeDeclare
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange typedurable
- true if we are declaring a durable exchange (the exchange will survive a server restart)autoDelete
- true if the server should delete the exchange when it is no longer in usearguments
- other properties (construction arguments) for the exchange- Returns:
- a declaration-confirm method to indicate the exchange was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Declare
,AMQP.Exchange.DeclareOk
-
exchangeDeclare
public AMQImpl.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, BuiltinExchangeType type, boolean durable, boolean autoDelete, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Declare an exchange.- Specified by:
exchangeDeclare
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange typedurable
- true if we are declaring a durable exchange (the exchange will survive a server restart)autoDelete
- true if the server should delete the exchange when it is no longer in usearguments
- other properties (construction arguments) for the exchange- Returns:
- a declaration-confirm method to indicate the exchange was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Declare
,AMQP.Exchange.DeclareOk
-
exchangeDeclareNoWait
public void exchangeDeclareNoWait(java.lang.String exchange, java.lang.String type, boolean durable, boolean autoDelete, boolean internal, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Description copied from interface:Channel
LikeChannel.exchangeDeclare(String, String, boolean, boolean, java.util.Map)
but sets nowait parameter to true and returns nothing (as there will be no response from the server).- Specified by:
exchangeDeclareNoWait
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange typedurable
- true if we are declaring a durable exchange (the exchange will survive a server restart)autoDelete
- true if the server should delete the exchange when it is no longer in useinternal
- true if the exchange is internal, i.e. can't be directly published to by a client.arguments
- other properties (construction arguments) for the exchange- Throws:
java.io.IOException
- if an error is encountered
-
exchangeDeclareNoWait
public void exchangeDeclareNoWait(java.lang.String exchange, BuiltinExchangeType type, boolean durable, boolean autoDelete, boolean internal, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Description copied from interface:Channel
LikeChannel.exchangeDeclare(String, String, boolean, boolean, java.util.Map)
but sets nowait parameter to true and returns nothing (as there will be no response from the server).- Specified by:
exchangeDeclareNoWait
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange typedurable
- true if we are declaring a durable exchange (the exchange will survive a server restart)autoDelete
- true if the server should delete the exchange when it is no longer in useinternal
- true if the exchange is internal, i.e. can't be directly published to by a client.arguments
- other properties (construction arguments) for the exchange- Throws:
java.io.IOException
- if an error is encountered
-
exchangeDeclare
public AMQImpl.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, java.lang.String type, boolean durable, boolean autoDelete, boolean internal, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Declare an exchange, via an interface that allows the complete set of arguments.- Specified by:
exchangeDeclare
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange typedurable
- true if we are declaring a durable exchange (the exchange will survive a server restart)autoDelete
- true if the server should delete the exchange when it is no longer in useinternal
- true if the exchange is internal, i.e. can't be directly published to by a client.arguments
- other properties (construction arguments) for the exchange- Returns:
- a declaration-confirm method to indicate the exchange was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Declare
,AMQP.Exchange.DeclareOk
-
exchangeDeclare
public AMQImpl.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, BuiltinExchangeType type, boolean durable, boolean autoDelete, boolean internal, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Declare an exchange, via an interface that allows the complete set of arguments.- Specified by:
exchangeDeclare
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange typedurable
- true if we are declaring a durable exchange (the exchange will survive a server restart)autoDelete
- true if the server should delete the exchange when it is no longer in useinternal
- true if the exchange is internal, i.e. can't be directly published to by a client.arguments
- other properties (construction arguments) for the exchange- Returns:
- a declaration-confirm method to indicate the exchange was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Declare
,AMQP.Exchange.DeclareOk
-
exchangeDeclare
public AMQImpl.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, java.lang.String type, boolean durable) throws java.io.IOException
Public API - Actively declare a non-autodelete exchange with no extra arguments- Specified by:
exchangeDeclare
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange typedurable
- true if we are declaring a durable exchange (the exchange will survive a server restart)- Returns:
- a declaration-confirm method to indicate the exchange was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Declare
,AMQP.Exchange.DeclareOk
-
exchangeDeclare
public AMQImpl.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, BuiltinExchangeType type, boolean durable) throws java.io.IOException
Public API - Actively declare a non-autodelete exchange with no extra arguments- Specified by:
exchangeDeclare
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange typedurable
- true if we are declaring a durable exchange (the exchange will survive a server restart)- Returns:
- a declaration-confirm method to indicate the exchange was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Declare
,AMQP.Exchange.DeclareOk
-
exchangeDeclare
public AMQImpl.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, java.lang.String type) throws java.io.IOException
Public API - Actively declare a non-autodelete, non-durable exchange with no extra arguments- Specified by:
exchangeDeclare
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange type- Returns:
- a declaration-confirm method to indicate the exchange was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Declare
,AMQP.Exchange.DeclareOk
-
exchangeDeclare
public AMQImpl.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, BuiltinExchangeType type) throws java.io.IOException
Public API - Actively declare a non-autodelete, non-durable exchange with no extra arguments- Specified by:
exchangeDeclare
in interfaceChannel
- Parameters:
exchange
- the name of the exchangetype
- the exchange type- Returns:
- a declaration-confirm method to indicate the exchange was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Declare
,AMQP.Exchange.DeclareOk
-
exchangeDeclarePassive
public AMQImpl.Exchange.DeclareOk exchangeDeclarePassive(java.lang.String exchange) throws java.io.IOException
Public API - Declare an exchange passively; that is, check if the named exchange exists.- Specified by:
exchangeDeclarePassive
in interfaceChannel
- Parameters:
exchange
- check the existence of an exchange named this- Throws:
java.io.IOException
- the server will raise a 404 channel exception if the named exchange does not exist.
-
exchangeDelete
public AMQImpl.Exchange.DeleteOk exchangeDelete(java.lang.String exchange, boolean ifUnused) throws java.io.IOException
Public API - Delete an exchange- Specified by:
exchangeDelete
in interfaceChannel
- Parameters:
exchange
- the name of the exchangeifUnused
- true to indicate that the exchange is only to be deleted if it is unused- Returns:
- a deletion-confirm method to indicate the exchange was successfully deleted
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Delete
,AMQP.Exchange.DeleteOk
-
exchangeDeleteNoWait
public void exchangeDeleteNoWait(java.lang.String exchange, boolean ifUnused) throws java.io.IOException
Public API - LikeChannel.exchangeDelete(String, boolean)
but sets nowait parameter to true and returns void (as there will be no response from the server).- Specified by:
exchangeDeleteNoWait
in interfaceChannel
- Parameters:
exchange
- the name of the exchangeifUnused
- true to indicate that the exchange is only to be deleted if it is unused- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Delete
,AMQP.Exchange.DeleteOk
-
exchangeDelete
public AMQImpl.Exchange.DeleteOk exchangeDelete(java.lang.String exchange) throws java.io.IOException
Public API - Delete an exchange, without regard for whether it is in use or not- Specified by:
exchangeDelete
in interfaceChannel
- Parameters:
exchange
- the name of the exchange- Returns:
- a deletion-confirm method to indicate the exchange was successfully deleted
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Delete
,AMQP.Exchange.DeleteOk
-
exchangeBind
public AMQImpl.Exchange.BindOk exchangeBind(java.lang.String destination, java.lang.String source, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Bind an exchange to an exchange.- Specified by:
exchangeBind
in interfaceChannel
- Parameters:
destination
- the name of the exchange to which messages flow across the bindingsource
- the name of the exchange from which messages flow across the bindingroutingKey
- the routing key to use for the bindingarguments
- other properties (binding parameters)- Returns:
- a binding-confirm method if the binding was successfully created
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Bind
,AMQP.Exchange.BindOk
-
exchangeBindNoWait
public void exchangeBindNoWait(java.lang.String destination, java.lang.String source, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - LikeChannel.exchangeBind(String, String, String, java.util.Map)
but sets nowait parameter to true and returns void (as there will be no response from the server).- Specified by:
exchangeBindNoWait
in interfaceChannel
- Parameters:
destination
- the name of the exchange to which messages flow across the bindingsource
- the name of the exchange from which messages flow across the bindingroutingKey
- the routing key to use for the bindingarguments
- other properties (binding parameters)- Throws:
java.io.IOException
- if an error is encountered
-
exchangeBind
public AMQImpl.Exchange.BindOk exchangeBind(java.lang.String destination, java.lang.String source, java.lang.String routingKey) throws java.io.IOException
Public API - Bind an exchange to an exchange, with no extra arguments.- Specified by:
exchangeBind
in interfaceChannel
- Parameters:
destination
- the name of the exchange to which messages flow across the bindingsource
- the name of the exchange from which messages flow across the bindingroutingKey
- the routing key to use for the binding- Returns:
- a binding-confirm method if the binding was successfully created
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Bind
,AMQP.Exchange.BindOk
-
exchangeUnbind
public AMQImpl.Exchange.UnbindOk exchangeUnbind(java.lang.String destination, java.lang.String source, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Unbind an exchange from an exchange.- Specified by:
exchangeUnbind
in interfaceChannel
- Parameters:
destination
- the name of the exchange to which messages flow across the bindingsource
- the name of the exchange from which messages flow across the bindingroutingKey
- the routing key to use for the bindingarguments
- other properties (binding parameters)- Returns:
- a binding-confirm method if the binding was successfully created
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Bind
,AMQP.Exchange.BindOk
-
exchangeUnbind
public AMQImpl.Exchange.UnbindOk exchangeUnbind(java.lang.String destination, java.lang.String source, java.lang.String routingKey) throws java.io.IOException
Public API - Unbind an exchange from an exchange, with no extra arguments.- Specified by:
exchangeUnbind
in interfaceChannel
- Parameters:
destination
- the name of the exchange to which messages flow across the bindingsource
- the name of the exchange from which messages flow across the bindingroutingKey
- the routing key to use for the binding- Returns:
- a binding-confirm method if the binding was successfully created
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Exchange.Bind
,AMQP.Exchange.BindOk
-
exchangeUnbindNoWait
public void exchangeUnbindNoWait(java.lang.String destination, java.lang.String source, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Same asChannel.exchangeUnbind(String, String, String, java.util.Map)
but sets no-wait parameter to true and returns nothing (as there will be no response from the server).- Specified by:
exchangeUnbindNoWait
in interfaceChannel
- Parameters:
destination
- the name of the exchange to which messages flow across the bindingsource
- the name of the exchange from which messages flow across the bindingroutingKey
- the routing key to use for the bindingarguments
- other properties (binding parameters)- Throws:
java.io.IOException
- if an error is encountered
-
queueDeclare
public AMQImpl.Queue.DeclareOk queueDeclare(java.lang.String queue, boolean durable, boolean exclusive, boolean autoDelete, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Declare a queue- Specified by:
queueDeclare
in interfaceChannel
- Parameters:
queue
- the name of the queuedurable
- true if we are declaring a durable queue (the queue will survive a server restart)exclusive
- true if we are declaring an exclusive queue (restricted to this connection)autoDelete
- true if we are declaring an autodelete queue (server will delete it when no longer in use)arguments
- other properties (construction arguments) for the queue- Returns:
- a declaration-confirm method to indicate the queue was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Declare
,AMQP.Queue.DeclareOk
-
queueDeclare
public AMQP.Queue.DeclareOk queueDeclare() throws java.io.IOException
Public API - Actively declare a server-named exclusive, autodelete, non-durable queue. The name of the new queue is held in the "queue" field of theAMQP.Queue.DeclareOk
result.- Specified by:
queueDeclare
in interfaceChannel
- Returns:
- a declaration-confirm method to indicate the queue was successfully declared
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Declare
,AMQP.Queue.DeclareOk
-
queueDeclareNoWait
public void queueDeclareNoWait(java.lang.String queue, boolean durable, boolean exclusive, boolean autoDelete, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - LikeChannel.queueDeclare(String, boolean, boolean, boolean, java.util.Map)
but sets nowait flag to true and returns no result (as there will be no response from the server).- Specified by:
queueDeclareNoWait
in interfaceChannel
- Parameters:
queue
- the name of the queuedurable
- true if we are declaring a durable queue (the queue will survive a server restart)exclusive
- true if we are declaring an exclusive queue (restricted to this connection)autoDelete
- true if we are declaring an autodelete queue (server will delete it when no longer in use)arguments
- other properties (construction arguments) for the queue- Throws:
java.io.IOException
- if an error is encountered
-
queueDeclarePassive
public AMQImpl.Queue.DeclareOk queueDeclarePassive(java.lang.String queue) throws java.io.IOException
Public API - Declare a queue passively; i.e., check if it exists. In AMQP 0-9-1, all arguments aside from nowait are ignored; and sending nowait makes this method a no-op, so we default it to false.- Specified by:
queueDeclarePassive
in interfaceChannel
- Parameters:
queue
- the name of the queue- Returns:
- a declaration-confirm method to indicate the queue exists
- Throws:
java.io.IOException
- if an error is encountered, including if the queue does not exist and if the queue is exclusively owned by another connection.- See Also:
AMQP.Queue.Declare
,AMQP.Queue.DeclareOk
-
messageCount
public long messageCount(java.lang.String queue) throws java.io.IOException
Public API - Returns the number of messages in a queue ready to be delivered to consumers. This method assumes the queue exists. If it doesn't, the channels will be closed with an exception.- Specified by:
messageCount
in interfaceChannel
- Parameters:
queue
- the name of the queue- Returns:
- the number of messages in ready state
- Throws:
java.io.IOException
- Problem transmitting method.
-
consumerCount
public long consumerCount(java.lang.String queue) throws java.io.IOException
Public API - Returns the number of consumers on a queue. This method assumes the queue exists. If it doesn't, the channel will be closed with an exception.- Specified by:
consumerCount
in interfaceChannel
- Parameters:
queue
- the name of the queue- Returns:
- the number of consumers
- Throws:
java.io.IOException
- Problem transmitting method.
-
queueDelete
public AMQImpl.Queue.DeleteOk queueDelete(java.lang.String queue, boolean ifUnused, boolean ifEmpty) throws java.io.IOException
Public API - Delete a queue- Specified by:
queueDelete
in interfaceChannel
- Parameters:
queue
- the name of the queueifUnused
- true if the queue should be deleted only if not in useifEmpty
- true if the queue should be deleted only if empty- Returns:
- a deletion-confirm method to indicate the queue was successfully deleted
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Delete
,AMQP.Queue.DeleteOk
-
queueDeleteNoWait
public void queueDeleteNoWait(java.lang.String queue, boolean ifUnused, boolean ifEmpty) throws java.io.IOException
Description copied from interface:Channel
LikeChannel.queueDelete(String, boolean, boolean)
but sets nowait parameter to true and returns nothing (as there will be no response from the server).- Specified by:
queueDeleteNoWait
in interfaceChannel
- Parameters:
queue
- the name of the queueifUnused
- true if the queue should be deleted only if not in useifEmpty
- true if the queue should be deleted only if empty- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Delete
,AMQP.Queue.DeleteOk
-
queueDelete
public AMQImpl.Queue.DeleteOk queueDelete(java.lang.String queue) throws java.io.IOException
Public API - Delete a queue, without regard for whether it is in use or has messages on it- Specified by:
queueDelete
in interfaceChannel
- Parameters:
queue
- the name of the queue- Returns:
- a deletion-confirm method to indicate the queue was successfully deleted
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Delete
,AMQP.Queue.DeleteOk
-
queueBind
public AMQImpl.Queue.BindOk queueBind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Bind a queue to an exchange.- Specified by:
queueBind
in interfaceChannel
- Parameters:
queue
- the name of the queueexchange
- the name of the exchangeroutingKey
- the routing key to use for the bindingarguments
- other properties (binding parameters)- Returns:
- a binding-confirm method if the binding was successfully created
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Bind
,AMQP.Queue.BindOk
-
queueBind
public AMQImpl.Queue.BindOk queueBind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey) throws java.io.IOException
Public API - Bind a queue to an exchange, with no extra arguments.- Specified by:
queueBind
in interfaceChannel
- Parameters:
queue
- the name of the queueexchange
- the name of the exchangeroutingKey
- the routing key to use for the binding- Returns:
- a binding-confirm method if the binding was successfully created
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Bind
,AMQP.Queue.BindOk
-
queueBindNoWait
public void queueBindNoWait(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Same asChannel.queueBind(String, String, String, java.util.Map)
but sets nowait parameter to true and returns void (as there will be no response from the server).- Specified by:
queueBindNoWait
in interfaceChannel
- Parameters:
queue
- the name of the queueexchange
- the name of the exchangeroutingKey
- the routing key to use for the bindingarguments
- other properties (binding parameters)- Throws:
java.io.IOException
- if an error is encountered
-
queueUnbind
public AMQImpl.Queue.UnbindOk queueUnbind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey, java.util.Map<java.lang.String,java.lang.Object> arguments) throws java.io.IOException
Public API - Unbind a queue from an exchange.- Specified by:
queueUnbind
in interfaceChannel
- Parameters:
queue
- the name of the queueexchange
- the name of the exchangeroutingKey
- the routing key to use for the bindingarguments
- other properties (binding parameters)- Returns:
- an unbinding-confirm method if the binding was successfully deleted
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Unbind
,AMQP.Queue.UnbindOk
-
queuePurge
public AMQImpl.Queue.PurgeOk queuePurge(java.lang.String queue) throws java.io.IOException
Public API - Purges the contents of the given queue.- Specified by:
queuePurge
in interfaceChannel
- Parameters:
queue
- the name of the queue- Returns:
- a purge-confirm method if the purge was executed successfully
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Purge
,AMQP.Queue.PurgeOk
-
queueUnbind
public AMQImpl.Queue.UnbindOk queueUnbind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey) throws java.io.IOException
Public API - Unbinds a queue from an exchange, with no extra arguments.- Specified by:
queueUnbind
in interfaceChannel
- Parameters:
queue
- the name of the queueexchange
- the name of the exchangeroutingKey
- the routing key to use for the binding- Returns:
- an unbinding-confirm method if the binding was successfully deleted
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Queue.Unbind
,AMQP.Queue.UnbindOk
-
basicGet
public GetResponse basicGet(java.lang.String queue, boolean autoAck) throws java.io.IOException
Public API - Retrieve a message from a queue usingAMQP.Basic.Get
- Specified by:
basicGet
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgements- Returns:
- a
GetResponse
containing the retrieved message data - Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Get
,AMQP.Basic.GetOk
,AMQP.Basic.GetEmpty
-
basicAck
public void basicAck(long deliveryTag, boolean multiple) throws java.io.IOException
Public API - Acknowledge one or several received messages. Supply the deliveryTag from theAMQP.Basic.GetOk
orAMQP.Basic.Deliver
method containing the received message being acknowledged.- Specified by:
basicAck
in interfaceChannel
- Parameters:
deliveryTag
- the tag from the receivedAMQP.Basic.GetOk
orAMQP.Basic.Deliver
multiple
- true to acknowledge all messages up to and including the supplied delivery tag; false to acknowledge just the supplied delivery tag.- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Ack
-
basicNack
public void basicNack(long deliveryTag, boolean multiple, boolean requeue) throws java.io.IOException
Public API - Reject one or several received messages. Supply thedeliveryTag
from theAMQP.Basic.GetOk
orAMQP.Basic.Deliver
method containing the message to be rejected.- Specified by:
basicNack
in interfaceChannel
- Parameters:
deliveryTag
- the tag from the receivedAMQP.Basic.GetOk
orAMQP.Basic.Deliver
multiple
- true to reject all messages up to and including the supplied delivery tag; false to reject just the supplied delivery tag.requeue
- true if the rejected message(s) should be requeued rather than discarded/dead-lettered- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Nack
-
basicReject
public void basicReject(long deliveryTag, boolean requeue) throws java.io.IOException
Public API - Reject a message. Supply the deliveryTag from theAMQP.Basic.GetOk
orAMQP.Basic.Deliver
method containing the received message being rejected.- Specified by:
basicReject
in interfaceChannel
- Parameters:
deliveryTag
- the tag from the receivedAMQP.Basic.GetOk
orAMQP.Basic.Deliver
requeue
- true if the rejected message should be requeued rather than discarded/dead-lettered- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Reject
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, Consumer callback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with explicit acknowledgement and a server-generated consumerTag.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queuecallback
- an interface to the consumer object- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, DeliverCallback deliverCallback, CancelCallback cancelCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with explicit acknowledgement and a server-generated consumerTag. Provide access only tobasic.deliver
andbasic.cancel
AMQP methods (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queuedeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelled- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with explicit acknowledgement and a server-generated consumerTag. Provide access only tobasic.deliver
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queuedeliverCallback
- callback when a message is deliveredshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with explicit acknowledgement and a server-generated consumerTag. Provide access tobasic.deliver
,basic.cancel
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queuedeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelledshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, Consumer callback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementscallback
- an interface to the consumer object- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag. Provide access only tobasic.deliver
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsdeliverCallback
- callback when a message is deliveredshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, DeliverCallback deliverCallback, CancelCallback cancelCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag. Provide access only tobasic.deliver
andbasic.cancel
AMQP methods (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsdeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelled- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Description copied from interface:Channel
Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag. Provide access tobasic.deliver
,basic.cancel
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsdeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelledshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.util.Map<java.lang.String,java.lang.Object> arguments, Consumer callback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag and specified arguments.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsarguments
- a set of arguments for the consumecallback
- an interface to the consumer object- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, CancelCallback cancelCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag and specified arguments. Provide access only tobasic.deliver
andbasic.cancel
AMQP methods (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsarguments
- a set of arguments for the consumedeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelled- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag and specified arguments. Provide access only tobasic.deliver
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsarguments
- a set of arguments for the consumedeliverCallback
- callback when a message is deliveredshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag and specified arguments. Provide access tobasic.deliver
,basic.cancel
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsarguments
- a set of arguments for the consumedeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelledshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag generated by the server
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicAck(long, boolean)
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, Consumer callback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsconsumerTag
- a client-generated consumer tag to establish contextcallback
- an interface to the consumer object- Returns:
- the consumerTag associated with the new consumer
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, DeliverCallback deliverCallback, CancelCallback cancelCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer. Provide access only tobasic.deliver
andbasic.cancel
AMQP methods (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsconsumerTag
- a client-generated consumer tag to establish contextdeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelled- Returns:
- the consumerTag associated with the new consumer
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer. Provide access only tobasic.deliver
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsconsumerTag
- a client-generated consumer tag to establish contextdeliverCallback
- callback when a message is deliveredshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag associated with the new consumer
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Public API - Start a non-nolocal, non-exclusive consumer. Provide access tobasic.deliver
,basic.cancel
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsconsumerTag
- a client-generated consumer tag to establish contextdeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelledshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag associated with the new consumer
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
,Channel.basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, boolean noLocal, boolean exclusive, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, CancelCallback cancelCallback) throws java.io.IOException
Public API - Start a consumer. Calls the consumer'sConsumer.handleConsumeOk(java.lang.String)
method. Provide access only tobasic.deliver
andbasic.cancel
AMQP methods (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsconsumerTag
- a client-generated consumer tag to establish contextnoLocal
- True if the server should not deliver to this consumer messages published on this channel's connection. Note that the RabbitMQ server does not support this flag.exclusive
- true if this is an exclusive consumerarguments
- a set of arguments for the consumedeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelled- Returns:
- the consumerTag associated with the new consumer
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, boolean noLocal, boolean exclusive, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Public API - Start a consumer. Calls the consumer'sConsumer.handleConsumeOk(java.lang.String)
method. Provide access only tobasic.deliver
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsconsumerTag
- a client-generated consumer tag to establish contextnoLocal
- True if the server should not deliver to this consumer messages published on this channel's connection. Note that the RabbitMQ server does not support this flag.exclusive
- true if this is an exclusive consumerarguments
- a set of arguments for the consumedeliverCallback
- callback when a message is deliveredshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag associated with the new consumer
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, boolean noLocal, boolean exclusive, java.util.Map<java.lang.String,java.lang.Object> arguments, DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback) throws java.io.IOException
Description copied from interface:Channel
Start a consumer. Calls the consumer'sConsumer.handleConsumeOk(java.lang.String)
method. Provide access tobasic.deliver
,basic.cancel
and shutdown signal callbacks (which is sufficient for most cases). See methods with aConsumer
argument to have access to all the application callbacks.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsconsumerTag
- a client-generated consumer tag to establish contextnoLocal
- True if the server should not deliver to this consumer messages published on this channel's connection. Note that the RabbitMQ server does not support this flag.exclusive
- true if this is an exclusive consumerarguments
- a set of arguments for the consumedeliverCallback
- callback when a message is deliveredcancelCallback
- callback when the consumer is cancelledshutdownSignalCallback
- callback when the channel/connection is shut down- Returns:
- the consumerTag associated with the new consumer
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
-
basicConsume
public java.lang.String basicConsume(java.lang.String queue, boolean autoAck, java.lang.String consumerTag, boolean noLocal, boolean exclusive, java.util.Map<java.lang.String,java.lang.Object> arguments, Consumer callback) throws java.io.IOException
Public API - Start a consumer. Calls the consumer'sConsumer.handleConsumeOk(java.lang.String)
method.- Specified by:
basicConsume
in interfaceChannel
- Parameters:
queue
- the name of the queueautoAck
- true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgementsconsumerTag
- a client-generated consumer tag to establish contextnoLocal
- True if the server should not deliver to this consumer messages published on this channel's connection. Note that the RabbitMQ server does not support this flag.exclusive
- true if this is an exclusive consumerarguments
- a set of arguments for the consumecallback
- an interface to the consumer object- Returns:
- the consumerTag associated with the new consumer
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Basic.Consume
,AMQP.Basic.ConsumeOk
-
consumerFromDeliverCancelCallbacks
private Consumer consumerFromDeliverCancelCallbacks(DeliverCallback deliverCallback, CancelCallback cancelCallback)
-
consumerFromDeliverShutdownCallbacks
private Consumer consumerFromDeliverShutdownCallbacks(DeliverCallback deliverCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
-
consumerFromDeliverCancelShutdownCallbacks
private Consumer consumerFromDeliverCancelShutdownCallbacks(DeliverCallback deliverCallback, CancelCallback cancelCallback, ConsumerShutdownSignalCallback shutdownSignalCallback)
-
basicCancel
public void basicCancel(java.lang.String consumerTag) throws java.io.IOException
Public API - Cancel a consumer. Calls the consumer'sConsumer.handleCancelOk(java.lang.String)
method.- Specified by:
basicCancel
in interfaceChannel
- Parameters:
consumerTag
- a client- or server-generated consumer tag to establish context- Throws:
java.io.IOException
- if an error is encountered, or if the consumerTag is unknown- See Also:
AMQP.Basic.Cancel
,AMQP.Basic.CancelOk
-
basicRecover
public AMQImpl.Basic.RecoverOk basicRecover() throws java.io.IOException
Public API -Ask the broker to resend unacknowledged messages. In 0-8 basic.recover is asynchronous; in 0-9-1 it is synchronous, and the new, deprecated method basic.recover_async is asynchronous.
Equivalent to callingbasicRecover(true)
, messages will be requeued and possibly delivered to a different consumer.- Specified by:
basicRecover
in interfaceChannel
- Throws:
java.io.IOException
- See Also:
Channel.basicRecover(boolean)
-
basicRecover
public AMQImpl.Basic.RecoverOk basicRecover(boolean requeue) throws java.io.IOException
Public API - Ask the broker to resend unacknowledged messages. In 0-8 basic.recover is asynchronous; in 0-9-1 it is synchronous, and the new, deprecated method basic.recover_async is asynchronous.- Specified by:
basicRecover
in interfaceChannel
- Parameters:
requeue
- If true, messages will be requeued and possibly delivered to a different consumer. If false, messages will be redelivered to the same consumer.- Throws:
java.io.IOException
-
txSelect
public AMQImpl.Tx.SelectOk txSelect() throws java.io.IOException
Public API - Enables TX mode on this channel.- Specified by:
txSelect
in interfaceChannel
- Returns:
- a transaction-selection method to indicate the transaction was successfully initiated
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Tx.Select
,AMQP.Tx.SelectOk
-
txCommit
public AMQImpl.Tx.CommitOk txCommit() throws java.io.IOException
Public API - Commits a TX transaction on this channel.- Specified by:
txCommit
in interfaceChannel
- Returns:
- a transaction-commit method to indicate the transaction was successfully committed
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Tx.Commit
,AMQP.Tx.CommitOk
-
txRollback
public AMQImpl.Tx.RollbackOk txRollback() throws java.io.IOException
Public API - Rolls back a TX transaction on this channel.- Specified by:
txRollback
in interfaceChannel
- Returns:
- a transaction-rollback method to indicate the transaction was successfully rolled back
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Tx.Rollback
,AMQP.Tx.RollbackOk
-
confirmSelect
public AMQImpl.Confirm.SelectOk confirmSelect() throws java.io.IOException
Public API - Enables publisher acknowledgements on this channel.- Specified by:
confirmSelect
in interfaceChannel
- Throws:
java.io.IOException
- if an error is encountered- See Also:
AMQP.Confirm.Select
-
getNextPublishSeqNo
public long getNextPublishSeqNo()
Public API - When in confirm mode, returns the sequence number of the next message to be published.- Specified by:
getNextPublishSeqNo
in interfaceChannel
- Returns:
- the sequence number of the next message to be published
-
asyncRpc
public void asyncRpc(Method method) throws java.io.IOException
Description copied from interface:Channel
Asynchronously send a method over this channel.
-
rpc
public AMQCommand rpc(Method method) throws java.io.IOException
Description copied from class:AMQChannel
Protected API - sends aMethod
to the broker and waits for the next in-bound Command from the broker: only for use from non-connection-MainLoop threads!- Specified by:
rpc
in interfaceChannel
- Overrides:
rpc
in classAMQChannel
- Parameters:
method
- method to transmit over this channel.- Returns:
- command response to method. Caller should cast as appropriate.
- Throws:
java.io.IOException
- Problem transmitting method.
-
asyncCompletableRpc
public java.util.concurrent.CompletableFuture<Command> asyncCompletableRpc(Method method) throws java.io.IOException
Description copied from interface:Channel
Asynchronously send a method over this channel.- Specified by:
asyncCompletableRpc
in interfaceChannel
- Parameters:
method
- method to transmit over this channel.- Returns:
- a completable future that completes when the result is received
- Throws:
java.io.IOException
- Problem transmitting method.
-
enqueueRpc
public void enqueueRpc(AMQChannel.RpcContinuation k)
- Overrides:
enqueueRpc
in classAMQChannel
-
markRpcFinished
protected void markRpcFinished()
- Overrides:
markRpcFinished
in classAMQChannel
-
handleAckNack
private void handleAckNack(long seqNo, boolean multiple, boolean nack)
-
validateQueueNameLength
private static void validateQueueNameLength(java.lang.String queue)
-
-