public PersonQueue(QueueUow queueUow) { QueueUow = queueUow; QueueUow.Chanel.QueueDeclare( queue: QueueName, durable: true, exclusive: false, autoDelete: false, arguments: _queueParameters?.Build() ); }
public PersonDeadLetterQueue(QueueUow queueUow) { QueueUow = queueUow; //normal queue QueueUow.Chanel.QueueDeclare( queue: QueueName, durable: true, exclusive: false, autoDelete: false, arguments: null ); var deadLetterParameters = new QueueParameters(timeToLive: 15000, deadLetterExchange: ExcangeName); //retry queue QueueUow.Chanel.QueueDeclare( queue: RetryQueue, durable: true, exclusive: false, autoDelete: false, arguments: deadLetterParameters.Build() ); //error queue QueueUow.Chanel.QueueDeclare( queue: ErrorQueue, durable: true, exclusive: false, autoDelete: false, arguments: null ); QueueUow.Chanel.ExchangeDeclare( exchange: ExcangeName, type: "fanout", durable: true, autoDelete: false, arguments: null ); QueueUow.Chanel.QueueBind( queue: QueueName, exchange: ExcangeName, routingKey: string.Empty, arguments: null ); }
static void Main(string[] args) { Log.WriteLine("Start"); QueueUow uow = new QueueUow(); var personQueueWithDeadLetter = new PersonDeadLetterQueue(uow); Log.WriteLine("..:: Generating world ::.."); for (int i = 0; i < 100; i++) { var newPerson = new Person() { Age = i, Name = NameGenerator.Generate() }; Log.WriteLine($"..:: Sending {newPerson.Name} to World! ::.."); personQueueWithDeadLetter.Push(newPerson); } Log.WriteLine("..:: World is full of peoples ::.."); Log.WriteLine("..."); var personQueue = new PersonQueue(uow); Log.WriteLine("..:: Game Start ::.."); personQueueWithDeadLetter.ReadQueue((person) => { Log.WriteLine("..."); Log.WriteLine("-Shhh, there's someone comming..."); Task.Delay(500).Wait(); RollTheDice(); Log.WriteLine(person.SeyHello()); personQueue.Push(person); }); Log.WriteLine("Stop"); }