2

我在尝试了解类型标头交换的工作原理时遇到了一些问题。

只有一个交易所,myExchange

三个队列:

  1. 我的队列1
  2. 我的队列2
  3. 我的队列3

绑定:

  1. myExchange => myQueue1 (x-match: any, myHeader: [test1])
  2. myExchange => myQueue2 (x-match: any, myHeader: [test2])
  3. myExchange => myQueue3 (x-match: any, myHeader: [test1, test2, test3])

我希望消息的标题有多个值;test1test2test3的任意组合 (例如:单独的 test1 、test1test2 test3test2...)

myQueue3仅接收具有 myHeaders:[ test1, test2, test3 ] 的消息。我希望myQueue3也能获得例如test1test2的消息。

myQueue1仅接收具有 myHeaders:[ test1 ] 的消息。我希望myQueue1也能获得例如test1和 [ test1 , test2 ] 的消息。

有没有办法实现这种行为?谢谢

4

2 回答 2

1

为此,我有一个窍门。

绑定:

  • myExchange => myQueue1 (x-match: any, test1: true)
  • myExchange => myQueue2 (x-match: any, test2: true)
  • myExchange => myQueue3 (x-match: any, test1: true, test2: true, test3: true)

myQueue1 将接收所有标题包含 {test1: true} 的消息。

myQueue2 将接收所有标题包含 {test2: true} 的消息。

myQueue3 将接收所有标头包含 {test1: true}、{test2: true} 或 {test3: true} 之一的消息。

我更喜欢这个,因为 Routing Key 被限制为 255 个字节,但是 header 中元素数量的限制非常高。

对于性能,我不知道它是最好的。

于 2019-07-31T12:32:07.867 回答
0

我同意这些评论,我试图实现目前不受支持的东西。我将使用路由键。

于 2015-03-10T14:28:13.307 回答