得到"amqp:内部错误".使用AMQP,rhea和Node从Azure Service Bus队列中查看消息时 [英] Getting "amqp:internal-error" when peeking messages from Azure Service Bus Queue using AMQP, rhea and Node

查看:160
本文介绍了得到"amqp:内部错误".使用AMQP,rhea和Node从Azure Service Bus队列中查看消息时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前我问了同样的问题:从Azure Service Bus队列发送消息.我再次问相同的问题,但有一些区别(因此,请不要将此问题标记为其他问题的重复项):

I asked the very same question few days ago: Unable to "Peek" messages from an Azure Service Bus Queue using AMQP and Node. I'm asking the same question again but with a few differences (hence, please don't mark this question as a duplicate of the other question):

  • In the previous question, I was using nodeamqp10 library however based on some comments on the Github page for this library, I ended up using rhea instead of nodeamqp10 library.
  • With some help from Azure Service Bus team, I made some progress and now I am getting an error back from Azure Service Bus which tells me that I am on the right track.

这是我正在使用的新代码:

Here's the new code I am using:

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 Service Bus收到500错误:

Now when I run this code, I'm getting 500 error back from Azure Service Bus:

{
  "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"
  }
}

我什至检查了错误消息中包含的链接( http://go.microsoft .com/fwlink/?LinkId = 761101 ),但该链接上没有提及与amqp相关的错误.

I even checked the link included in the error message (http://go.microsoft.com/fwlink/?LinkId=761101) but there is no mention of amqp related errors on that link.

与上一个问题一样,如果我仅使用地址作为队列名而不是queue-name/$management,则可以获取消息,但是消息被锁定,消息的传递计数正在增加.此外,它将返回队列中的所有消息,而不是我请求的5条消息.

As in the previous question, if I use address as just the queue name instead of queue-name/$management, I am able to get the messages but the messages are locked and the delivery count for the messages is increasing. Furthermore, it is returning all the messages from the queue instead of just 5 messages that I am requesting.

我不确定自己在做什么错.有人可以帮忙吗?

I'm not sure what I am doing wrong. Can someone help?

推荐答案

在Azure Service Bus团队的帮助下,我找到了解决此问题的解决方案(实际上,他们给了我这种解决方案).基本上messageBody的元素应该使用AMQP类型正确编码.

With help of Azure Service Bus team, I was able to find a solution to this problem (in fact, they gave me this solution). Essentially elements of messageBody should be properly encoded using AMQP types.

以下代码有效:

  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'
  };

这篇关于得到"amqp:内部错误".使用AMQP,rhea和Node从Azure Service Bus队列中查看消息时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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