简体   繁体   English

不通过Azure服务总线队列接收消息

[英]Not receiving messages via azure service bus queue

I have a C# program sending messages to an Azure service Bus Q (on VM). 我有一个C#程序,将消息发送到Azure服务总线Q(在VM上)。 The messages should be received by a node.js application (on Mac). 消息应由 node.js应用程序(在Mac上)接收。 Problem is the receive. 问题是接收。 The behaviour I see is: 我看到的行为是:

  • If I start the node.js app in a new term window with a message already in the Q, it is received on the first call 如果我在新的term窗口中启动了node.js应用,并且在Q中已经有一条消息,那么它将在第一次调用时收到
  • Keeping the node.js app running, the next message posted to the Q will be received after 1 min 保持node.js应用运行,在1分钟后将收到发布到Q的下一条消息
  • stopping the node.js app and restarting it in the same term window and posting another message to the Q is never received 永远不会收到停止node.js应用程序并在同一术语窗口中重新启动它并将其他消息发布到Q的消息

I know that the C# program is correctly sending the message as I inspect with service bus explorer immediately after the program confirms "send". 我知道C#程序在确认“发送”后立即用服务总线资源管理器检查时正确地发送了消息。 The send is being done currently in synchronous mode. 当前正在同步模式下完成发送。

Node.js program: (running with latest azure library and node 8.9.4) Node.js程序:(与最新的Azure库和节点8.9.4一起运行)

logger.info("Connecting to service bus");
const sbService = azure.createServiceBusService(connectionString);
if (sbService != null) {
 sbService.createQueueIfNotExists(queueName, function (err) {
   if (err) {
     logger.error("Cannot connect to "+queueName+" :: "+ util.inspect(err, { depth: null }));
   } else {
      logger.info("Connected to Q :: processing begins ");
      var intervalID = setInterval(timerElapsed, 5000);
   }
 });
}

function timerElapsed() {
  sbService.receiveQueueMessage(queueName, { isPeekLock: false }, function (err, lockedMessage) {
      if (err) {
          if (err !== 'No messages to receive') {
            logger.error("receiveQueueMessage error states: "+ util.inspect(err, { depth: 2 }));
          } else {
            console.log('.');
          }
       } else {
         logger.info("received Message: "+ util.inspect(lockedMessage, { depth: 2 }));
       }
  });
}

[EDIT] - Interestingly, I used the example from MS Github here github example with similar results. [编辑]-有趣的是,我使用了来自MS Github的示例,这里的github示例具有相似的结果。

< bangs head on table > Look at the clues in this post delays using python . < 桌上的刘海 >看这篇文章中使用python延迟的线索。 The culprit is queue partitioning which is on by default. 罪魁祸首是默认情况下启用的队列分区。 Turn it off, and voila... 关闭它,瞧...

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

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