public class ExclusiveQueueWithBinding extends Object implements QueueDeclaration
AMQPSpout: if your app already publishes
to an exchange, you can just point this at the exchange and start consuming
messages.
However N.B. this queue setup is not reliable, in that if the spout task crashes or restarts, messages published while the spout is down will be lost (because the spout creates the queue when it starts up, and the server deletes the queue when the spout closes).
It also cannot scale out to multiple parallel spout tasks. The semantics of an exclusive queue mean that each spout task would get its own queue bound to the exchange. That means each task would receive a copy of every message, so messages would get processed multiple times.
If you need guaranteed processing or a horizontally scalable spout,
consider SharedQueueWithBinding.
| Constructor and Description |
|---|
ExclusiveQueueWithBinding(String exchange,
String routingKey)
Create a declaration of an exclusive server-named queue bound to the
specified exchange.
|
| Modifier and Type | Method and Description |
|---|---|
AMQP.Queue.DeclareOk |
declare(Channel channel)
Verifies the exchange exists, creates an exclusive, server-named queue
and binds it to the exchange.
|
boolean |
isParallelConsumable()
Returns false as this queue is not safe for parallel
consumers.
|
public ExclusiveQueueWithBinding(String exchange, String routingKey)
exchange - exchange to bind the queue to.routingKey - routing key for the exchange binding. Use "#" to
receive all messages published to the exchange.public AMQP.Queue.DeclareOk declare(Channel channel) throws IOException
declare in interface QueueDeclarationchannel - An open AMQP channel which can be used to send the
declarations.IOException - if the exchange does not exist, or if the AMQP
connection drops.public boolean isParallelConsumable()
isParallelConsumable in interface QueueDeclarationCopyright © 2016. All rights reserved.