If you suspect issues with your RabbitMQ client you can test out connectivity problems using ToxiProxy.
Once ToxiProxy server is installed and running use the CLI to setup the proxy. The following command creates a local endpoint ‘localhost:5670’ which will proxy to ‘rabbitmq:5672’.
toxiproxy-cli-windows-amd64.exe create rabbitmq -l localhost:5670 -u rabbitmq:5672
With the proxy setup, you can configure your consumer to use ToxiProxy now. The following is an example C# consumer using EasyNetQ.
using (var bus = RabbitHutch.CreateBus("host=localhost:5670")) { LogProvider.SetCurrentLogProvider(ConsoleLogProvider.Instance); var source = bus.Advanced.ExchangeDeclare("jgr.debug.connection.issue", "topic"); var subscriptionQueue = bus.Advanced.QueueDeclare("jgr.debug.connection.issue.queue"); bus.Advanced.Bind(source, subscriptionQueue, "#"); bus.Advanced.Consume( subscriptionQueue, (body, properties, info) => { var json = Encoding.UTF8.GetString(body); Console.WriteLine(json); }); Console.ReadLine(); }
Now start adding toxic conditions:
Example add timeout
toxiproxy-cli-windows-amd64.exe toxic add rabbitmq -t timeout -a timeout=10000
Example remove timeout
toxiproxy-cli-windows-amd64.exe toxic remove rabbitmq -n timeout_downstream
Example add slow close
toxiproxy-cli-windows-amd64.exe toxic add rabbitmq -t slow_close -a delay=12000
Example remove slow close
toxiproxy-cli-windows-amd64.exe toxic remove rabbitmq -n slow_close_downstream
Example add latency
toxiproxy-cli-windows-amd64.exe toxic add rabbitmq -t latency -a latency=12000
Example remove slow latency
toxiproxy-cli-windows-amd64.exe toxic remove rabbitmq -n latency_downstream
To take a closer look setup wireshark to investigate further.
Leave a Reply