Created
October 1, 2014 18:36
-
-
Save ThomasArdal/baaac1805fab03047268 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Microsoft.ServiceBus.Messaging; | |
using Microsoft.WindowsAzure; | |
namespace AzureElasticsearchConsumer | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString"); | |
SubscriptionClient Client = SubscriptionClient.CreateFromConnectionString( | |
connectionString, | |
"errors", | |
"elasticsearch"); | |
Client.Receive(); | |
// Continuously process messages received from the HighMessages subscription | |
while (true) | |
{ | |
BrokeredMessage message = Client.Receive(); | |
if (message != null) | |
{ | |
try | |
{ | |
Console.WriteLine("Body: " + message.GetBody<string>()); | |
// Remove message from subscription | |
message.Complete(); | |
} | |
catch (Exception) | |
{ | |
// Indicate a problem, unlock message in subscription | |
message.Abandon(); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment