使用 stomp (ruby) 将消息 属性 设置为整数到 ActiveMQ
Setting a message property to be an integer using stomp (ruby) to ActiveMQ
当我向 activemq 发送消息时,我必须将名为 SEQUENCE
的自定义消息 属性 设置为整数。正如 activemq 站点所解释的那样,STOMP 协议仅处理字符串。所以据我所知,没有办法使用 STOMP 来做到这一点。有没有其他方法可以使用 Ruby 我可以将 header 设置为整数值?
来自 http://activemq.apache.org/cms/stomp-support.html :
Message Properties in Stomp CMS Since Stomp is strictly text-based, it
does not support a way to specify the type of message properties
(called "header" in stomp lingo). This means that a property sent as
an integer could be read by a Stomp CMS client as any of: string,
integer, short, long, etc.
When a Java client, for example, sends a message to the broker with an
integer property ("myval"=1), the broker adapts the message from
openwire to stomp and in the process converts the property "myval" to
the string "1" and sends the message to the client. The client
receives the string, but allows the user to read this value in any way
that will work successfully with the std::istringstream >> operator.
The same goes for writing values to an outgoing message. You can call
any of the methods (e.g. setIntProperty). The resulting value that
goes out on the wire is still a string, however.
在线路上发送的任何内容都需要是 UTF-8 编码的字符串,因为这是 STOMP 所允许的(它是一种基于文本的协议)。代理将属性中的值视为字符串,如果要发送到 OpenWire 或 AMQP,会将它们转换为适用于这些协议的正确编码的字符串。在客户端,您可以使用现有的任何语言功能将字符串转换为数字形式,并且需要处理可能因错误解码而导致的错误。
当我向 activemq 发送消息时,我必须将名为 SEQUENCE
的自定义消息 属性 设置为整数。正如 activemq 站点所解释的那样,STOMP 协议仅处理字符串。所以据我所知,没有办法使用 STOMP 来做到这一点。有没有其他方法可以使用 Ruby 我可以将 header 设置为整数值?
来自 http://activemq.apache.org/cms/stomp-support.html :
Message Properties in Stomp CMS Since Stomp is strictly text-based, it does not support a way to specify the type of message properties (called "header" in stomp lingo). This means that a property sent as an integer could be read by a Stomp CMS client as any of: string, integer, short, long, etc.
When a Java client, for example, sends a message to the broker with an integer property ("myval"=1), the broker adapts the message from openwire to stomp and in the process converts the property "myval" to the string "1" and sends the message to the client. The client receives the string, but allows the user to read this value in any way that will work successfully with the std::istringstream >> operator.
The same goes for writing values to an outgoing message. You can call any of the methods (e.g. setIntProperty). The resulting value that goes out on the wire is still a string, however.
在线路上发送的任何内容都需要是 UTF-8 编码的字符串,因为这是 STOMP 所允许的(它是一种基于文本的协议)。代理将属性中的值视为字符串,如果要发送到 OpenWire 或 AMQP,会将它们转换为适用于这些协议的正确编码的字符串。在客户端,您可以使用现有的任何语言功能将字符串转换为数字形式,并且需要处理可能因错误解码而导致的错误。