8.2. 接收消息
要接收消息,创建一个连接、会话和接收器链接,然后调用 Receiver.Receive()
方法并使用返回的 Message
对象。
示例:接收消息
Connection connection = new Connection(new Address("amqp://example.com")); Session session = new Session(connection); ReceiverLink receiver = new ReceiverLink(session, "receiver-1", "jobs"); Message message = receiver.Receive(); receiver.Accept(message);
Receiver.Accept()
调用告诉远程对等点,消息已被接收和处理。
如需更多信息,请参阅 Receive.cs 示例。