public SNSToSQSServiceBus(SNSPublisher publisher, SequentialSQSReceiver receiver, bool createSubscription)
 {
     _publisher = publisher;
     _receiver = receiver;
     _createSubscription = createSubscription;
     _sQSReceiverThread = new Thread(_receiver.StartReceiving);
 }
        public static void Main(string[] args)
        {
            var receiver = new ConcurrentSqsReceiver(
                new AmazonSQSClient(), 
                new QueueByName("justeat-servicebus-example-queue", true),
                ProcessMessage, 
                ProcessError);

            var publisher = new SNSPublisher(
                new AmazonSimpleNotificationServiceClient(),
                new TopicByName("justeat-servicebus-example-topic", true));

            //var publisher = new SQSPublisher(
            //    new AmazonSQSClient(),
            //    new QueueByName("justeat-servicebus-example-queue", true));

            var serviceBus = new SNSToSQSServiceBus(publisher, receiver);
            serviceBus.StartReceiving();

            var message = string.Format(@"{{""id"":{0}}}", new Random().Next());
            
            Console.WriteLine("Publishing Message: {0}", message);

            serviceBus.Publish(message);

            SpinWait.SpinUntil(() => _completed, TimeSpan.FromSeconds(10));

            if (_completed)
            {
                if (_completedSuccessfully)
                {
                    Console.WriteLine("Message recieved and handled successfuly");
                }
                else
                {
                    Console.WriteLine("Message recieved but an unexpected error occured.  Please submit a github issue.");
                }

            }
            else
            {
                Console.WriteLine("Something has unexpectedly gone wrong. Please submit a github issue and try " +
                                  "enabling logging in the AWS SDK to capture useful output: " +
                                  "http://docs.aws.amazon.com/AWSSdkDocsNET/latest/DeveloperGuide/net-dg-config-other.html#config-setting-awslogging");
            }

            serviceBus.StopReceiving();

            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();
        }
 public SNSToSQSServiceBus(SNSPublisher publisher, SequentialSQSReceiver receiver) : 
     this(publisher, receiver, true)
 {
     _publisher = publisher;
     _receiver = receiver;
 }