首页 > 解决方案 > 具有多个输出到同一 EventHub 的 Azure 函数不起作用

问题描述

我有两个输出绑定到 Azure EventHub 的 Azure Function。输出到相同的 EH 但不同的主题。只要输出消息转到一个主题,它就可以正常工作。如果同时涉及两个主题,我会收到如下错误:

Exception while executing function: Functions.EventHubTriggerCSharp1. 
Microsoft.Azure.WebJobs.Host: Error while handling parameter 
outputEventHubMessageColdPath after function returned:. Microsoft.ServiceBus:
This event data instance has already been disposed.

尽管消息仅发送到 1 个主题。你知道为什么我不能得到关于这两个主题的消息吗?顺便说一句,代码与: 带有事件中心输出绑定的 Azure 函数不起作用

谢谢

标签: azureazure-functions

解决方案


好的,我通过更改解决了:

//Send it to both cold and hot path:
var message=CreateEHMessages("aggregates", rawMessageSection, deviceId, log);                  outputEventHubMessageHotPath.Add(message);
                outputEventHubMessageColdPath.Add(message);

至:

//Send it to both cold and hot path:
                    outputEventHubMessageHotPath.Add(CreateEHMessages("aggregates", rawMessageSection, deviceId, log));
                    outputEventHubMessageColdPath.Add(CreateEHMessages("aggregates", rawMessageSection, deviceId, log));

推荐阅读