Created
February 8, 2018 19:10
-
-
Save jeffhollan/2d514e0e1a0b9195f5d2553fdc04cf78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Azure.EventHubs; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Host; | |
using Microsoft.Azure.WebJobs.ServiceBus; | |
using StackExchange.Redis; | |
using System; | |
using System.Threading.Tasks; | |
namespace OrderedEventHubs | |
{ | |
public static class EventHubTrigger | |
{ | |
private static ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(Environment.GetEnvironmentVariable("Redis")); | |
private static IDatabase db = redis.GetDatabase(); | |
[FunctionName("SingleMessageTrigger")] | |
public static async Task Single( | |
[EventHubTrigger("ordered", Connection = "EventHub")] EventData eventData, | |
TraceWriter log) | |
{ | |
try | |
{ | |
await db.ListRightPushAsync( | |
"events:" + eventData.Properties["partitionKey"], | |
(string)eventData.Properties["counter"]); | |
} | |
catch | |
{ | |
// handle event exception | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment