Demo of measuring time from RabbitMQ to Websocket

I hacked a little bit on the weekend and got some (imo) cool test to work, where I am measuring time between event A to event B. (I will explain better below)
I thought this is something to share with you guys, maybe somebody finds this use case interessting or usefull also for others. It also shows how you can “trick” gatling a little bit.
It also shows the way I use to synchronize virtual users (not sure if thats a good way to do it, would also appreciate feedback on this)

My use case is the following:
I have 3 services which are connected one after the other, like: ServiceA → ServiceB → ServiceC
ServiceA receives messages from RabbitMQ sends it further on the B which in turn sends it to C and this sends it over a Websocket to the Client.
Now I want to test the time it takes from the RabbitMQ message to the Client.

Looking more deeply into gatling it seems its build mainly (only) for request/response time measurement on the same “connection” but not between different connections or even protocols.
What I essentially ended up doing is sending the RabbitMQ message together with a dummy Websocket message (“test”) and then waiting for the resulting message on the Websocket.
I know its not clean and there are quite some error cases which are not correctly handled, but for simple usage it works quite fine.

I shared a trimmed down version of the code on github: https://github.com/leozilla/gatling-amqp-to-ws-demo
Basically the test first waits until X clients are subscribed and then it triggers the Rabbit message and one client (the one which sends the dummy WS message) waits for it.

Maybe you like the idea and maybe it would be even worth supporting this in gatling itself.