Esempio n. 1
0
 internal bool CreateModel(string queueName)
 {
     if (string.IsNullOrEmpty(queueName))
     {
         throw new ArgumentException("The queue name has to be specified before.");
     }
     lock (_modelLock)
     {
         if (!IsConnected)
         {
             Connect();
         }
         if (_model == null || _model.IsClosed)
         {
             _model = _connection.CreateModel();
             // When AutoClose is true, the last channel to close will also cause the connection to close.
             // If it is set to true before any channel is created, the connection will close then and there.
             _connection.AutoClose = true;
             // Configure the Quality of service for the model. Below is how what each setting means.
             // BasicQos(0="Dont send me a new message untill I’ve finshed",  1= "Send me one message at a time", false ="Apply to this Model only")
             _model.BasicQos(0, 50, false);
             const bool durable = true, queueAutoDelete = false, exclusive = false;
             _model.QueueDeclare(queueName, durable, exclusive, queueAutoDelete, null);
             _properties = RabbitMQProperties.CreateDefaultProperties(_model);
         }
     }
     return(true);
 }
Esempio n. 2
0
 private void Publish(RoutingKey routingKey, Niffle niffle)
 {
     Channel.BasicPublish(exchange: ExchangeName, routingKey: routingKey.GetRoutingKey(),
                          basicProperties: RabbitMQProperties.CreateDefaultProperties(Channel), body: niffle.ToByteArray());
 }
Esempio n. 3
0
 private void Publish(RoutingKey routingKey, Niffle niffle)
 {
     //if (niffle.IsBackTesting) Thread.Sleep(50);
     Model.BasicPublish(exchange: ExchangeName, routingKey: routingKey.GetRoutingKey(),
                        basicProperties: RabbitMQProperties.CreateDefaultProperties(Model), body: niffle.ToByteArray());
 }