Node.js 获得;amqp:内部错误“;使用AMQP、rhea和节点从Azure服务总线队列中窥视消息时

Node.js 获得;amqp:内部错误“;使用AMQP、rhea和节点从Azure服务总线队列中窥视消息时,node.js,azure,amqp,azureservicebus,azure-servicebus-queues,Node.js,Azure,Amqp,Azureservicebus,Azure Servicebus Queues,几天前我问了同样的问题:。我再次问同一个问题,但有一些不同(因此,请不要将此问题标记为其他问题的重复): 在上一个问题中,我使用的是nodeamqp10library,但是根据Github页面上对该库的一些评论,我最终使用的不是nodeamqp10library 在Azure Service Bus团队的帮助下,我取得了一些进展,现在我从Azure Service Bus那里得到了一个错误,它告诉我我走在了正确的轨道上 以下是我正在使用的新代码: var client = require('

几天前我问了同样的问题:。我再次问同一个问题,但有一些不同(因此,请不要将此问题标记为其他问题的重复):

  • 在上一个问题中,我使用的是
    nodeamqp10
    library,但是根据Github页面上对该库的一些评论,我最终使用的不是
    nodeamqp10
    library
  • 在Azure Service Bus团队的帮助下,我取得了一些进展,现在我从Azure Service Bus那里得到了一个错误,它告诉我我走在了正确的轨道上
以下是我正在使用的新代码:

var client = require('rhea');
const keyName = 'MyCustomPolicy';
const sasKey = 'SAS Key'
const serviceBusHost = 'account.servicebus.windows.net';
const queueName = '003';

client.on('connection_open', (context) => {
  context.connection.open_sender({
    target: { address: `${queueName}/$management` }
  });
});

client.once('sendable', (context) => {
  console.log('messages can be sent now....');
  var receiver = context.connection.open_receiver({
    source: { address: `${queueName}/$management` },
    autoaccept: false,
    target: { address: 'receiver-link' }
  });

  receiver.once('receiver_open', (context) => {
    console.log('receiver is now open....');
  });

  receiver.once('message', (context) => {
    console.log('message received by receiver....');
    console.log(context.message);
  });

  var messageBody = {
    'from-sequence-number': 1,
    'message-count': 5
  };

  const msg = {
    application_properties: {
      operation: 'com.microsoft:peek-message'
    },
    body: client.types.wrap_map(messageBody),
    reply_to: 'receiver-link'
  };
  context.sender.send(msg);
  console.log('message sent....');
});

client.connect({
  transport: 'tls',
  host: serviceBusHost,
  hostname: serviceBusHost,
  username: keyName,
  password: sasKey,
  port: 5671,
  reconnect_limit: 10
});
现在,当我运行此代码时,我从Azure服务总线返回
500
错误:

{
  "application_properties":
  {
    "statusCode":500,
    "errorCondition":"amqp:internal-error",
    "statusDescription":"The service was unable to process the request; please retry the operation. For more information on exception types and proper exception handling, please refer to http://go.microsoft.com/fwlink/?LinkId=761101 Reference:ab667ed6-1565-4728-97b7-6ae4a33468b9, TrackingId:538f93a1-2c07-4bc0-bf41-dc00d7ae963c_B13, SystemTracker:account-name:Queue:003, Timestamp:8/2/2018 7:43:52 AM",
    "com.microsoft:tracking-id":"538f93a1-2c07-4bc0-bf41-dc00d7ae963c_B13"
  }
}
我甚至检查了错误消息()中包含的链接,但在该链接上没有提到与amqp相关的错误

与前一个问题一样,如果我使用address作为队列名称,而不是
队列名称/$management
,我可以获取消息,但消息被锁定,消息的传递计数正在增加。此外,它返回队列中的所有消息,而不是我请求的5条消息


我不确定我做错了什么。有人能帮忙吗?

在Azure服务总线团队的帮助下,我找到了这个问题的解决方案(事实上,他们给了我这个解决方案)。本质上,
messageBody
的元素应该使用AMQP类型进行正确编码

以下代码工作:

  var messageBody = {
    'from-sequence-number': client.types.wrap_long(1),
    'message-count': client.types.wrap_int(5)
  };

  const msg = {
    application_properties: {
      operation: 'com.microsoft:peek-message'
    },
    body: messageBody,
    reply_to: 'receiver-link'
  };