Created
March 11, 2013 03:43
-
-
Save zhuqling/5131747 to your computer and use it in GitHub Desktop.
RabbitMQ发送消息
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IBasicProperties msgProps = new BasicProperties(); | |
msgProps.DeliveryMode = 2; // 1=临时,2=永久 | |
msgProps.ContentType = "application/json"; // mime type | |
msgProps.ReplyTo = qName; // 设置ReplyTo为匿名Queue,用于返回结果 | |
// 发送消息 | |
_chan.BasicPublish( | |
exchange:ExchangeName, | |
routingKey: RoutingKeyName, | |
basicProperties: msgProps, | |
body: Encoding.ASCII.GetBytes(json) // 建议使用ASCII编码,减少使用UTF8编码,以使内存占用最小化 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment