com.rabbitmq.client.Channel |
Known Indirect Subclasses |
Public API: Interface to an AMQ channel. See the spec for details.
To open a channel,
Connection
conn = ...;Channel
channel = conn.createChannel
();
Public API:
While a Channel can be used by multiple threads, it's important to ensure that only one thread executes a command at once. Concurrent execution of commands will likely cause an UnexpectedFrameError to be thrown.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Abort this channel.
| |||||||||||
Abort this channel with the
com.rabbitmq.client.AMQP close code
and message 'OK'. | |||||||||||
Add a
ConfirmListener . | |||||||||||
Add a
FlowListener . | |||||||||||
Add a
ReturnListener . | |||||||||||
Asynchronously send a method over this channel.
| |||||||||||
Acknowledge one or several received
messages.
| |||||||||||
Cancel a consumer.
| |||||||||||
Start a non-nolocal, non-exclusive consumer.
| |||||||||||
Start a consumer.
| |||||||||||
Start a non-nolocal, non-exclusive consumer, with
a server-generated consumerTag.
| |||||||||||
Start a non-nolocal, non-exclusive consumer, with
explicit acknowledgement and a server-generated consumerTag.
| |||||||||||
Retrieve a message from a queue using com.rabbitmq.client.AMQP.Basic.Get
| |||||||||||
Reject one or several received messages.
| |||||||||||
Publish a message with both "mandatory" and "immediate" flags set to false
| |||||||||||
Publish a message
| |||||||||||
Request a specific prefetchCount "quality of service" settings
for this channel.
| |||||||||||
Request specific "quality of service" settings.
| |||||||||||
Ask the broker to resend unacknowledged messages.
| |||||||||||
Ask the broker to resend unacknowledged messages.
| |||||||||||
Ask the broker to resend unacknowledged messages.
| |||||||||||
Reject a message.
| |||||||||||
Remove all
ConfirmListener s. | |||||||||||
Remove all
FlowListener s. | |||||||||||
Remove all
ReturnListener s. | |||||||||||
Close this channel.
| |||||||||||
Close this channel with the
com.rabbitmq.client.AMQP close code
and message 'OK'. | |||||||||||
Enables publisher acknowledgements on this channel.
| |||||||||||
Bind an exchange to an exchange, with no extra arguments.
| |||||||||||
Bind an exchange to an exchange.
| |||||||||||
Actively declare a non-autodelete exchange with no extra arguments
| |||||||||||
Declare an exchange.
| |||||||||||
Declare an exchange, via an interface that allows the complete set of
arguments.
| |||||||||||
Actively declare a non-autodelete, non-durable exchange with no extra arguments
| |||||||||||
Declare an exchange passively; that is, check if the named exchange exists.
| |||||||||||
Delete an exchange
| |||||||||||
Delete an exchange, without regard for whether it is in use or not
| |||||||||||
Unbind an exchange from an exchange, with no extra arguments.
| |||||||||||
Unbind an exchange from an exchange.
| |||||||||||
Set flow on the channel
| |||||||||||
Retrieve this channel's channel number.
| |||||||||||
Retrieve the connection which carries this channel.
| |||||||||||
Get the current default consumer.
| |||||||||||
Return the current Channel.Flow settings.
| |||||||||||
When in confirm mode, returns the sequence number of the next
message to be published.
| |||||||||||
Bind a queue to an exchange.
| |||||||||||
Bind a queue to an exchange, with no extra arguments.
| |||||||||||
Declare a queue
| |||||||||||
Actively declare a server-named exclusive, autodelete, non-durable queue.
| |||||||||||
Declare a queue passively; i.e., check if it exists.
| |||||||||||
Delete a queue, without regard for whether it is in use or has messages on it
| |||||||||||
Delete a queue
| |||||||||||
Purges the contents of the given queue.
| |||||||||||
Unbind a queue from an exchange.
| |||||||||||
Unbinds a queue from an exchange, with no extra arguments.
| |||||||||||
Remove a
ConfirmListener . | |||||||||||
Remove a
FlowListener . | |||||||||||
Remove a
ReturnListener . | |||||||||||
Synchronously send a method over this channel.
| |||||||||||
Set the current default consumer.
| |||||||||||
Commits a TX transaction on this channel.
| |||||||||||
Rolls back a TX transaction on this channel.
| |||||||||||
Enables TX mode on this channel.
| |||||||||||
Wait until all messages published since the last call have been
either ack'd or nack'd by the broker.
| |||||||||||
Wait until all messages published since the last call have
been either ack'd or nack'd by the broker.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.rabbitmq.client.ShutdownNotifier
|
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.
IOException |
---|
Abort this channel with the com.rabbitmq.client.AMQP
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.
IOException |
---|
Add a ConfirmListener
.
listener | the listener to add |
---|
Add a FlowListener
.
listener | the listener to add |
---|
Add a ReturnListener
.
listener | the listener to add |
---|
Asynchronously send a method over this channel.
method | method to transmit over this channel. |
---|
IOException | Problem transmitting method. |
---|
Acknowledge one or several received messages. Supply the deliveryTag from the com.rabbitmq.client.AMQP.Basic.GetOk or com.rabbitmq.client.AMQP.Basic.Deliver method containing the received message being acknowledged.
deliveryTag | the tag from the received com.rabbitmq.client.AMQP.Basic.GetOk or com.rabbitmq.client.AMQP.Basic.Deliver |
---|---|
multiple | true to acknowledge all messages up to and including the supplied delivery tag; false to acknowledge just the supplied delivery tag. |
IOException | if an error is encountered |
---|
Cancel a consumer. Calls the consumer's handleCancelOk(String)
method.
consumerTag | a client- or server-generated consumer tag to establish context |
---|
IOException | if an error is encountered |
---|
Start a non-nolocal, non-exclusive consumer.
queue | the name of the queue |
---|---|
autoAck | true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgements |
consumerTag | a client-generated consumer tag to establish context |
callback | an interface to the consumer object |
IOException | if an error is encountered |
---|
basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
Start a consumer. Calls the consumer's handleConsumeOk(String)
method.
queue | the name of the queue |
---|---|
autoAck | true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgements |
consumerTag | a client-generated consumer tag to establish context |
noLocal | flag set to true unless server local buffering is required |
exclusive | true if this is an exclusive consumer |
arguments | a set of arguments for the consume |
callback | an interface to the consumer object |
IOException | if an error is encountered |
---|
Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag.
queue | the name of the queue |
---|---|
autoAck | true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgements |
callback | an interface to the consumer object |
IOException | if an error is encountered |
---|
basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
Start a non-nolocal, non-exclusive consumer, with explicit acknowledgement and a server-generated consumerTag.
queue | the name of the queue |
---|---|
callback | an interface to the consumer object |
IOException | if an error is encountered |
---|
basicAck(long, boolean)
basicConsume(String, boolean, String, boolean, boolean, Map, Consumer)
Retrieve a message from a queue using com.rabbitmq.client.AMQP.Basic.Get
queue | the name of the queue |
---|---|
autoAck | true if the server should consider messages acknowledged once delivered; false if the server should expect explicit acknowledgements |
GetResponse
containing the retrieved message dataIOException | if an error is encountered |
---|
Reject one or several received messages.
Supply the deliveryTag
from the com.rabbitmq.client.AMQP.Basic.GetOk
or com.rabbitmq.client.AMQP.Basic.GetOk method containing the message to be rejected.
deliveryTag | the tag from the received com.rabbitmq.client.AMQP.Basic.GetOk or com.rabbitmq.client.AMQP.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 |
IOException | if an error is encountered |
---|
Publish a message with both "mandatory" and "immediate" flags set to false
exchange | the exchange to publish the message to |
---|---|
routingKey | the routing key |
props | other properties for the message - routing headers etc |
body | the message body |
IOException | if an error is encountered |
---|
Publish a message
exchange | the exchange to publish the message to |
---|---|
routingKey | the routing key |
mandatory | true if we are requesting a mandatory publish |
immediate | true if we are requesting an immediate publish |
props | other properties for the message - routing headers etc |
body | the message body |
IOException | if an error is encountered |
---|
Request a specific prefetchCount "quality of service" settings for this channel.
prefetchCount | maximum number of messages that the server will deliver, 0 if unlimited |
---|
IOException | if an error is encountered |
---|
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.
prefetchSize | maximum amount of content (measured in octets) that the server will deliver, 0 if unlimited |
---|---|
prefetchCount | maximum number of messages that the server will deliver, 0 if unlimited |
global | true if the settings should be applied to the entire connection rather than just the current channel |
IOException | if an error is encountered |
---|
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. IOException |
---|
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.
requeue | If true, messages will be requeued and possibly delivered to a different consumer. If false, messages will be redelivered to the same consumer. |
---|
IOException |
---|
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 and deprecated.
requeue | If true, messages will be requeued and possibly delivered to a different consumer. If false, messages will be redelivered to the same consumer. |
---|
IOException |
---|
Reject a message. Supply the deliveryTag from the com.rabbitmq.client.AMQP.Basic.GetOk or com.rabbitmq.client.AMQP.Basic.Deliver method containing the received message being rejected.
deliveryTag | the tag from the received com.rabbitmq.client.AMQP.Basic.GetOk or com.rabbitmq.client.AMQP.Basic.Deliver |
---|---|
requeue | true if the rejected message should be requeued rather than discarded/dead-lettered |
IOException | if an error is encountered |
---|
Close this channel.
closeCode | the close code (See under "Reply Codes" in the AMQP specification) |
---|---|
closeMessage | a message indicating the reason for closing the connection |
IOException | if an error is encountered |
---|
Close this channel with the com.rabbitmq.client.AMQP
close code
and message 'OK'.
IOException | if an error is encountered |
---|
Enables publisher acknowledgements on this channel.
IOException | if an error is encountered |
---|
Bind an exchange to an exchange, with no extra arguments.
IOException | if an error is encountered |
---|
Bind an exchange to an exchange.
IOException | if an error is encountered |
---|
Actively declare a non-autodelete exchange with no extra arguments
exchange | the name of the exchange |
---|---|
type | the exchange type |
durable | true if we are declaring a durable exchange (the exchange will survive a server restart) |
IOException | if an error is encountered |
---|
Declare an exchange.
exchange | the name of the exchange |
---|---|
type | the exchange type |
durable | 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 use |
arguments | other properties (construction arguments) for the exchange |
IOException | if an error is encountered |
---|
Declare an exchange, via an interface that allows the complete set of arguments.
exchange | the name of the exchange |
---|---|
type | the exchange type |
durable | 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 use |
internal | 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 |
IOException | if an error is encountered |
---|
Actively declare a non-autodelete, non-durable exchange with no extra arguments
exchange | the name of the exchange |
---|---|
type | the exchange type |
IOException | if an error is encountered |
---|
Declare an exchange passively; that is, check if the named exchange exists.
name | check the existence of an exchange named this |
---|
IOException | the server will raise a 404 channel exception if the named exchange does not exist. |
---|
Delete an exchange
exchange | the name of the exchange |
---|---|
ifUnused | true to indicate that the exchange is only to be deleted if it is unused |
IOException | if an error is encountered |
---|
Delete an exchange, without regard for whether it is in use or not
exchange | the name of the exchange |
---|
IOException | if an error is encountered |
---|
Unbind an exchange from an exchange, with no extra arguments.
IOException | if an error is encountered |
---|
Unbind an exchange from an exchange.
IOException | if an error is encountered |
---|
Set flow on the channel
active | if true, the server is asked to start sending. If false, the server is asked to stop sending. |
---|
IOException |
---|
Retrieve this channel's channel number.
Retrieve the connection which carries this channel.
Connection
Get the current default consumer. @see setDefaultConsumer for rationale.
Return the current Channel.Flow settings.
When in confirm mode, returns the sequence number of the next message to be published.
Bind a queue to an exchange.
queue | the name of the queue |
---|---|
exchange | the name of the exchange |
routingKey | the routine key to use for the binding |
arguments | other properties (binding parameters) |
IOException | if an error is encountered |
---|
Bind a queue to an exchange, with no extra arguments.
queue | the name of the queue |
---|---|
exchange | the name of the exchange |
routingKey | the routine key to use for the binding |
IOException | if an error is encountered |
---|
Declare a queue
queue | the name of the queue |
---|---|
durable | 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 |
IOException | if an error is encountered |
---|
Actively declare a server-named exclusive, autodelete, non-durable queue. The name of the new queue is held in the "queue" field of the com.rabbitmq.client.AMQP.Queue.DeclareOk result.
IOException | if an error is encountered |
---|
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.
queue | the name of the queue |
---|
IOException | if an error is encountered, including if the queue does not exist and if the queue is exclusively owned by another connection. |
---|
Delete a queue, without regard for whether it is in use or has messages on it
queue | the name of the queue |
---|
IOException | if an error is encountered |
---|
Delete a queue
queue | the name of the queue |
---|---|
ifUnused | true if the queue should be deleted only if not in use |
ifEmpty | true if the queue should be deleted only if empty |
IOException | if an error is encountered |
---|
Purges the contents of the given queue.
queue | the name of the queue |
---|
IOException | if an error is encountered |
---|
Unbind a queue from an exchange.
queue | the name of the queue |
---|---|
exchange | the name of the exchange |
routingKey | the routine key to use for the binding |
arguments | other properties (binding parameters) |
IOException | if an error is encountered |
---|
Unbinds a queue from an exchange, with no extra arguments.
queue | the name of the queue |
---|---|
exchange | the name of the exchange |
routingKey | the routine key to use for the binding |
IOException | if an error is encountered |
---|
Remove a ConfirmListener
.
listener | the listener to remove |
---|
true
if the listener was found and removed,
false
otherwise
Remove a FlowListener
.
listener | the listener to remove |
---|
true
if the listener was found and removed,
false
otherwise
Remove a ReturnListener
.
listener | the listener to remove |
---|
true
if the listener was found and removed,
false
otherwise
Synchronously send a method over this channel.
method | method to transmit over this channel. |
---|
IOException | Problem transmitting method. |
---|
Set the current default consumer. Under certain circumstances it is possible for a channel to receive a message delivery which does not match any consumer which is currently set up via basicConsume(). This will occur after the following sequence of events: ctag = basicConsume(queue, consumer); // i.e. with explicit acks // some deliveries take place but are not acked basicCancel(ctag); basicRecover(false); Since requeue is specified to be false in the basicRecover, the spec states that the message must be redelivered to "the original recipient" - i.e. the same channel / consumer-tag. But the consumer is no longer active. In these circumstances, you can register a default consumer to handle such deliveries. If no default consumer is registered an IllegalStateException will be thrown when such a delivery arrives. Most people will not need to use this.
consumer | the consumer to use, or null indicating "don't use one". |
---|
Commits a TX transaction on this channel.
IOException | if an error is encountered |
---|
Rolls back a TX transaction on this channel.
IOException | if an error is encountered |
---|
Enables TX mode on this channel.
IOException | if an error is encountered |
---|
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 returns true immediately.
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 return immediately.
IOException | |
---|---|
InterruptedException |