Tinkoff / gatling-amqp-plugin

Plugin for support performance testing with AMQP in Gatling (3.7.x)
Apache License 2.0
33 stars 20 forks source link

Unable to set queue properties while publishing #4

Closed MaheshGooner closed 4 years ago

MaheshGooner commented 4 years ago

Hi,

I am using your plugin to publish amqp messages to an existing queue. But the test fails to publish with the error

Wrapped by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'x-expi
res' for queue 'xxxxx-xxxxx-xxxxxx' in vhost '/': received none but current is the value '600000' of
 type 'long', class-id=50, method-id=10)

I assume that this if failing because i am unable to set the queue properties image

Below is my test

class PublishExample extends Simulation {

  val source: BufferedSource = Source.fromFile("./sport/icehockey.json")
  val payload: String = try source.mkString finally source.close()

  val amqpConf: AmqpProtocolBuilder = amqp
    .connectionFactory(
      rabbitmq
        .host("xxx-xxx")
        .port(5672)
        .vhost("/")
        .username("guest")
        .password("guest")
    ).replyTimeout(600000)
    .usePersistentDeliveryMode

  val cfProps: java.util.Map[String,AnyRef] = new java.util.HashMap[String,AnyRef]
  cfProps.put("'x-expires","600000")

  amqpConf.connectionFactory.setClientProperties(cfProps)

 val props: scala.collection.immutable.Map[String,String] =
    Map("content-type" -> "application/json",
      "contentEncoding" -> "utf-8",
      "[SerializerType]" -> "Newtonsoft.Json.JsonConverter"

  val scn: ScenarioBuilder = scenario("AMQP test")
    .feed(idFeeder)
    .exec(
      amqp("publish to exchange").publish
        .queueExchange("xxxx-xxxx-xxxx-xxxx")  .bytesMessage(payload.getBytes("UTF-8"))
        .property("x-expires",600000)
        .headers(props)
    )

  setUp(
    scn.inject(rampUsers(10) during (10 seconds))
  ).protocols(amqpConf)
    .maxDuration(10 minutes)

}

Could you please help ?

MaheshGooner commented 4 years ago

Also for a consumer test. could you please provide an example of consuming all messages from a queue(topic exchange) verifying each message with some checks using session please.

red-bashmak commented 4 years ago

Hi, You no need to pass params into ConnectionFactory. If you write .property("x-expires",600000), it added param to ConnectionFactory under hood.