互操作性的Azure服务总线的消息队列中的消息 [英] Interoperability Azure Service Bus Message Queue Messages

查看:244
本文介绍了互操作性的Azure服务总线的消息队列中的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Java应用程序和应用程序的NodeJS都使用单一的Azure服务总线消息队列。

I have a Java App and a NodeJS App both using a single Azure Service Bus Message Queue.

我看到与我的客户一些奇怪的效果,如下图。

I witness some strange effects with my clients, as follow.

JAVA消息生产者

 TextMessage message = sendSession.createTextMessage();
        message.setText("Test AMQP message from JMS");
        long randomMessageID = randomGenerator.nextLong() >>>1;
        message.setJMSMessageID("ID:" + randomMessageID);
        sender.send(message);
        System.out.println("Sent message with JMSMessageID = " + message.getJMSMessageID());

输出:
发送消息,JMSMessageID = ID:2414932965987073843

OUTPUT: Sent message with JMSMessageID = ID:2414932965987073843

的NodeJS消息消费者:

NODEJS MESSAGE CONSUMER:

serviceBus.receiveQueueMessage(queue, {timeoutIntervalInS: timeOut, isReceiveAndDelete: true}, function(err, message) {
if(message !==null)console.log(util.inspect(message, {showHidden: false, depth: null}));
});

OUTPUT:

OUTPUT:

{ body: '@\u0006string\b3http://schemas.microsoft.com/2003/10/Serialization/�\u001aTest AMQP message from JMS',
brokerProperties:
{ DeliveryCount: 1,
EnqueuedSequenceNumber: 5000004,
EnqueuedTimeUtc: 'Wed, 04 Nov 2015 21:28:21 GMT',
MessageId: '2414932965987073843',
PartitionKey: '89',
SequenceNumber: 59672695067659070,
State: 'Active',
TimeToLive: 1209600,
To: 'moequeue' },
contentType: 'application/xml; charset=utf-8' }

如果我比较,为插入通过serviceBus.sendQueueMessage()队列中的消息,则属性是这样的:

If I compare that to a message inserted into the queue via serviceBus.sendQueueMessage(), then the properties look like this:

{ body: 'test message',
brokerProperties:
{ DeliveryCount: 1,
EnqueuedSequenceNumber: 0,
EnqueuedTimeUtc: 'Wed, 04 Nov 2015 21:44:03 GMT',
MessageId: 'bc0a3d4f-15ba-434f-9fb0-1a3789885f8c',
PartitionKey: '734',
SequenceNumber: 37436171906517256,
State: 'Active',
TimeToLive: 1209600 },
contentType: 'text/plain',
customProperties:
{ message_number: 0,
sent_date: Wed Nov 04 2015 21:44:03 GMT+0000 (UTC) } }

所以,内容类型是不同的入手 - 为什么? - 然后哪里在第一条消息有效载荷的身体奇怪的垃圾来自于: @ \\ u0006string \\ b3http://schemas.microsoft.com/2003/10/Serialization/ \\ u001a
是序列化的结果呢?这该如何缓解?

So content type is different to start with - why? - and then where does the strange garbage in the body of the first message payload come from: @\u0006string\b3http://schemas.microsoft.com/2003/10/Serialization/�\u001a Is that the result of serialization? How can this be mitigated?

查找code,以及在这里:
http://pastebin.com/T9RTFRBk

Find the code as well here: http://pastebin.com/T9RTFRBk

推荐答案

Azure的服务总线支持两种不同的协议:AMQP和HTTP。在Java / JMS使用qpid库使用AMQP protocal的ServiceBus。然而,ServiceBus REST API的包裹在周四的NodeJS HTTP协议。

The Azure Service Bus supports two different protocols: AMQP and HTTP. The Java/JMS using qpid libs is using AMQP protocal for ServiceBus. However, the ServiceBus REST APIs wrapped in NodeJS thur HTTP protocol.

在服务总线支持AMQP详细资料,请参考的https://azure.microsoft.com/en-us/documentation/articles/service-bus-amqp-overview/.

Details for AMQP support in Service Bus, please refer to https://azure.microsoft.com/en-us/documentation/articles/service-bus-amqp-overview/.

而对于ServiceBus的REST API的,请参考 https://开头msdn.microsoft.com/en-us/library/azure/hh780717.aspx

And for REST APIs of ServiceBus, please refer to https://msdn.microsoft.com/en-us/library/azure/hh780717.aspx.

AMQP是一个二进制文件,应用层协议,旨在有效
  支持多种消息传递应用程序和通信
  图案。 - 维基百科

AMQP is a binary, application layer protocol, designed to efficiently support a wide variety of messaging applications and communication patterns. - from WikiPedia

但HTTP是一种文本协议。

But the HTTP is a text protocol.

该消息格式如下,请参考章节消息格式的aritifact <一的href=\"http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format\" rel=\"nofollow\">http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format.而AMQP规范,可以向所指向的 http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html

The message format is as below, please refer to the section Message Format of the aritifact http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format. And the AMQP specification can be refered to http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html.

                                                     Bare Message
                                                            |
                                      .---------------------+--------------------.
                                      |                                          |
 +--------+-------------+-------------+------------+--------------+--------------+--------+
 | header | delivery-   | message-    | properties | application- | application- | footer |
 |        | annotations | annotations |            | properties   | data         |        |
 +--------+-------------+-------------+------------+--------------+--------------+--------+
 |                                                                                        |
 '-------------------------------------------+--------------------------------------------'
                                             |
                                      Annotated Message

所以在Java中寄自或寄往在对的NodeJS消息被序列化到不同的结果。

So the messages sent in Java or sent in NodeJS were serialized to different results.

在身体从AMQP内容格式化内容为\\ uXXXX 是单向code特性的试验研究。

The content \uXXXX formated in the content of body from AMQP is Unicode Charater.

单向code柴拉特 \\ u0006 的就是承认控制研究系统字符,请参考的 https://en.wikipedia.org/wiki/Acknowledge_character 知道这一点。

The Unicode Charater \u0006 is Acknowledge controll charater, please refer to https://en.wikipedia.org/wiki/Acknowledge_character to know it.

和单向code柴拉特 \\ u001a 是替代控制研究系统字符,请参考的 https://en.wikipedia.org/wiki/Substitute_character

And the Unicode Charater \u001a is Substitute controll charater, please refer to https://en.wikipedia.org/wiki/Substitute_character.

它们限制在消息报头中的元数据的开始和结束。

They are limit the start and end of the metadata in the message header.

这篇关于互操作性的Azure服务总线的消息队列中的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆