RabbitMQ's first intimate contact

           Enterprise applications, if the communication, integration and integration between systems, especially when faced with heterogeneous systems, we need to communicate with distributed call. Systems generally have a lot of bits and pieces but place and time consuming less demanding real-time, such as sending text messages, e-mail alerts, logs and other records of user actions, in case the user access than the larger, more pressure on the system Big.

        Faced with these problems, we generally will these requests in the message queue MQ processing; using message communication between disparate systems.

        MQ called the Message Queue, the message queue (MQ) is an application communication method according to the application. Application to communicate via a message (data for the application program) read out of the queue, without the need for a dedicated connection to link them. Refers to message passing communication between a program in the data message transmitted by, rather than through direct calls to communicate with each other, is a technique commonly called directly, such as remote procedure calls. It refers to the application queue by the queue to communicate. Removed using a queue and transmission requirements received concurrently executing applications.

       http://www.rabbitmq.com/download.html installation server, due to the use RabbitMQ written in Erlang language, Erlang runtime environment installed language http://www.erlang.org/ , in accordance with the requirements of the installation and operation of the Internet Configuring environment variables, command line instruction browser management interface as follows:

Because I use C # language to be a simple verification, it is necessary to support the API, download the following address https://www.rabbitmq.com/releases/rabbitmq-dotnet-client/, many versions, as appropriate download

Reference RabbitMQ.Client.dll:

. 1      static  void the Main ( String [] args)
 2      {
 . 3          var Factory = new new the ConnectionFactory ();
 . 4          factory.HostName = " localhost " ; // RabbitMQ service running locally 
. 5          factory.UserName = " Guest " ; // username 
. 6          factory.Password = " Guest " ; // password 
. 7  
. 8          the using ( var Connection = factory.CreateConnection ())
. 9          {
 10              the using ( var Channel = connection.CreateModel ())
 . 11              {
 12 is                  channel.QueueDeclare ( " hello " , to false , to false , to false , null ); // create a name for the hello message queue 
13 is                  String Message = " the Hello world " ; // messaging content 
14                  var body = Encoding.UTF8.GetBytes (message);
 15                  channel.BasicPublish ( " ", " Hello " , null , body); // start transmission 
16                  Console.WriteLine ( " Sent: {0} " , Message); Console.ReadLine ();
 . 17              }
 18 is          }
 . 19      }

    A simple test is like, pay attention to before using RabitMQ, the first of several concepts and knowledge: production, queue, consumption, work queues, in rotation distribution, message response, message persistence, fair distribution, the network has the knowledge, no detailed solution of the ...

Switch to the next open cmd sbin directory rabbitmqctl status \ rabbitmq-service start \ rabbitmqctl list_users simple instruction

Well, to start playing now!

 

 

 

     

Guess you like

Origin www.cnblogs.com/shiningleo007/p/11412404.html