Skip to content

Commit a968c69

Browse files
committed
Add code samples for website documentation
1 parent b10d0de commit a968c69

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/test/java/com/rabbitmq/client/amqp/docs/WebsiteDocumentation.java

+57
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,61 @@ void binding() {
228228
.key("foo")
229229
.unbind();
230230
}
231+
232+
void resourceListeners() {
233+
Environment environment = null;
234+
235+
Connection connection = environment.connectionBuilder()
236+
.listeners(context -> { // set the listener
237+
context.previousState(); // the previous state
238+
context.currentState(); // the current (new) state
239+
context.failureCause(); // the cause of the failure (in case of failure)
240+
context.resource(); // the connection
241+
}).build();
242+
243+
Publisher publisher = connection.publisherBuilder()
244+
.listeners(context -> {
245+
// ...
246+
})
247+
.exchange("foo").key("bar")
248+
.build();
249+
250+
Consumer consumer = connection.consumerBuilder()
251+
.listeners(context -> {
252+
// ...
253+
})
254+
.queue("my-queue")
255+
.build();
256+
257+
}
258+
259+
void recovery() {
260+
Environment environment = null;
261+
Connection connection = environment.connectionBuilder()
262+
.recovery()
263+
.backOffDelayPolicy(BackOffDelayPolicy.fixed(Duration.ofSeconds(2)))
264+
.connectionBuilder().build();
265+
266+
267+
}
268+
269+
void deactivateTopologyRecovery() {
270+
Environment environment = null;
271+
Connection connection = environment.connectionBuilder()
272+
.recovery()
273+
.topology(false)
274+
.connectionBuilder()
275+
.listeners(context -> {
276+
277+
})
278+
.build();
279+
}
280+
281+
void deactivateRecovery() {
282+
Environment environment = null;
283+
Connection connection = environment.connectionBuilder()
284+
.recovery()
285+
.activated(false)
286+
.connectionBuilder().build();
287+
}
231288
}

0 commit comments

Comments
 (0)