Search code examples
activemq-classicstomp

STOMP with custom properties in Lua


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.


Solution

  • 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:

    Troubleshooting:

    You can enable STOMP protocol tracing with the following steps:

    • ActiveMQ 5.x: Set 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
    • ActiveMQ Artemis: Set the logger org.apache.activemq.artemis.core.protocol.stomp.StompConnection to DEBUG in etc/logging.properties.