Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RabbitMqConsumer : IRabbitMqConsumer
- {
- private string _queueName = "uservote";
- private IConnection _rabbitMqConnection;
- private IModel _queueChannel;
- public RabbitMqConsumer()
- {
- var factory = Helpers.CreateConnectionFactory();
- _rabbitMqConnection = factory.CreateConnection();
- _queueChannel = _rabbitMqConnection.CreateModel();
- _queueChannel.QueueDeclare(queue: _queueName,
- durable: false,
- exclusive: false,
- autoDelete: false,
- arguments: null);
- var consumer = new EventingBasicConsumer(_queueChannel);
- //consumer.Received += Consume;
- _queueChannel.BasicConsume(queue: _queueName,
- autoAck: true,
- consumer: consumer);
- }
- private void Consume(object model, BasicDeliverEventArgs eventArgs)
- {
- }
- public void Dispose()
- {
- _queueChannel.Close();
- _rabbitMqConnection.Close();
- }
- }
- // Helpers
- public static ConnectionFactory CreateConnectionFactory()
- {
- return new ConnectionFactory
- {
- HostName = "localhost",
- Password = "guest",
- UserName = "guest"
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement