|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Channel
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.
Method Summary | |
---|---|
void |
abort()
Abort this channel with the AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
abort(int closeCode,
java.lang.String closeMessage)
Abort this channel. |
void |
basicAck(long deliveryTag,
boolean multiple)
Acknowledge one or several received messages. |
void |
basicCancel(java.lang.String consumerTag)
Cancel a consumer. |
java.lang.String |
basicConsume(java.lang.String queue,
boolean noAck,
Consumer callback)
Start a non-nolocal, non-exclusive consumer, with a server-generated consumerTag. |
java.lang.String |
basicConsume(java.lang.String queue,
boolean noAck,
java.lang.String consumerTag,
boolean noLocal,
boolean exclusive,
Consumer callback)
Start a consumer. |
java.lang.String |
basicConsume(java.lang.String queue,
boolean noAck,
java.lang.String consumerTag,
Consumer callback)
Start a non-nolocal, non-exclusive consumer. |
java.lang.String |
basicConsume(java.lang.String queue,
Consumer callback)
Start a non-nolocal, non-exclusive consumer, with explicit acknowledgements required and a server-generated consumerTag. |
GetResponse |
basicGet(java.lang.String queue,
boolean noAck)
Retrieve a message from a queue using AMQP.Basic.Get |
void |
basicPublish(java.lang.String exchange,
java.lang.String routingKey,
AMQP.BasicProperties props,
byte[] body)
Publish a message with both "mandatory" and "immediate" flags set to false |
void |
basicPublish(java.lang.String exchange,
java.lang.String routingKey,
boolean mandatory,
boolean immediate,
AMQP.BasicProperties props,
byte[] body)
Publish a message |
void |
basicQos(int prefetchCount)
Request a specific prefetchCount "quality of service" settings for this channel. |
void |
basicQos(int prefetchSize,
int prefetchCount,
boolean global)
Request specific "quality of service" settings. |
AMQP.Basic.RecoverOk |
basicRecover(boolean requeue)
Ask the broker to resend unacknowledged messages. |
void |
basicRecoverAsync(boolean requeue)
Deprecated. |
void |
close()
Close this channel with the AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
close(int closeCode,
java.lang.String closeMessage)
Close this channel. |
AMQP.Exchange.DeclareOk |
exchangeDeclare(java.lang.String exchange,
java.lang.String type)
Actively declare a non-autodelete, non-durable exchange with no extra arguments |
AMQP.Exchange.DeclareOk |
exchangeDeclare(java.lang.String exchange,
java.lang.String type,
boolean durable)
Actively declare a non-autodelete exchange with no extra arguments |
AMQP.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)
Declare an exchange, via an interface that allows the complete set of arguments. |
AMQP.Exchange.DeclareOk |
exchangeDeclarePassive(java.lang.String name)
Declare an exchange passively; that is, check if the named exchange exists. |
AMQP.Exchange.DeleteOk |
exchangeDelete(java.lang.String exchange)
Delete an exchange, without regard for whether it is in use or not |
AMQP.Exchange.DeleteOk |
exchangeDelete(java.lang.String exchange,
boolean ifUnused)
Delete an exchange |
AMQP.Channel.FlowOk |
flow(boolean active)
Set flow on the channel |
int |
getChannelNumber()
Retrieve this channel's channel number. |
Connection |
getConnection()
Retrieve the connection which carries this channel. |
Consumer |
getDefaultConsumer()
Get the current default consumer. |
AMQP.Channel.FlowOk |
getFlow()
Return the current Channel.Flow settings. |
FlowListener |
getFlowListener()
Return the current FlowListener . |
ReturnListener |
getReturnListener()
Return the current ReturnListener . |
AMQP.Queue.BindOk |
queueBind(java.lang.String queue,
java.lang.String exchange,
java.lang.String routingKey)
Bind a queue to an exchange, with no extra arguments. |
AMQP.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)
Bind a queue to an exchange. |
AMQP.Queue.DeclareOk |
queueDeclare()
Actively declare a server-named exclusive, autodelete, non-durable queue. |
AMQP.Queue.DeclareOk |
queueDeclare(java.lang.String queue,
boolean durable,
boolean exclusive,
boolean autoDelete,
java.util.Map<java.lang.String,java.lang.Object> arguments)
Declare a queue |
AMQP.Queue.DeclareOk |
queueDeclarePassive(java.lang.String queue)
Declare a queue passively; i.e., check if it exists. |
AMQP.Queue.DeleteOk |
queueDelete(java.lang.String queue)
Delete a queue, without regard for whether it is in use or has messages on it |
AMQP.Queue.DeleteOk |
queueDelete(java.lang.String queue,
boolean ifUnused,
boolean ifEmpty)
Delete a queue |
AMQP.Queue.PurgeOk |
queuePurge(java.lang.String queue)
Purges the contents of the given queue and awaits a completion. |
AMQP.Queue.PurgeOk |
queuePurge(java.lang.String queue,
boolean nowait)
Purges the contents of the given queue. |
AMQP.Queue.UnbindOk |
queueUnbind(java.lang.String queue,
java.lang.String exchange,
java.lang.String routingKey)
Unbinds a queue from an exchange, with no extra arguments. |
AMQP.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)
Unbind a queue from an exchange. |
void |
setDefaultConsumer(Consumer consumer)
Set the current default consumer. |
void |
setFlowListener(FlowListener listener)
Set the current FlowListener . |
void |
setReturnListener(ReturnListener listener)
Set the current ReturnListener . |
AMQP.Tx.CommitOk |
txCommit()
Commits a TX transaction on this channel. |
AMQP.Tx.RollbackOk |
txRollback()
Rolls back a TX transaction on this channel. |
AMQP.Tx.SelectOk |
txSelect()
Enables TX mode on this channel. |
Methods inherited from interface com.rabbitmq.client.ShutdownNotifier |
---|
addShutdownListener, getCloseReason, isOpen, notifyListeners, removeShutdownListener |
Method Detail |
---|
int getChannelNumber()
Connection getConnection()
Connection
void close() throws java.io.IOException
AMQP.REPLY_SUCCESS
close code
and message 'OK'.
java.io.IOException
- if an error is encounteredvoid close(int closeCode, java.lang.String closeMessage) throws java.io.IOException
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connection
java.io.IOException
- if an error is encounteredAMQP.Channel.FlowOk flow(boolean active) throws java.io.IOException
active
- if true, the server is asked to start sending. If false, the server is asked to stop sending.
java.io.IOException
AMQP.Channel.FlowOk getFlow()
void abort() throws java.io.IOException
AMQP.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.
java.io.IOException
void abort(int closeCode, java.lang.String closeMessage) throws java.io.IOException
java.io.IOException
ReturnListener getReturnListener()
ReturnListener
.
void setReturnListener(ReturnListener listener)
ReturnListener
.
listener
- the listener to use, or null indicating "don't use one".FlowListener getFlowListener()
FlowListener
.
void setFlowListener(FlowListener listener)
FlowListener
.
listener
- the listener to use, or null indicating "don't use one".Consumer getDefaultConsumer()
void setDefaultConsumer(Consumer consumer)
consumer
- the consumer to use, or null indicating "don't use one".void basicQos(int prefetchSize, int prefetchCount, boolean global) throws java.io.IOException
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 connection rather than just the current channel
java.io.IOException
- if an error is encounteredAMQP.Basic.Qos
void basicQos(int prefetchCount) throws java.io.IOException
prefetchCount
- maximum number of messages that the server
will deliver, 0 if unlimited
java.io.IOException
- if an error is encounteredbasicQos(int, int, boolean)
void basicPublish(java.lang.String exchange, java.lang.String routingKey, AMQP.BasicProperties props, byte[] body) throws java.io.IOException
exchange
- the exchange to publish the message toroutingKey
- the routing keyprops
- other properties for the message - routing headers etcbody
- the message body
java.io.IOException
- if an error is encounteredAMQP.Basic.Publish
void basicPublish(java.lang.String exchange, java.lang.String routingKey, boolean mandatory, boolean immediate, AMQP.BasicProperties props, byte[] body) throws java.io.IOException
exchange
- the exchange to publish the message toroutingKey
- the routing keymandatory
- true if we are requesting a mandatory publishimmediate
- true if we are requesting an immediate publishprops
- other properties for the message - routing headers etcbody
- the message body
java.io.IOException
- if an error is encounteredAMQP.Basic.Publish
AMQP.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, java.lang.String type) throws java.io.IOException
exchange
- the name of the exchangetype
- the exchange type
java.io.IOException
- if an error is encounteredAMQP.Exchange.Declare
,
AMQP.Exchange.DeclareOk
AMQP.Exchange.DeclareOk exchangeDeclare(java.lang.String exchange, java.lang.String type, boolean durable) throws java.io.IOException
exchange
- the name of the exchangetype
- the exchange typedurable
- true if we are declaring a durable exchange (the exchange will survive a server restart)
java.io.IOException
- if an error is encounteredAMQP.Exchange.Declare
,
AMQP.Exchange.DeclareOk
AMQP.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
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
java.io.IOException
- if an error is encounteredAMQP.Exchange.Declare
,
AMQP.Exchange.DeclareOk
AMQP.Exchange.DeclareOk exchangeDeclarePassive(java.lang.String name) throws java.io.IOException
name
- check the existence of an exchange named this
java.io.IOException
- the server will raise a 404 channel exception if the named exchange does not exist.AMQP.Exchange.DeleteOk exchangeDelete(java.lang.String exchange, boolean ifUnused) throws java.io.IOException
exchange
- the name of the exchangeifUnused
- true to indicate that the exchange is only to be deleted if it is unused
java.io.IOException
- if an error is encounteredAMQP.Exchange.Delete
,
AMQP.Exchange.DeleteOk
AMQP.Exchange.DeleteOk exchangeDelete(java.lang.String exchange) throws java.io.IOException
exchange
- the name of the exchange
java.io.IOException
- if an error is encounteredAMQP.Exchange.Delete
,
AMQP.Exchange.DeleteOk
AMQP.Queue.DeclareOk queueDeclare() throws java.io.IOException
AMQP.Queue.DeclareOk
result.
java.io.IOException
- if an error is encounteredAMQP.Queue.Declare
,
AMQP.Queue.DeclareOk
AMQP.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
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
java.io.IOException
- if an error is encounteredAMQP.Queue.Declare
,
AMQP.Queue.DeclareOk
AMQP.Queue.DeclareOk queueDeclarePassive(java.lang.String queue) throws java.io.IOException
queue
- the name of the queue
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.AMQP.Queue.Declare
,
AMQP.Queue.DeclareOk
AMQP.Queue.DeleteOk queueDelete(java.lang.String queue) throws java.io.IOException
queue
- the name of the queue
java.io.IOException
- if an error is encounteredAMQP.Queue.Delete
,
AMQP.Queue.DeleteOk
AMQP.Queue.DeleteOk queueDelete(java.lang.String queue, boolean ifUnused, boolean ifEmpty) throws java.io.IOException
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
java.io.IOException
- if an error is encounteredAMQP.Queue.Delete
,
AMQP.Queue.DeleteOk
AMQP.Queue.BindOk queueBind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey) throws java.io.IOException
queue
- the name of the queueexchange
- the name of the exchangeroutingKey
- the routine key to use for the binding
java.io.IOException
- if an error is encounteredAMQP.Queue.Bind
,
AMQP.Queue.BindOk
AMQP.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
queue
- the name of the queueexchange
- the name of the exchangeroutingKey
- the routine key to use for the bindingarguments
- other properties (binding parameters)
java.io.IOException
- if an error is encounteredAMQP.Queue.Bind
,
AMQP.Queue.BindOk
AMQP.Queue.UnbindOk queueUnbind(java.lang.String queue, java.lang.String exchange, java.lang.String routingKey) throws java.io.IOException
queue
- the name of the queueexchange
- the name of the exchangeroutingKey
- the routine key to use for the binding
java.io.IOException
- if an error is encounteredAMQP.Queue.Unbind
,
AMQP.Queue.UnbindOk
AMQP.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
queue
- the name of the queueexchange
- the name of the exchangeroutingKey
- the routine key to use for the bindingarguments
- other properties (binding parameters)
java.io.IOException
- if an error is encounteredAMQP.Queue.Unbind
,
AMQP.Queue.UnbindOk
AMQP.Queue.PurgeOk queuePurge(java.lang.String queue) throws java.io.IOException
queue
- the name of the queue
java.io.IOException
- if an error is encounteredAMQP.Queue.Purge
,
AMQP.Queue.PurgeOk
AMQP.Queue.PurgeOk queuePurge(java.lang.String queue, boolean nowait) throws java.io.IOException
queue
- the name of the queuenowait
- whether to await completion of the purge
java.io.IOException
- if an error is encounteredAMQP.Queue.Purge
,
AMQP.Queue.PurgeOk
GetResponse basicGet(java.lang.String queue, boolean noAck) throws java.io.IOException
AMQP.Basic.Get
queue
- the name of the queuenoAck
- true if no handshake is required
GetResponse
containing the retrieved message data
java.io.IOException
- if an error is encounteredAMQP.Basic.Get
,
AMQP.Basic.GetOk
,
AMQP.Basic.GetEmpty
void basicAck(long deliveryTag, boolean multiple) throws java.io.IOException
AMQP.Basic.GetOk
or AMQP.Basic.Deliver
method
containing the received message being acknowledged.
deliveryTag
- the tag from the received AMQP.Basic.GetOk
or AMQP.Basic.Deliver
multiple
- true if we are acknowledging multiple messages with the same delivery tag
java.io.IOException
- if an error is encounteredAMQP.Basic.Ack
java.lang.String basicConsume(java.lang.String queue, Consumer callback) throws java.io.IOException
queue
- the name of the queuecallback
- an interface to the consumer object
java.io.IOException
- if an error is encounteredAMQP.Basic.Consume
,
AMQP.Basic.ConsumeOk
,
basicAck(long, boolean)
,
basicConsume(String,boolean, String,boolean,boolean, Consumer)
java.lang.String basicConsume(java.lang.String queue, boolean noAck, Consumer callback) throws java.io.IOException
queue
- the name of the queuenoAck
- true if no handshake is requiredcallback
- an interface to the consumer object
java.io.IOException
- if an error is encounteredAMQP.Basic.Consume
,
AMQP.Basic.ConsumeOk
,
basicConsume(String,boolean, String,boolean,boolean, Consumer)
java.lang.String basicConsume(java.lang.String queue, boolean noAck, java.lang.String consumerTag, Consumer callback) throws java.io.IOException
queue
- the name of the queuenoAck
- true if no handshake is requiredconsumerTag
- a client-generated consumer tag to establish contextcallback
- an interface to the consumer object
java.io.IOException
- if an error is encounteredAMQP.Basic.Consume
,
AMQP.Basic.ConsumeOk
,
basicConsume(String,boolean, String,boolean,boolean, Consumer)
java.lang.String basicConsume(java.lang.String queue, boolean noAck, java.lang.String consumerTag, boolean noLocal, boolean exclusive, Consumer callback) throws java.io.IOException
Consumer.handleConsumeOk(java.lang.String)
method before returning.
queue
- the name of the queuenoAck
- true if no handshake is requiredconsumerTag
- a client-generated consumer tag to establish contextnoLocal
- flag set to true unless server local buffering is requiredexclusive
- true if this is an exclusive consumercallback
- an interface to the consumer object
java.io.IOException
- if an error is encounteredAMQP.Basic.Consume
,
AMQP.Basic.ConsumeOk
void basicCancel(java.lang.String consumerTag) throws java.io.IOException
Consumer.handleCancelOk(java.lang.String)
method before returning.
consumerTag
- a client- or server-generated consumer tag to establish context
java.io.IOException
- if an error is encounteredAMQP.Basic.Cancel
,
AMQP.Basic.CancelOk
AMQP.Basic.RecoverOk basicRecover(boolean requeue) throws java.io.IOException
requeue
- If true, messages will be requeued and possibly
delivered to a different consumer. If false, messages will be
redelivered to the same consumer.
java.io.IOException
@Deprecated void basicRecoverAsync(boolean requeue) throws java.io.IOException
requeue
- If true, messages will be requeued and possibly
delivered to a different consumer. If false, messages will be
redelivered to the same consumer.
java.io.IOException
AMQP.Tx.SelectOk txSelect() throws java.io.IOException
java.io.IOException
- if an error is encounteredAMQP.Tx.Select
,
AMQP.Tx.SelectOk
AMQP.Tx.CommitOk txCommit() throws java.io.IOException
java.io.IOException
- if an error is encounteredAMQP.Tx.Commit
,
AMQP.Tx.CommitOk
AMQP.Tx.RollbackOk txRollback() throws java.io.IOException
java.io.IOException
- if an error is encounteredAMQP.Tx.Rollback
,
AMQP.Tx.RollbackOk
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |