1

I'm looking for a way to "listen" to server sent events (sse) within JMeter for a certain amount of time or a certain content.

I haven't found a proper way yet. There is no sampler I could use. I found a javascript library eventsource which would help me doing this put when I try to use the content of it I receive the error:

message:javax.script.ScriptException: ReferenceError: "require" is not defined 

And then something like that to use the library:

var source = new EventSource('/events');
source.onmessage = function(e) {
  log.info(e.data);
};

What can I do to listen to sse within JMeter with the least dependencies possible (SSH command? Groovy? Java? Javascript?)?

As an alternative I found Gatling.io but I would really like to keep the dependencies as less as possible and not introduce another tool.

Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92

1 Answers1

1

I believe Groovy is a viable option, JAX RS API has SseEventSource class which you can use to wait for server-side events.

More information:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • thank you for your reply. Is there an example how to import an external class into groovy so I could use it. I tried with `import javax.ws.rs.client.Client; Client sseClient;` – Bruno Bieri Dec 14 '17 at 14:04
  • You need to add JAX RS jars into [JMeter Classpath](http://jmeter.apache.org/usermanual/get-started.html#classpath) first – Dmitri T Dec 14 '17 at 14:07