I’m trying to run a JMS load test using ActiveMQ. When I run the load test, I never see any OK nor KO’s - both 0. The test continues to run until I ctrl-c.
Here’s the script
`
import io.gatling.core.Predef._
import io.gatling.jms.Predef._
import io.gatling.jms.protocol._
import javax.jms._
import scala.concurrent.duration._
class TestSimulation extends Simulation {
val jmsConfig = jms
.connectionFactoryName(“ConnectionFactory”)
.url(“tcp://localhost:8292”)
.contextFactory(“org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory”)
.listenerCount(1)
.messageMatcher(MessageIDMessageMatcher)
val scn = scenario(“JMS Load Test”).repeat(1) {
exec(jms(“JMS Load Test”).reqreply
.queue(“EVENTS.INBOUND.POST”)
.textMessage(“MESSAGE BODY”)
.check(simpleCheck(checkBodyTextCorrect)))
}
setUp(scn.inject(constantUsersPerSec(1) during (1 minutes)))
.protocols(jmsConfig)
def checkBodyTextCorrect(m: Message) = {
m match {
case tm: TextMessage => tm.getText == “MESSAGE BODY”
case _ => false
}
}
}
`
Here’s the receiver side
`
public class JMSConsumer implements MessageListener {
private static final Logger LOG = LoggerFactory.getLogger(JMSConsumer.class);
private final JMSProducer jmsProducer;
public JMSConsumer(final JMSProducer jmsProducer) {
this.jmsProducer = jmsProducer;
}
@Override
public void onMessage(final Message message) {
try {
message.acknowledge();
jmsProducer.sendMessage(message);
} catch (final Exception ex) {
LOG.error(ex.getMessage(), ex);
}
}
}
public class JMSProducer {
private final JmsTemplate template;
public JMSProducer(final JmsTemplate template) {
this.template = template;
}
public void sendMessage(final Message message) {
try {
template.send(message.getJMSReplyTo(), new MessageCreator() {
@Override
public Message createMessage(final Session session) throws JMSException {
try {
final TextMessage response = session.createTextMessage(message.getBody(String.class));
response.setJMSCorrelationID(message.getJMSCorrelationID());
response.setJMSMessageID(message.getJMSMessageID());
return response;
} catch (final Exception ex) {
throw new RuntimeException(ex);
}
}
});
} catch (final Exception ex) {
throw new RuntimeException(ex);
}
}
}
`