Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- var factory = new ConnectionFactory()
- {
- UserName = "guest",
- Password = "guest",
- HostName = "localhost",
- VirtualHost = "103057"
- };
- using (var connection = factory.CreateConnection())
- using (var channel = connection.CreateModel())
- {
- channel.QueueDeclare("moja_koleja", false, false, false, null);
- channel.BasicQos(0, 1, false);
- // send/receive message
- for (int i = 0; i < 10; i++)
- {
- IBasicProperties properties = channel.CreateBasicProperties();
- properties.Headers = new Dictionary<string, object>();
- properties.Headers.Add("naglowek", i);
- string message = "wiadomosc " + i;
- var body = Encoding.UTF8.GetBytes(message);
- channel.BasicPublish("", "moja_koleja", properties, body);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement