Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using RabbitMQ.Client;
- using RabbitMQ.Client.Events;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace rabbitmq
- {
- class Program
- {
- static void Main(string[] args)
- {
- var factory = new ConnectionFactory()
- {
- UserName = "dahjdrhx",
- Password = "ng-DairYiYJDTY9JyemWFB9By5WqxXcA",
- HostName = "eagle.rmq.cloudamqp.com",
- VirtualHost = "dahjdrhx"
- };
- using (var connection = factory.CreateConnection())
- using (var channel = connection.CreateModel())
- {
- channel.QueueDeclare("message_queue", true, false, false, null);
- var consumer = new EventingBasicConsumer(channel);
- for (int i = 0; i < 100; i++)
- {
- string message = "aaaa" + i.ToString();
- var body = Encoding.UTF8.GetBytes(message);
- channel.BasicPublish("", "message_queue", null, body);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement