Skip to content

Commit

Permalink
feat : let spring boot handle MessageConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Dec 29, 2024
1 parent 40f6b30 commit edc4034
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.autoconfigure.amqp.RabbitTemplateCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -77,16 +78,12 @@ Binding deadLetterBinding(Queue deadLetterQueue, FanoutExchange deadLetterExchan
}

@Bean
RabbitTemplateCustomizer rabbitTemplateCustomizer(
Jackson2JsonMessageConverter producerJackson2MessageConverter) {
return rabbitTemplate -> {
rabbitTemplate.setMessageConverter(producerJackson2MessageConverter);
rabbitTemplate.setConfirmCallback(rabbitTemplateConfirmCallback);
};
RabbitTemplateCustomizer rabbitTemplateCustomizer() {
return rabbitTemplate -> rabbitTemplate.setConfirmCallback(rabbitTemplateConfirmCallback);
}

@Bean
Jackson2JsonMessageConverter producerJackson2MessageConverter() {
MessageConverter producerJackson2MessageConverter() {
return new Jackson2JsonMessageConverter();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import java.util.StringJoiner;

@Entity
public class TrackingState {
Expand Down Expand Up @@ -46,4 +47,13 @@ public TrackingState setStatus(String status) {
this.status = status;
return this;
}

@Override
public String toString() {
return new StringJoiner(", ", TrackingState.class.getSimpleName() + "[", "]")
.add("id=" + id)
.add("correlationId='" + correlationId + "'")
.add("status='" + status + "'")
.toString();
}
}

0 comments on commit edc4034

Please sign in to comment.