Connection Setup
Connect to RabbitMQ and configure how you consume messages
Last updated
Was this helpful?
Was this helpful?
// 1. Create a connection
IConnection connection = _connectionFactory.CreateConnection();
// 2. Create a model
IModel model = connection.CreateModel();
// 3. Configure Quality of Service
model.BasicQos(prefetchSize: 0, prefetchCount: 100, global: false);
// 4. Consume messages
EventingBasicConsumer consumer = new EventingBasicConsumer(model);
consumer.Received += (sender, eventArgs) => {
// Deserialize message, then handle it
};
// 5. Start consumption (replace with your Package ID)
model.BasicConsume(queue: "_YOUR_PACKAGE_ID_", noAck: true, consumer: consumer);