Gatling Websocket implementation for subscribing to particular topic

329 views
Skip to first unread message

Vrushali Pathrikar

unread,
Aug 20, 2018, 5:16:10 AM8/20/18
to Gatling User Group
Hello everyone,

Is there any way to subscribe to topic using Gatling websocket implementation? for example, below is the code in java script - 

function connect() {
    var socket = new SockJS('http://localhost:8090/gs-guide-websocket');
    stompClient = Stomp.over(socket);
    stompClient.connect({}, function (frame) {
        setConnected(true);
        console.log('Connected: ' + frame);
        stompClient.subscribe('/topic/3d36d506-f0bf-4756-aa27-57add9ea7ebf', function (greeting) {
            showGreeting(greeting.body);
        });
    });
}

would like to make similar in Gatling.

Thanks,
Vrushalee 

Katerina Stepanova

unread,
Aug 21, 2018, 7:41:36 AM8/21/18
to Gatling User Group
You just need to send subscribe frame text to the websocket.
Text sent should look like smth like this:
val subscribeText = "[\"SUBSCRIBE\\nid:sub-1\\ndestination:/topic/3d36d506-f0bf-4756-aa27-57add9ea7ebf\\n\\n\\u0000\"]"

Basically, to deal with STOMP protocol over websocket in Gatling, you'll have to implement messages wrapping into proper STOMP frames yourself.
Don't forget to send CONNECT frame before subscribing to anything, sending other messages etc.

Vrushali Pathrikar

unread,
Aug 22, 2018, 11:31:01 AM8/22/18
to gat...@googlegroups.com
Hi Katerina,

I was able to subscribe to particular topic with your help. I am again stuck with one problem. My case study is below -

1.Websocket Simulation is written which will connect and subscribe to particular topic.
2. Another simulation is written where I am sending few http requests. Once these request are sent, I received 202 status code which means it is in the processing queue of websocket. Once These requests are successful, I received particular frame/message on websocket simulation.

How can I make sure that all frames/message are received on websocket for which requests are sent from second simulation. Basically, I am looking for communication between these two script to verify results.

Thanks,
Vrushalee


Reply all
Reply to author
Forward
0 new messages