11package fr .rakambda .rsndiscord .spring .amqp ;
22
3- import com .fasterxml .jackson .databind .ObjectMapper ;
43import org .springframework .amqp .core .Binding ;
54import org .springframework .amqp .core .BindingBuilder ;
65import org .springframework .amqp .core .CustomExchange ;
98import org .springframework .amqp .rabbit .annotation .EnableRabbit ;
109import org .springframework .amqp .rabbit .connection .ConnectionFactory ;
1110import org .springframework .amqp .rabbit .core .RabbitTemplate ;
12- import org .springframework .amqp .support .converter .Jackson2JsonMessageConverter ;
11+ import org .springframework .amqp .support .converter .JacksonJsonMessageConverter ;
1312import org .springframework .beans .factory .annotation .Autowired ;
1413import org .springframework .beans .factory .annotation .Qualifier ;
1514import org .springframework .context .annotation .Bean ;
1615import org .springframework .context .annotation .Configuration ;
17- import org .springframework .retry .backoff .ExponentialBackOffPolicy ;
18- import org .springframework .retry .support .RetryTemplate ;
16+ import org .springframework .core .retry .RetryPolicy ;
17+ import org .springframework .core .retry .RetryTemplate ;
18+ import org .springframework .util .backoff .ExponentialBackOff ;
19+ import tools .jackson .databind .json .JsonMapper ;
1920import java .util .Map ;
2021
2122@ Configuration
@@ -47,14 +48,17 @@ public Binding delayBinding(@Qualifier("delayQueue") Queue testeQueue, @Qualifie
4748 }
4849
4950 @ Bean
50- public RabbitTemplate rabbitTemplate (ConnectionFactory connectionFactory , Jackson2JsonMessageConverter messageConverter ){
51- var backOffPolicy = new ExponentialBackOffPolicy ();
52- backOffPolicy .setInitialInterval (1000 );
53- backOffPolicy .setMultiplier (10 );
54- backOffPolicy .setMaxInterval (60000 );
51+ public RabbitTemplate rabbitTemplate (ConnectionFactory connectionFactory , JacksonJsonMessageConverter messageConverter ){
52+ var backOff = new ExponentialBackOff ();
53+ backOff .setInitialInterval (1000 );
54+ backOff .setMultiplier (10 );
55+ backOff .setMaxInterval (60000 );
5556
56- var retryTemplate = new RetryTemplate ();
57- retryTemplate .setBackOffPolicy (backOffPolicy );
57+ var retryPolicy = RetryPolicy .builder ()
58+ .backOff (backOff )
59+ .build ();
60+
61+ var retryTemplate = new RetryTemplate (retryPolicy );
5862
5963 var rabbitTemplate = new RabbitTemplate (connectionFactory );
6064 rabbitTemplate .setMessageConverter (messageConverter );
@@ -63,7 +67,7 @@ public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory, Jackso
6367 }
6468
6569 @ Bean
66- public Jackson2JsonMessageConverter producerJackson2MessageConverter (ObjectMapper jsonObjectMapper ){
67- return new Jackson2JsonMessageConverter ( jsonObjectMapper );
70+ public JacksonJsonMessageConverter producerJackson2MessageConverter (JsonMapper jsonMapper ){
71+ return new JacksonJsonMessageConverter ( jsonMapper );
6872 }
6973}
0 commit comments