【发布时间】:2016-07-08 06:03:24
【问题描述】:
Azure 服务总线订阅客户端是否支持在订阅需要会话时使用 OnMessage 操作的功能?
我有一个订阅,名为“TestSubscription”。它需要一个 sessionId 并包含由 SessionId 绑定在一起的多部分数据。
if (!namespaceManager.SubscriptionExists("TestTopic", "Export"))
{
var testRule = new RuleDescription
{
Filter = new SqlFilter(@"(Action='Export')"),
Name = "Export"
};
var subDesc = new SubscriptionDescription("DataCollectionTopic", "Export")
{
RequiresSession = true
};
namespaceManager.CreateSubscription(sub`enter code here`Desc, testRule);
}
在一个单独的项目中,我有一个 Service Bus Monitor 和 WorkerRole,而在 Worker Role 中,我有一个名为“testSubscriptionClient”的 SubscriptionClient:
testSubscriptionClient = SubscriptionClient.CreateFromConnectionString(connectionString, _topicName, CloudConfigurationManager.GetSetting("testSubscription"), ReceiveMode.PeekLock);
然后我希望在将新项目放入服务总线队列时触发 OnMessage:
testSubscriptionClient.OnMessage(PersistData);
但是我在运行代码时收到以下消息:
InvalidOperationException:需要会话的实体不可能创建非会话消息接收器
我正在使用 Azure SDK v2.8。
我想做的事可能吗?是否需要在我的服务总线监视器、订阅客户端或其他地方进行特定设置,以便我以这种方式从订阅中检索消息。附带说明一下,这种方法在我不使用会话数据的其他情况下非常有效。
【问题讨论】:
标签: session azure azureservicebus servicebus