Beispiel #1
0
        public RabbitMq(bool durable)
        {
            _connection = _factory.CreateConnection();
            _session = durable ? _connection.CreateDurableSession() : _connection.CreateNonDurableSession();
            _props = _session.Model.CreateBasicProperties();
            _props.SetPersistent(true);

            _consumeThread = new Thread(ReadMessages);
        }
Beispiel #2
0
 public static RabbitSession CreateSession(this IConnection connection, bool durable)
 {
     var s = new RabbitSession { RoutingKey = "rk" + durable, QueueName = "q" + durable, ExchangeName = "ex" + durable };
     var model = connection.CreateModel();
     model.ExchangeDeclare(s.ExchangeName, ExchangeType.Direct, true);
     model.QueueDeclare(s.QueueName, true);
     model.QueueBind(s.QueueName, s.ExchangeName, s.RoutingKey, true, null);
     s.Model = model;
     return s;
 }