I am updating a project that sends rabbitMQ messages from spring boot to to spring boot 3 I THINK the current springboot 2 project uses spring-cloud-stream v3.2.3 to send the messages Here is a snippet of the service class where it sends the rabbitMQ messages
`@EnableBinding(MessageChannels.class) public class MessageService {
@Autowired
private MessageChannels messageSource;
public void send(String id, Map<String, Object> data, MessageChannel messageChannel, MessageType messageType, String messageTypeHeader) {
try {
MessageDTO message = new MessageDTO();
message.setId(id);
message.setData(data);
message.setMessageType(messageType);
Message m = MessageBuilder.withPayload(message)
.setHeader("messageType", messageTypeHeader)
.setHeader("messageSourceType", MessageSourceType.PLATFORM.name())
.build();
messageChannel.send(m);
}
}
`
The last statement, the send method is from an abstract class that is part of springboot 2 spring-cloud-stream (I think?) that implements the MessageChannel interface from spring-messaging v5.3.29. The code below is from that library
package org.springframework.messaging;
@FunctionalInterface
public interface MessageChannel {
long INDEFINITE_TIMEOUT = -1L;
default boolean send(Message<?> message) {
return this.send(message, -1L);
}
boolean send(Message<?> message, long timeout);
}
So with spring boot 3, I get an execution error that required bean for MessageChannel (interface) cannot be found. Apparently the abstract classes that implemented that interface are no longer included in springboot 3.
My question is does the prescribed upgrade path call for us to throw out this huge amount of code like above which utilizes MessageChannel interface and (to instead use the StreamBridge method), or can we keep the code and continue sending messages using the MessageChannel interface in Springboot 3 (which I THINK uses spring-cloud-stream 4.04)?