B.4. Interop.Drain.cs、Interop.Spout.cs(性能练习器)
AMQ .NET 示例 Interop.Drain 和 Interop.Spout 演示了与红帽 AMQ 互连的交互。在这种情况下没有消息代理。相反,Red Hat AMQ Interconnect 注册客户端程序请求的地址,并在它们之间路由消息。
Interop.Drain 命令行选项
$ Interop.Drain.exe --help Usage: interop.drain [OPTIONS] --address STRING Create a connection, attach a receiver to an address, and receive messages. Options: --broker [amqp://guest:guest@127.0.0.1:5672] - AMQP 1.0 peer connection address --address STRING [] - AMQP 1.0 terminus name --timeout SECONDS [1] - time to wait for each message to be received --forever [false] - use infinite receive timeout --count INT [1] - receive this many messages and exit; 0 disables count based exit --initial-credit INT [10] - receiver initial credit --reset-credit INT [5] - reset credit to initial-credit every reset-credit messages --quiet [false] - do not print each message's content --help - print this message and exit Exit codes: 0 - successfully received all messages 1 - timeout waiting for a message 2 - other error
Interop.Spout 命令行选项
$ interop.spout --help Usage: Interop.Spout [OPTIONS] --address STRING Create a connection, attach a sender to an address, and send messages. Options: --broker [amqp://guest:guest@127.0.0.1:5672] - AMQP 1.0 peer connection address --address STRING [] - AMQP 1.0 terminus name --timeout SECONDS [0] - send for N seconds; 0 disables timeout --durable [false] - send messages marked as durable --count INT [1] - send this many messages and exit; 0 disables count based exit --id STRING [guid] - message id --replyto STRING [] - message ReplyTo address --content STRING [] - message content --print [false] - print each message's content --help - print this message and exit Exit codes: 0 - successfully received all messages 2 - other error
Interop.Spout 和 Interop.Drain 示例调用
在一个窗口中运行 Interop.drain。排空会永远等待一条消息到达。
$ Interop.Drain.exe --broker amqp://10.10.2.2:5672 --forever --count 1 --address amq.topic
在另一个窗口中运行 Interop.spout。spout 将消息发送到代理地址并退出。
$ interop.spout --broker amqp://10.10.2.2:5672 --address amq.topic $
现在,在第一个窗口中排空将收到来自 spout 的消息,然后退出。
$ Interop.Drain.exe --broker amqp://10.10.2.2:5672 --forever --count 1 --address amq.topic Message(Properties=properties(message-id:9803e781-14d3-4fa7-8e39-c65e18f3e8ea:0), ApplicationProperties=, Body= $