Just contact, if there is not the right to the public static void StartUp () {#region preparatory work connectionfactory F Actory = new ConnectionFactory (); Factory. Uri = "amqp://guest:[email protected]:5672/"; Frame the physical link iconnection conn = factory. CreateConnection (); Create communication channel IModel CHANNEL = conn. Createmodel (); String exchangename = "I am the route 1 that is responsible for forwarding the signal"; String queuename = "I am the receiver of the signal 1"; Set up signals to route the channel. Exchangedeclare (Exchangename, exchangetype.direct); Set up a signal receiver channel. Queuedeclare (QueueName, False, False, false, NULL); Communicates the signal router and receiver channel. Queuebind (QueueName, Exchangename, "", null); #endregion byte[] messagebodybytes = System.Text.Encoding.UTF8.GetBytes ("Hello, world!"); Channel. Basicpublish (Exchangename, "", null,messagebodybytes); Ibasicproperties props = Channel. Createbasicproperties (); Props. ContentType = "Text/plain"; Props. DeliveryMode = 2; Channel. Basicpublish (Exchangename, "", props,messagebodybytes); ConnectionFactory service = new ConnectionFactory (); using (conn = service. CreateConnection ()) {using (IModel SERVICECHANNLE = conn. Createmodel ()) {//ch. Queuedeclare (QueueName, False, False, false, NULL); The server receives Message Queuing bool Noack = false; Basicgetresult result = Servicechannle. Basicget (QueueName, Noack); if (result = = null) {Console.WriteLine ("no Message"); } else {Servicechannle. Basicack (result. Deliverytag, false); Console.WriteLine ("Receive Message succeeded:" + result.) Basicproperties.contenttype); Console.WriteLine ("Receive Message succeeded:" + result.) BasIcproperties.deliverymode); Console.WriteLine ("Receive Message succeeded:" + System.Text.Encoding.Default.GetString (Result). Body)); }}} conn. AutoClose = true; }
RabbitMQ C # example-excerpt from the Web