Use rocketmq in springboot client, there are 2 ways.
First, the use of rocketmq-client org.apache.rocketmq
Second, cited in pom.xml
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.0.3</version>
</dependency>
Specific URLs https://github.com/apache/rocketmq-spring/blob/master/README_zh_CN.md
7 described in the text of the FAQ and 6, which can add a custom header properties.
In the experiment found that duplicate the original name and attributes defined custom names to add "USER_" as described in the instructions, if the name is not a conflict, it will not be changed.
public void send() throws InterruptedException { Message<?> msg = MessageBuilder.withPayload("Hi rocketmq!") .setHeader(MessageConst.PROPERTY_KEYS, "20191018") .setHeader("TAGS", "191018") .setHeader(MessageConst.PROPERTY_BUYER_ID,"20191018a") .setHeader("MQ", "user_mq") .build(); template.convertAndSend(topic + ":1018", "topic with tags"); java.lang.Thread.sleep(2000); template.send(topic, msg); log.info("send mq message, ext message" + msg.toString()); }
the setHeader ( "the TAGS", "191 018" ), are filtered out, the setHeader ( "USER_TAGS", "191 018"), the receiving end can receive the results.
To add tags attribute should only be placed in the transmit function in the first argument. The code '(+ Topic ": 1018",'
. The setHeader (MessageConst.PROPERTY_KEYS, "20,191,018"), is an effective
example of such MessageConst.PROPERTY_BUYER_ID other properties (tried several) it seems to have been in the filter MessageConst a. not like the description he said, adding that "USER_" prefix.