Skip to content

Instantly share code, notes, and snippets.

@zhuqling
Created March 11, 2013 03:43
Show Gist options
  • Save zhuqling/5131747 to your computer and use it in GitHub Desktop.
Save zhuqling/5131747 to your computer and use it in GitHub Desktop.
RabbitMQ发送消息
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