英文:
How to read byte attachment in solace
问题
我能够接收到InboundMessage消息。当我将其转储时,我可以看到二进制附件,但无法从InboundMessage中提取二进制附件。
我正在使用Python发布消息,Java消费消息。
有人可以帮助我从InboundMessage中提取二进制附件吗?
二进制附件:len=65
80 04 95 36 00 00 00 00 00 00 00 8c 0b 6d 6f 64 ...6.........mod
65 6c 2e 62 61 74 63 68 94 8c 05 42 61 74 63 68 el.batch...Batch
94 93 94 29 81 94 7d 94 8c 04 6e 61 6d 65 94 8c ...)..}...name..
0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21 94 73 62 .hello.world!.sb
2e .
提前感谢!
英文:
I am able to receive the InboundMessage message. When I dump it, I can see Binary Attachment but I am not able to extract Binary Attachment from InboundMessage.
I am using python to publish message and java to consume message.
Can anyone help me to extract Binary Attachment from InboundMessage
Binary Attachment: len=65
80 04 95 36 00 00 00 00 00 00 00 8c 0b 6d 6f 64 ...6.........mod
65 6c 2e 62 61 74 63 68 94 8c 05 42 61 74 63 68 el.batch...Batch
94 93 94 29 81 94 7d 94 8c 04 6e 61 6d 65 94 8c ...)..}...name..
0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21 94 73 62 .hello.world!.sb
2e .
Thanks in advance!
答案1
得分: 2
如果您使用新的Java API,那么这些可能是您想查看的方法:
Message.getPayloadAsBytes()
文档链接Message.getPayloadAsString()
文档链接InboundMessage.getAndConvertPayload(Converter, Class)
文档链接
如果您使用JCSMP,只需将接收到的BytesXMLMessage
强制转换为BytesMessage
并获取原始载荷:((BytesMessage)message).getData()
。或者,如果您要发布文本消息/字符串载荷,那么应该是((TextMessage)message).getText()
。
Solace实际上有4个Java API,还有更多支持Solace的其他协议的API(MQTT,AMQP等)。使用Python发布消息的具体细节以及您正在使用的Java API,请编辑您的问题以提供更多详细信息。
英文:
If you are using the new Java API, then these are probably the methods you'd want to check out:
Message.getPayloadAsBytes()
Docs linkMessage.getPayloadAsString()
Docs linkInboundMessage.getAndConvertPayload(Converter, Class)
Docs link
If you are using JCSMP, then just cast the received BytesXMLMessaage
to a BytesMessage
and get the raw payload: ((BytesMessage)message).getData()
. Or if you are publishing a Text message / String payload, then it would be ((TextMessage)message).getText()
.
Solace has 4 Java APIs, actually, and there are more for the other protocols Solace supports (MQTT, AMQP, etc.). Edit your question with more specifics about how you're publishing in Python & exactly which Java API you're consuming with.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论