Hi there,
I am still new to Gatling and scala and have just gone through various documentation and looks like a very fascinating tool and trying my hard to get this working.
What I am trying to do is to publish a lot of messages to RabbitMQ for load testing. However the message I publish has an id in it which need to be unique for each message published.
So I have a message Template in which the delivery id will be replaced fr each message published.
So I tried using the feeder route which never worked, so thought of using session function like below.
So my scenario looks like below
val messageTemplate: String = Source.fromFile(“src/test/resources/data/Delivery.json”).getLines.mkString // This is where I get the messageTemplate from a file to a string
//Rabbit connection
implicit val amqpProtocol: AmqpProtocol = amqp.host(RMQ_HOST)
.port(5672) //.vhost("/")
.auth(“guest”, “guest”)
.poolSize(10)
val publishDelivery = scenario(“Publish Delivery”).forever (
pace(1 seconds)
.exec( // My idea here is to uniquely generate an id for the session and replace that in the template in tis exec block and store it in session
session => {
var message:String = messageTemplate.replace("${deliveryId}", Random.nextInt(10000000).toString)
session.set(“message”, message)
session
}
).exec(amqp(“Publish”).publish(PublishRequest(queue, session(“message”).as[String]))) // This exec is to actually publish the message to RabbitMQ by fetching the session value for "message"
)
However the second exec block doesn’t recognise the session(“message”)
Can you anyone suggest me where I am going wrong? Or any better solutions please? Excuse me as I am still learning and very new to this exciting tool.
Cheers