Ejemplo n.º 1
0
 protected override IQueue CreateQueue()
 {
     return(new ReliableSqsQueue(new DelayedQueue(SqsQueue.Create(
                                                      AmazonTest.ServiceId,
                                                      AmazonTest.ServiceSecret,
                                                      GetNextQueueName()), DelayMilliseconds)));
 }
        /// <summary>
        /// Configure the polling wait time for receive bus
        /// </summary>
        /// <param name="configuration">Configuration to modify</param>
        /// <param name="timeInSeconds">Number of seconds to the long polling to wait</param>
        /// <returns>Modified configuration</returns>
        public static IConfigureEventReceiving SetSqsPollWaitTime(this IConfigureEventReceiving configuration, int timeInSeconds)
        {
            if (timeInSeconds < 0 || timeInSeconds > 14)
            {
                throw new JungleBusConfigurationException("timeInSeconds", "Time in seconds must be between 0 and 14");
            }

            if (configuration.Receive == null)
            {
                throw new JungleBusConfigurationException("General", "Input queue needs to be configured before setting the wait timeout");
            }

            if (configuration == null)
            {
                throw new JungleBusConfigurationException("configuration", "Configuration cannot be null");
            }

            SqsQueue queue = configuration.Receive.InputQueue as SqsQueue;

            if (queue == null)
            {
                throw new InvalidOperationException("Queue is not a SQS queue");
            }

            queue.WaitTimeSeconds = timeInSeconds;

            return(configuration);
        }
Ejemplo n.º 3
0
        private void DeleteQueue(string queueName)
        {
            SqsQueue queue;

            if (SqsQueue.TryCreate(ServiceId, ServiceSecret, queueName, false, out queue))
            {
                queue.Delete();

                Console.WriteLine("Deleted {0} queue", queueName);
            }
            else
            {
                Console.WriteLine("Queue does not exist");
            }
        }
Ejemplo n.º 4
0
        private void DeleteQueues(string queueNamePrefix)
        {
            int deletedCount = 0;

            foreach (SqsQueue queue in SqsQueue.ListQueues(ServiceId, ServiceSecret))
            {
                if (queue.Name.StartsWith(queueNamePrefix))
                {
                    queue.Delete();

                    deletedCount++;
                }
            }

            Console.WriteLine("Deleted {0} queues", deletedCount);
        }
Ejemplo n.º 5
0
        private void ListQueues()
        {
            PrettyConsole console = new PrettyConsole();

            console.AddColumn("Name", 64);
            console.AddColumn("MessageCount", 16);
            console.AddColumn("MessageNotVisibleCount", 22);
            console.WriteHeader();

            foreach (SqsQueue queue in SqsQueue.ListQueues(ServiceId, ServiceSecret))
            {
                long messageCount;
                long messageNotVisibleCount;

                queue.GetInfo(out messageCount, out messageNotVisibleCount);

                console.WriteLine(queue.Name, messageCount, messageNotVisibleCount);
            }
        }
 public SqsConsumerSample(IServiceCollection services, ISqsClientHandler sqsClientHandler, SqsQueue sqsQueue) : base(services, sqsClientHandler, sqsQueue)
 {
 }
Ejemplo n.º 7
0
 protected SqsMessageConsumerHandler(IServiceCollection services, SqsQueue sqsQueue, AWSCredentials awsCredentials = null, RegionEndpoint regionEndpoint = null)
 {
     SqsClientHandler = new SqsClientHandler(awsCredentials, regionEndpoint);
     Services         = services;
     SqsQueue         = sqsQueue;
 }
Ejemplo n.º 8
0
 protected SqsMessageConsumerHandler(IServiceCollection services, ISqsClientHandler sqsClientHandler, SqsQueue sqsQueue)
 {
     SqsClientHandler = sqsClientHandler;
     Services         = services;
     SqsQueue         = sqsQueue;
 }
Ejemplo n.º 9
0
        private void CreateQueue(string queueName)
        {
            SqsQueue.Create(ServiceId, ServiceSecret, queueName);

            Console.WriteLine("Created {0} queue", queueName);
        }