I am trying to put two custom properties in a STOMP message header when publishing a topic message so that a subscriber can filter messages. Here are two frames that I send to ActiveMQ 5.14 to connect and publish:
CONNECT
login: myUserName
passcode: myPassword
Note: Actual string is CONNECT\nlogin: myUserName\npasscode: myPassword
.
and
SEND
destination:/topic/myTopic
myTopicMessage
Note: Actual string is SEND\ndestination:/topic/myTopic\n\nmyTopicMessage
.
How am I supposed to add the following two pairs of properties to above strings?
package_code = ''
whse_code = 'MyWarehouse'
BTW, I am using lua to implement this.
You can add the properties to your SEND
frame with the same syntax used by destination
, e.g.:
SEND
destination:/topic/myTopic
package_code:MyPackageCode
whse_code:MyWarehouse
myTopicMessage^@
If package_code
(or any other header) is blank simply don't set it.
A few other details are worth noting:
^@
(i.e. control-@ in ASCII) to represent the NULL octet.SEND
frames should include a content-length header and a content-type header if a body is present as noted in the "SEND" section of the STOMP 1.2 spec.Troubleshooting:
You can enable STOMP protocol tracing with the following steps:
trace=true
on the STOMP transportConnector
, e.g.: <transportConnector name="stomp" uri="stomp://localhost:61613?trace=true"/>
. Then set the org.apache.activemq.transport.stomp.StompIO
logger to TRACE
in conf/log4j.properties
org.apache.activemq.artemis.core.protocol.stomp.StompConnection
to DEBUG
in etc/logging.properties
.