Search code examples
spring-integration

Spring Integration AbstractMessageSourceAdvice is deprecated


I'm using an AbstractMessageSourceAdvice to achieve an action after polling on a folder but is is deprecated , what is the replacement class to this one and do you have a tutorial.

Here is my code:

public class EmptyFolderAdvice extends AbstractMessageSourceAdvice {

    private static final Logger LOGGER = LoggerFactory.getLogger(EmptyFolderAdvice.class);


    @Override
    public Message<?> afterReceive(Message<?> message, MessageSource<?> source) {
        if (message == null) {
            LOGGER.info("Empty folder , the process will stop");
            System.exit(0);
        }
        return message;
} 

Solution

  • I thought it should be very clear from JavaDocs of that deprecated class:

     * @deprecated since 5.3 in favor of {@link MessageSourceMutator}.
     */
    @Deprecated
    public abstract class AbstractMessageSourceAdvice implements MessageSourceMutator {
    

    I don't remember that I recommended you somewhere to use that abstract class: Spring integration stop gracefully application when no file in directory

    You definitely don't even need that "mutator" variant: you really don't mutate a message source, but whole application to make it stop.

    It also says that you use some old Spring Integration version. Consider to upgrade to the latest one: https://spring.io/projects/spring-integration#learn