|
19 | 19 | import static com.rabbitmq.stream.impl.TestUtils.localhost;
|
20 | 20 | import static com.rabbitmq.stream.impl.TestUtils.waitAtMost;
|
21 | 21 | import static org.assertj.core.api.Assertions.assertThat;
|
| 22 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; |
22 | 23 |
|
23 | 24 | import com.rabbitmq.client.Connection;
|
24 | 25 | import com.rabbitmq.client.ConnectionFactory;
|
@@ -75,12 +76,20 @@ void tearDown() throws Exception {
|
75 | 76 | connection.close();
|
76 | 77 | }
|
77 | 78 |
|
| 79 | + @Test |
| 80 | + void exceptionShouldBeThrownWhenSuperStreamIsSetAndRoutingIsNotConfigured() { |
| 81 | + assertThatThrownBy(() -> environment.producerBuilder().superStream(superStream).build()) |
| 82 | + .isInstanceOf(IllegalArgumentException.class); |
| 83 | + } |
| 84 | + |
78 | 85 | @Test
|
79 | 86 | void allMessagesSentToSuperStreamWithHashRoutingShouldBeThenConsumed() throws Exception {
|
80 | 87 | int messageCount = 10_000;
|
81 | 88 | declareSuperStreamTopology(connection, superStream, partitions);
|
82 | 89 | Producer producer =
|
83 |
| - environment.producerBuilder().stream(superStream) |
| 90 | + environment |
| 91 | + .producerBuilder() |
| 92 | + .superStream(superStream) |
84 | 93 | .routing(message -> message.getProperties().getMessageIdAsString())
|
85 | 94 | .producerBuilder()
|
86 | 95 | .build();
|
@@ -133,7 +142,9 @@ void allMessagesSentToSuperStreamWithRoutingKeyRoutingShouldBeThenConsumed() thr
|
133 | 142 | routingKeys = new String[] {"amer", "emea", "apac"};
|
134 | 143 | declareSuperStreamTopology(connection, superStream, routingKeys);
|
135 | 144 | Producer producer =
|
136 |
| - environment.producerBuilder().stream(superStream) |
| 145 | + environment |
| 146 | + .producerBuilder() |
| 147 | + .superStream(superStream) |
137 | 148 | .routing(message -> message.getApplicationProperties().get("region").toString())
|
138 | 149 | .key()
|
139 | 150 | .producerBuilder()
|
@@ -183,7 +194,9 @@ void messageIsNackedIfNoRouteFound() throws Exception {
|
183 | 194 | routingKeys = new String[] {"amer", "emea", "apac"};
|
184 | 195 | declareSuperStreamTopology(connection, superStream, routingKeys);
|
185 | 196 | Producer producer =
|
186 |
| - environment.producerBuilder().stream(superStream) |
| 197 | + environment |
| 198 | + .producerBuilder() |
| 199 | + .superStream(superStream) |
187 | 200 | .routing(message -> message.getApplicationProperties().get("region").toString())
|
188 | 201 | .key()
|
189 | 202 | .producerBuilder()
|
@@ -216,7 +229,10 @@ void getLastPublishingIdShouldReturnLowestValue() throws Exception {
|
216 | 229 | declareSuperStreamTopology(connection, superStream, partitions);
|
217 | 230 | String producerName = "super-stream-application";
|
218 | 231 | Producer producer =
|
219 |
| - environment.producerBuilder().name(producerName).stream(superStream) |
| 232 | + environment |
| 233 | + .producerBuilder() |
| 234 | + .name(producerName) |
| 235 | + .superStream(superStream) |
220 | 236 | .routing(message -> message.getProperties().getMessageIdAsString())
|
221 | 237 | .producerBuilder()
|
222 | 238 | .build();
|
|
0 commit comments