2017-04-19 127 views
0

当我试图推动主题此格式/主题/推/ {organizationId}我得到一个错误RabbitMQ的主题格式 - 下主要话题子话题

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); 

任何想法如何保持斜线/和主题下的子主题。

回答

1

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.

所以“/”路由键没有被授权,并用分隔符是一个点。