如何将二进制消息从 python stomp 发送到 ActiveMQ
How to send binary message from python stomp to ActiveMQ
我正在尝试 Python stomp
客户端通过 ActiveMQ 向 JVM 发送二进制消息,我需要它作为 JMS BytesMessage
,但它以 TextMessage
的形式出现。
我想这应该是可能的,因为我可以做相反的事情(JVM 到 Python),但不确定怎么做。
有人知道这个技巧吗?
您需要在发送的 STOMP 消息上设置 content-length
header,以便将其转换为 JMS BytesMessage
。请参阅 ActiveMQ STOMP documentation 的 "Working with JMS Text/Bytes Messages and Stomp" 部分。
stomp.Connection.send() 总是指定 content-length header。
您需要添加 stomp.Connection(auto_content_length=False),
因为默认值是 stomp.Connection(auto_content_length=True) 指定 content-length header 仅用于字节消息而不是字符串消息。
我正在尝试 Python stomp
客户端通过 ActiveMQ 向 JVM 发送二进制消息,我需要它作为 JMS BytesMessage
,但它以 TextMessage
的形式出现。
我想这应该是可能的,因为我可以做相反的事情(JVM 到 Python),但不确定怎么做。
有人知道这个技巧吗?
您需要在发送的 STOMP 消息上设置 content-length
header,以便将其转换为 JMS BytesMessage
。请参阅 ActiveMQ STOMP documentation 的 "Working with JMS Text/Bytes Messages and Stomp" 部分。
stomp.Connection.send() 总是指定 content-length header。 您需要添加 stomp.Connection(auto_content_length=False), 因为默认值是 stomp.Connection(auto_content_length=True) 指定 content-length header 仅用于字节消息而不是字符串消息。