Reputation: 3851
I have created an event hub triggered function app, which would received from one event hub and send message/data to another event hub using
public static async Task Run(
[EventHubTrigger("source", Connection = "EventHubConnectionAppSetting")] EventData[] events,
[EventHub("dest-1", Connection = "EventHubConnectionAppSetting")]IAsyncCollector<string> outputEvents,
ILogger log)
however, right now I would like to publish the same message to one or more additional event hubs(e.g, dest-2
, dest-3
, etc) so all my consumer event hubs(dest-1, dest-2, dest-3) could consume same message async. Is there anyway to achieve that approach with Azure Event hub triggered function app?
Upvotes: 0
Views: 518
Reputation: 2351
If you don't want to create multiple async collectors then You need to use custom binder with IBinder class. Like below.
public static async Task Run(
[EventHubTrigger("source", Connection = "EventHubConnectionAppSetting")] EventData[] events,
IBinder binder,
ILogger log) {
// custom binding here (exmaple)
var collector = await binder.BindAsync<IAsyncCollector<string>>(
new EventHubAttribute(... params to event hub here...));
var message = ...
await collector.AddAsync(message);
}
I typed this from my phone so sorry if there are typos ;) But in general this is a way to go.
Upvotes: 1