Headers 类型的Exchanges是不处理路由键的,而是根据发送的消息内容中的headers属性进行匹配。在绑定Queue与Exchange时指定一组键值对;当消息发送到RabbitMQ时会取到该消息的headers与Exchange绑定时指定的键值对进行匹配;如果完全匹配则消息会路由到该队列,否则不会路由到该队列。headers属性是一个键值对,可以是Hashtable,键值对的值可以是任何类型。而fanout,direct,topic 的路由键都需要要字符串形式的。

匹配规则x-match有下列两种类型:

  • x-match = all :表示所有的键值对都匹配才能接受到消息
  • x-match = any:表示只要有键值对匹配就能接受到消息

不过headers比较少用到,下面是headers的官方说明文档:

A headers exchange is designed to for routing on multiple attributes that are more easily expressed as message headers than a routing key. Headers exchanges ignore the routing key attribute. Instead, the attributes used for routing are taken from the headers attribute. A message is considered matching if the value of the header equals the value specified upon binding.

更多相关文章

  1. 在使用visualvm进行分析时,如何避免“Profiler代理警告:无法查找缓

随机推荐

  1. Android高手进阶教程(五)之----Android
  2. android 组件
  3. android音乐播放器开发_开篇
  4. android ui显示技巧和注意事项
  5. 关于android的各种disk images(看过的讲a
  6. Eclipse中使用Ant打Android包报错解决方
  7. android平台的几个编译命令----make,mmm,
  8. Android:背景渐变色
  9. 【Android(BLE)】Android(BLE)之蓝牙权限
  10. 关于Android(安卓)Studio打包混淆以及上