Class HeadersExchange

  • All Implemented Interfaces:
    Externalizable, Serializable, IExchangeMBean

    public class HeadersExchange
    extends IExchange
    The headers exchange type works as follows:
    • 1. A message queue is bound to the exchange with a table of arguments containing the headers to be matched for that binding and optionally the values they should hold. The routing key is not used.
    • 2. A publisher sends a message to the exchange where the 'headers' property contains a table of names and values.
    • 3. The message is passed to the queue if the headers property matches the arguments with which the queue was bound.
    The matching algorithm is controlled by a special bind argument passed as a name value pair in the arguments table. The name of this argument is 'xmatch'.
    It can take one of two values, dictating how the rest of the name value pairs in the table are treated during matching:
    • (i) 'all' implies that all the other pairs must match the headers property of a message for that message to be routed (i.e. and AND match)
    • (ii) 'any' implies that the message should be routed if any of the fields in the headers property match one of the fields in the arguments table (i.e. an OR match)
    A field in the bind arguments matches a field in the message if either the field in the bind arguments has no value and a field of the same name is present in the message headers or if the field in the bind arguments has a value and a field of the same name exists in the message headers and has that same value.
    See Also:
    Serialized Form