RabbitMQ 主题格式 - 主主题下的子主题
RabbitMQ Topic format - sub-topic under main topic
当我尝试以这种格式推送到主题时 /topic/pushing/{organizationId} 我收到一个错误
messagingTemplate.convertAndSend("/topic/pushing/" + obj.getCustomerid(), obj);
错误:
15:06:48.901 [reactor-tcp-io-1] ERROR
o.s.m.s.s.StompBrokerRelayMessageHandler - Received ERROR
{message=[Invalid destination], content-type=[text/plain],
version=[1.0,1.1,1.2], content-length=[53]} session=system
text/plain payload='/pushing/2963_ent' is not a valid topic
destination
然而,当我将其更改为这种格式时 /topic/pushing.{organizationId},用点替换斜线,它工作正常:
messagingTemplate.convertAndSend("/topic/pushing." + obj.getCustomerid(), obj);
知道如何保留斜杠 / 并在主要主题下添加子主题。
AMQP 0.9.1 specification 关于主题交流有这样的话:
The topic exchange type works as follows:
1. A message queue binds to the exchange using a routing pattern, P.
2. A publisher sends the exchange a message with the routing key R.
3. The message is passed to the message queue if R matches P. The routing key used for a topic exchange MUST consist of zero or more
words delimited by dots. Each word may contain the letters A-Z and a-z
and digits 0-9.
The routing pattern follows the same rules as the routing key with the
addition that * matches a single word, and # matches zero or more
words. Thus the routing pattern *.stock.# matches the routing keys
usd.stock and eur.stock.db but not stock.nasdaq.
因此“/”在路由密钥中未被授权,使用的分隔符是一个点。
当我尝试以这种格式推送到主题时 /topic/pushing/{organizationId} 我收到一个错误
messagingTemplate.convertAndSend("/topic/pushing/" + obj.getCustomerid(), obj);
错误:
15:06:48.901 [reactor-tcp-io-1] ERROR o.s.m.s.s.StompBrokerRelayMessageHandler - Received ERROR {message=[Invalid destination], content-type=[text/plain], version=[1.0,1.1,1.2], content-length=[53]} session=system text/plain payload='/pushing/2963_ent' is not a valid topic destination
然而,当我将其更改为这种格式时 /topic/pushing.{organizationId},用点替换斜线,它工作正常:
messagingTemplate.convertAndSend("/topic/pushing." + obj.getCustomerid(), obj);
知道如何保留斜杠 / 并在主要主题下添加子主题。
AMQP 0.9.1 specification 关于主题交流有这样的话:
The topic exchange type works as follows: 1. A message queue binds to the exchange using a routing pattern, P. 2. A publisher sends the exchange a message with the routing key R. 3. The message is passed to the message queue if R matches P. The routing key used for a topic exchange MUST consist of zero or more words delimited by dots. Each word may contain the letters A-Z and a-z and digits 0-9.
The routing pattern follows the same rules as the routing key with the addition that * matches a single word, and # matches zero or more words. Thus the routing pattern *.stock.# matches the routing keys usd.stock and eur.stock.db but not stock.nasdaq.
因此“/”在路由密钥中未被授权,使用的分隔符是一个点。