3.5.2. 为 STOMP 信息提供 ID
通过 JMS 使用者或 QueueBrowser 接收 STOMP 消息时,消息不包含任何 JMS 属性,如 JMSMessageID
。但是,您可以使用代理参数设置每个传入的 STOMP 消息的消息 ID。
步骤
-
打开配置文件
BROKER_INSTANCE_DIR/etc/broker.xml
-
为 STOMP 连接将
stompEnableMessageId
参数设置为true
,如下例所示:
<acceptors> <acceptor name="stomp-acceptor">tcp://localhost:61613?protocols=STOMP;stompEnableMessageId=true</acceptor> ... </acceptors>
通过使用 stompEnableMessageId
参数,使用这个接收器发送的每个 STOMP 消息添加额外的属性。属性键是 amq-message-id
,值是前缀为 “STOMP” 的内部消息 ID 的字符串,如下例所示:
amq-message-id : STOMP12345
如果没有在配置中指定 stompEnableMessageId
,则默认值为 false
。