@@ -228,4 +228,61 @@ void binding() {
228
228
.key ("foo" )
229
229
.unbind ();
230
230
}
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
+ }
231
288
}
0 commit comments