RSS

Tag Archives: Rabbit MQ

Using RabbitMQ in C# (III) Consuming messages from RabbitMQ


It can be found that In earlier posts, setup RabbitMQ and sending messages are a piece of cake using RabbitMQ C# client. Let’s take a further step and see how to consume messages from RabbitMQ.

Create a console application, and add below code:

public static void Main()
{
        var factory = new ConnectionFactory() { HostName = "…" };
        using (var connection = factory.CreateConnection())
        {
            using (var channel = connection.CreateModel())
            {
//Assuming you have a queue named “whatever” created already
var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; var message = Encoding.Default.GetString(body); Console.WriteLine(" [x] Received {0}", message); }; channel.BasicConsume("whatever", true, consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } } }

That is it! Simple?

Advertisements
 
Leave a comment

Posted by on August 17, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , , , , , ,

Using RabbitMQ in C# (II) Sending message to RabbitMQ


Create a Winform application, add below UI to the form:

image

Read the rest of this entry »

 
1 Comment

Posted by on August 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , ,

Using RabbitMQ in C# (I) Installation of RabbitMQ


image image

 

  • Select the server software on the desired platform and download the setup package. In this example, I will use windows installer.
  • Run the windows installer, and you will be prompted to install Erlang, follow the links and download install Erlang:

image

image image

Read the rest of this entry »

 
2 Comments

Posted by on August 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , ,