如何使用 javascript 在 Azure 函数应用程序中使用服务总线主题会话
How to use servicebus topic sessions in azure functionapp using javascript
我有一个 Azure Functionapp,它处理一些数据并将该数据推送到 Azure 服务总线主题。
我需要在我的服务总线主题订阅上启用会话。在使用 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,我可以设置消息的会话 ID 属性 并在服务总线资源管理器中查看它。这是我的示例代码。
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);
}
});
这是测试结果。
请确保您在创建主题和订阅时启用了分流和会话。
我有一个 Azure Functionapp,它处理一些数据并将该数据推送到 Azure 服务总线主题。
我需要在我的服务总线主题订阅上启用会话。在使用 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,我可以设置消息的会话 ID 属性 并在服务总线资源管理器中查看它。这是我的示例代码。
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);
}
});
这是测试结果。
请确保您在创建主题和订阅时启用了分流和会话。