简体   繁体   English

Azure 服务总线未接收消息

[英]Azure service bus not receiving messages

I'm using Azure service bus to send messages across containers in my K8s setup.我正在使用 Azure 服务总线在我的 K8s 设置中跨容器发送消息。 Implementation of service that receives message is done in Node.js.From the doc page, here is the code I'm using to receive the messages.接收消息的服务的实现是在 Node.js 中完成的。从文档页面,这里是我用来接收消息的代码。

serviceBusService.receiveQueueMessage('feedback', function(error, receivedMessage) {

  if (!error) {

   // Message received and deleted

   console.log(receivedMessage);

  //..

   }

});

Everything works as expected for the first time but the messages are not received for the second time.第一次一切正常,但第二次没有收到消息。 It works as expected when the code snippet is kept inside the setInterval block.当代码片段保存在setInterval块中时,它按预期工作。 Which seems not the intended way of doing this.这似乎不是这样做的预期方式。

Any ideas what could be wrong?任何想法可能是错误的?

I have not used the js library for ServiceBus client, but the .NET library that has it seems similar methods.我没有使用 ServiceBus 客户端的 js 库,但它的 .NET 库似乎有类似的方法。 So if the js versjon works the same way, so then it receives only one message and you have to continue yourself.因此,如果 js versjon 以相同的方式工作,那么它只会收到一条消息,您必须自己继续。

In .Net library there are generally two ways:在.Net库中,一般有两种方式:

  1. You write your own while loop with whatever you think necessary您可以使用您认为必要的任何内容编写自己的 while 循环

  2. You use RegisterMessageHandler that seems to be absent from js library您使用了 js 库中似乎没有的 RegisterMessageHandler

The option number 2 generally does the same and starts the while loop inside the pump so that you don't have to implement it yourself.选项 2 通常执行相同的操作并在泵内启动 while 循环,这样您就不必自己实现它。

You can take a look here on how the while loop is implemented and do something similar to it in js.您可以在此处查看 while 循环是如何实现的,并在 js 中执行类似的操作。

Like Mikhail Shilkov has mentioned previously in the comments, I suspect it only receives one message and I'd also recommend using the AMQP libraries.就像 Mikhail Shilkov 之前在评论中提到的那样,我怀疑它只收到一条消息,我还建议使用 AMQP 库。

I know this is a late reply, but just in case someone is running into issues, refer to the links below.我知道这是一个迟到的回复,但以防万一有人遇到问题,请参阅下面的链接。

Version 7.0.0 of @azure/service-bus (based on AMQP) has been recently published.最近发布了@azure/service-bus (基于 AMQP)的 7.0.0 版。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM