- Hands-On Microservices with C#
- Matt R. Cole
- 430字
- 2021-07-23 17:25:23
Headers exchange
Headers exchange routes are based on arguments containing headers and optional values. Headers exchanges are very similar to topic exchanges, but they route based on header values instead of routing keys. A message is considered matching if the value of the header equals the value specified upon binding.
A special argument named x-match, which can be added in the binding between your exchange and your queue, tells if all headers must match or just one. Either any common header between the message and the binding counts as a match, or all the headers referenced in the binding need to be present in the message for it to match. The x-match property can have two different values: any or all, where all is the default value. A value of all means all header pairs (key, value) must match and a value of any means at least one of the header pairs must match. Headers can be constructed using a wider range of data types—integer or hash, for example, instead of a string. The header's exchange type (used with binding argument any) is useful for directing messages that may contain a subset of known (unordered) criteria:
- Exchange: Binding to Queue A with arguments (key = value): format = pdf, type = report, x-match = all
- Exchange: Binding to Queue B with arguments (key = value): format = pdf, type = log, x-match = any
- Exchange: Binding to Queue C with arguments (key = value): format = zip, type = report, x-match = all
SCENARIO 1:
Message 1 is published to the exchange with the header arguments (key = value): format = pdf, type = report and with the binding argument x-match = all.
Message 1 is delivered to Queue A —all key/value pair match.
SCENARIO 2:
Message 2 is published to the exchange with header arguments of (key = value): format = pdf and with the binding argument x-match = any.
Message 2 is delivered to Queue A and Queue B—the queue is configured to match any of the headers (format or log):

Headers exchange route messages to queues that are bound using arguments (key and value) that contain headers and optional values.
SCENARIO 3:
Message 3 is published to the exchange with the header arguments of (key = value): format = zip, type = log and with the binding argument x-match = all.
Message 3 is not delivered to any queue; the queue is configured to match all of the headers (format or log).
- JavaScript實(shí)例自學(xué)手冊
- Docker High Performance(Second Edition)
- Grome Terrain Modeling with Ogre3D,UDK,and Unity3D
- Machine Learning with Apache Spark Quick Start Guide
- 手把手教你學(xué)Flash CS3
- 運(yùn)動控制系統(tǒng)(第2版)
- 機(jī)器人剛?cè)狁詈蟿恿W(xué)
- 網(wǎng)絡(luò)安全原理與應(yīng)用
- 工業(yè)機(jī)器人與自控系統(tǒng)的集成應(yīng)用
- 多傳感器數(shù)據(jù)智能融合理論與應(yīng)用
- Hands/On Kubernetes on Azure
- 大學(xué)計算機(jī)實(shí)踐教程
- 仿魚機(jī)器人的設(shè)計與制作
- Getting Started with LevelDB
- ARM Cortex-M3嵌入式開發(fā)實(shí)例詳解