簡體   English   中英

如何使用JavaScript在Azure FunctionApp中使用Servicebus主題會話

[英]How to use servicebus topic sessions in azure functionapp using javascript

我有一個Azure Functionapp,它處理一些數據並將這些數據推入Azure Servicebus主題。

我要求在我的servicebus主題訂閱上啟用會話。 我似乎找不到使用javascript functionapp API時設置會話ID的方法。

這是我的功能應用程序的修改后的摘錄:

module.exports = function (context, streamInput) {
  context.bindings.outputSbMsg = [];
  context.bindings.logMessage = [];

  function push(response) {
      let message = {
          body: CrowdSourceDatum.encode(response).finish()
          , customProperties: {
              protoType: manifest.Type
              , version: manifest.Version
              , id: functionId
              , rootType: manifest.RootType
        }
        , brokerProperties: {
            SessionId: "1"
        }
    context.bindings.outputSbMsg.push(message);
  }

  .......... some magic happens here.

  push(crowdSourceDatum);
  context.done();
} 

但是sessionId似乎根本沒有設置。 關於如何實現此目標的任何想法嗎?

死信錯誤

消息屬性

我在功能上測試了sessionid,可以設置消息的session id屬性並在Service Bus Explorer中查看它。 這是我的示例代碼。

var connectionString = 'servicebus_connectionstring';
var serviceBusService = azure.createServiceBusService(connectionString);

var message = {
    body: '',
    customProperties:
    {
        messagenumber: 0
    },
    brokerProperties:
    {
        SessionId: "1"
    }
};

message.body= 'This is Message #101';
serviceBusService.sendTopicMessage('testtopic', message, function(error)
{
    if (error)
    {
        console.log(error);
    }
});

這是測試結果。

在此處輸入圖片說明

請確保在創建主題和訂閱時已啟用分區和會話。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM