-
Notifications
You must be signed in to change notification settings - Fork 19
/
RequestReplyTwoBrokerExample.kt
76 lines (69 loc) · 2.34 KB
/
RequestReplyTwoBrokerExample.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package ru.tinkoff.gatling.amqp.javaapi.examples
import io.gatling.javaapi.core.CoreDsl
import io.gatling.javaapi.core.CoreDsl.*
import io.gatling.javaapi.core.ScenarioBuilder
import io.gatling.javaapi.core.Simulation
import ru.tinkoff.gatling.amqp.javaapi.AmqpDsl
import ru.tinkoff.gatling.amqp.javaapi.AmqpDsl.amqp
class RequestReplyTwoBrokerExample : Simulation() {
override fun before() {
// For this test-example we define a consumer in your setup this should not be required, because
// you already have a rabbitmq-consumer.
SimpleRabbitMQClient.setup()
SimpleRabbitMQClient.readAndWrite()
}
override fun after() {
SimpleRabbitMQClient.tearDown()
}
val amqpConf = AmqpDsl.amqp()
.connectionFactory(
AmqpDsl.rabbitmq()
.host("localhost")
.port(5672)
.username("guest")
.password("guest")
.vhost("/")
.build(),
AmqpDsl.rabbitmq()
.host("localhost")
.port(5673)
.username("guest")
.password("guest")
.vhost("/")
.build()
)
.replyTimeout(60000L)
.consumerThreadsCount(8)
.matchByMessageId()
.usePersistentDeliveryMode()
val scn: ScenarioBuilder = CoreDsl.scenario("Request Reply AMQP test")
.feed(Utils.idFeeder)
.exec(
amqp("Request Reply exchange test")
.requestReply()
.queueExchange("readQueue")
.replyExchange("writeQueue")
.textMessage("{\"msg\": \"Hello message - #{id}\"}")
.messageId("#{id}")
.priority(0)
.contentType("application/json")
.headers(mapOf(Pair("test", "performance"), Pair("extra-test", "34-#{id}")))
.check(
bodyString().exists(),
bodyString().`is`("Message processed")
)
)
init {
setUp(
scn.injectOpen(
rampUsersPerSec(1.0)
.to(5.0)
.during(60),
constantUsersPerSec(5.0)
.during(2 * 60)
)
)
.protocols(amqpConf)
.maxDuration(10 * 60);
}
}