Skip to content

Instantly share code, notes, and snippets.

@ThomasArdal
Created October 1, 2014 18:36
Show Gist options
  • Save ThomasArdal/baaac1805fab03047268 to your computer and use it in GitHub Desktop.
Save ThomasArdal/baaac1805fab03047268 to your computer and use it in GitHub Desktop.
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