2

I'm running ActiveMQ Artemis with stomp port on 61623 and a Spring Boot application.

I need to perform a load test against it and want to send simple stomp messages to the broker.

Which sampler can I use? Is TCP Sampler suitable here?

Or can I use JMS Publisher and add e.g. StompJmsInitialContextFactory.class from "org.fusesource" as "Initial Context Factory"? I can not get it running.

My tryings:

CONNECT
accept-version:1.0,1.1,1.2
host:127.0.0.1
login:<...>
passcode:<...>

^@
SEND
version:1.0,1.1,1.2
session:?
destination:/queue/test

{<data>}
^@

Result:

Thread Name:Create Events 1-1
Sample Start:2022-10-27 08:00:30 MESZ
Load time:2015
Connect Time:2
Latency:0
Size in bytes:0
Sent bytes:0
Headers size in bytes:0
Body size in bytes:0
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):text
Response code:500
Response message:org.apache.jmeter.protocol.tcp.sampler.ReadException: Error reading from server, bytes read: 0


SampleResult fields:
ContentType: 
DataEncoding: windows-1252
Cat
  • 62
  • 7

1 Answers1

0

You need to simulate your ActiveMQ broker usage just like it will be used in production.

You have 2 options:

  1. JMS API
  2. WebSockets

none of them can be implemented using TCP Sampler.

For JMS API you will need to use JSR223 Sampler and Groovy language as JMeter's built-in JMS test elements don't give you the necessary level of flexibility, example code can be found in the Stomp protocol chapter of the ActiveMQ documentation

private String xmlObject = "<pojo>\n"
+ "  <name>Dejan</name>\n"
+ "  <city>Belgrade</city>\n"
+ "</pojo>";

public void testTransformationReceiveXMLObject() throws Exception {

    MessageProducer producer = session.createProducer(new ActiveMQQueue("USERS." + getQueueName()));
    ObjectMessage message = session.createObjectMessage(new SamplePojo("Dejan", "Belgrade"));
    producer.send(message);

    String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;
    stompConnection.sendFrame(frame);

    frame = stompConnection.receiveFrame();
    assertTrue(frame.startsWith("CONNECTED"));

    frame = "SUBSCRIBE\n" + "destination:/queue/USERS." + getQueueName() + "\n" + "ack:auto" + "\n" + "transformation:jms-object-xml\n\n" + Stomp.NULL;
    stompConnection.sendFrame(frame);

    frame = stompConnection.receiveFrame();

    assertTrue(frame.trim().endsWith(xmlObject));

    frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
    stompConnection.sendFrame(frame);
}       

For WebSockets you can take a look at JMeter Web Socket Stomp Sampler plugin.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • 1
    STOMP is a TCP-based protocol. How come the TCP sampler can't be used to send STOMP frames via TCP? – Justin Bertram Oct 28 '22 at 04:44
  • 1
    The sample code you pasted from the ActiveMQ documentation is demonstrating how to use the `transformation` header with a STOMP client to get XML text output from a JMS `ObjectMessage`. I don't see how this helps the OP test STOMP which is not directly related to JMS. Can you elaborate on how the sample code helps here? – Justin Bertram Oct 28 '22 at 04:53