-
Notifications
You must be signed in to change notification settings - Fork 19
/
RequestReplyTwoBrokerExample.java
81 lines (70 loc) · 2.93 KB
/
RequestReplyTwoBrokerExample.java
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
77
78
79
80
81
package ru.tinkoff.gatling.amqp.javaapi.examples;
import io.gatling.javaapi.core.ScenarioBuilder;
import io.gatling.javaapi.core.Simulation;
import ru.tinkoff.gatling.amqp.examples.utils.SimpleRabbitMQClient;
import ru.tinkoff.gatling.amqp.javaapi.protocol.AmqpProtocolBuilder;
import java.util.Map;
import static io.gatling.javaapi.core.CoreDsl.*;
import static ru.tinkoff.gatling.amqp.javaapi.AmqpDsl.*;
public class RequestReplyTwoBrokerExample extends Simulation {
@Override
public void 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
public void after() {
SimpleRabbitMQClient.tearDown();
}
public AmqpProtocolBuilder amqpConf = amqp()
.connectionFactory(
rabbitmq()
.host("localhost")
.port(5672)
.username("guest")
.password("guest")
.vhost("/")
.build(),
rabbitmq()
.host("localhost")
.port(5673)
.username("guest")
.password("guest")
.vhost("/")
.build()
)
.replyTimeout(60000L)
.consumerThreadsCount(8)
.matchByMessageId()
.usePersistentDeliveryMode();
public ScenarioBuilder scn =
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(Map.of("test", "performance", "extra-test", "34-#{id}"))
.check(
bodyString().exists(),
bodyString().is("Message processed")
)
);
{
setUp(
scn.injectOpen(rampUsersPerSec(1)
.to(5)
.during(60),
constantUsersPerSec(5)
.during(2 * 60)
))
.protocols(amqpConf)
.maxDuration(10 * 60);
}
}