Package org.ow2.joram.mom.amqp
Class DirectExchange
- java.lang.Object
-
- org.ow2.joram.mom.amqp.IExchange
-
- org.ow2.joram.mom.amqp.DirectExchange
-
- All Implemented Interfaces:
Externalizable,Serializable,IExchangeMBean
public class DirectExchange extends IExchange
The direct exchange type provides routing of messages to zero or more queues based on an exact match between the routing key of the message, and the binding key used to bind the queue to the exchange. This can be used to construct the classic point-to-point queue based messaging model, however, as with any of the defined exchange types, a message may end up in multiple queues when multiple binding keys match the message's routing key.
The direct exchange type works as follows:- 1. A message queue is bound to the exchange using a binding key, K.
- 2. A publisher sends the exchange a message with the routing key R.
- 3. The message is passed to all message queues bound to the exchange with key K where K = R.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Map<String,Set<String>>bindingsstatic StringDEFAULT_NAMEstatic Loggerloggerprivate static longserialVersionUIDdefine serialVersionUID for interoperabilitystatic StringTYPE-
Fields inherited from class org.ow2.joram.mom.amqp.IExchange
DEFAULT_EXCHANGE_NAME, durable, name, PREFIX_EXCHANGE
-
-
Constructor Summary
Constructors Constructor Description DirectExchange()DirectExchange(String name, boolean durable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(String queueName, String routingKey, Map<String,Object> arguments)voiddoPublish(String routingKey, boolean mandatory, boolean immediate, AMQP.Basic.BasicProperties properties, byte[] body, int channelNumber, short serverId, long proxyId)Set<String>getBoundQueues()StringgetType()booleanisUnused()voidreadExternal(ObjectInput in)voidremoveQueueBindings(String queueName)voidsetArguments(Map<String,Object> arguments)voidunbind(String queueName, String routingKey, Map<String,Object> arguments)voidwriteExternal(ObjectOutput out)-
Methods inherited from class org.ow2.joram.mom.amqp.IExchange
checkPublication, createExchange, deleteExchange, getHandledMessageCount, getName, getPublishedMessageCount, isDurable, loadExchange, publish, publishToQueue, saveExchange
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
define serialVersionUID for interoperability- See Also:
- Constant Field Values
-
logger
public static final Logger logger
-
DEFAULT_NAME
public static final String DEFAULT_NAME
- See Also:
- Constant Field Values
-
TYPE
public static final String TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DirectExchange
public DirectExchange()
-
DirectExchange
public DirectExchange(String name, boolean durable)
-
-
Method Detail
-
unbind
public void unbind(String queueName, String routingKey, Map<String,Object> arguments) throws NotFoundException
- Specified by:
unbindin classIExchange- Throws:
NotFoundException
-
doPublish
public void doPublish(String routingKey, boolean mandatory, boolean immediate, AMQP.Basic.BasicProperties properties, byte[] body, int channelNumber, short serverId, long proxyId) throws NotFoundException, NoConsumersException, TransactionException
- Specified by:
doPublishin classIExchange- Throws:
NotFoundExceptionNoConsumersExceptionTransactionException
-
setArguments
public void setArguments(Map<String,Object> arguments)
- Specified by:
setArgumentsin classIExchange
-
getType
public String getType()
-
removeQueueBindings
public void removeQueueBindings(String queueName)
- Specified by:
removeQueueBindingsin classIExchange
-
getBoundQueues
public Set<String> getBoundQueues()
- Specified by:
getBoundQueuesin interfaceIExchangeMBean- Specified by:
getBoundQueuesin classIExchange
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Overrides:
writeExternalin classIExchange- Parameters:
out-- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Overrides:
readExternalin classIExchange- Parameters:
in-- Throws:
IOExceptionClassNotFoundException
-
-