如何使用javascript在azure functionapp中使用servicebus主题会话
我有一个Azure Functionapp,它处理一些数据并将这些数据推送到Azure servicebus主题中 我要求在我的servicebus主题订阅上启用会话。在使用javascript functionapp API时,我似乎找不到设置会话id的方法 以下是我的函数应用程序的修改摘录:如何使用javascript在azure functionapp中使用servicebus主题会话,javascript,azure,session,servicebus,azure-servicebus-topics,Javascript,Azure,Session,Servicebus,Azure Servicebus Topics,我有一个Azure Functionapp,它处理一些数据并将这些数据推送到Azure servicebus主题中 我要求在我的servicebus主题订阅上启用会话。在使用javascript functionapp API时,我似乎找不到设置会话id的方法 以下是我的函数应用程序的修改摘录: module.exports = function (context, streamInput) { context.bindings.outputSbMsg = []; context.bin
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,我可以设置消息的sessionid属性,并在服务总线资源管理器中查看它。这是我的示例代码
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);
}
});
这是测试结果
请确保在创建主题和订阅时已启用了分配和会话
这不使用function apps提供的内置servicebus连接器,我正试图这样做。很抱歉,这是在node中使用输出绑定的限制之一,因为我们丢失了其他语言中的一些类型信息。当前请使用节点的ServiceBus sdk作为解决方法。有关更多信息,您可以参考以下回复。谢谢你的帮助。:-)