Spring Integration AbstractMessageSourceAdvice 已弃用

huangapple go评论60阅读模式
英文:

Spring Integration AbstractMessageSourceAdvice is deprecated

问题

我正在使用AbstractMessageSourceAdvice来在轮询文件夹后执行操作,但它已被弃用,替代类是什么,您有教程吗?

这是我的代码:

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;
    }
}
英文:

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&lt;?&gt; afterReceive(Message&lt;?&gt; message, MessageSource&lt;?&gt; source) {
		if (message == null) {
			LOGGER.info(&quot;Empty folder , the process will stop&quot;);
			System.exit(0);
		}
		return message;
}

Thanks

答案1

得分: 1

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

 * @deprecated since 5.3 in favor of {@link MessageSourceMutator}.

I don't remember that I recommended you somewhere to use that abstract class: Stack Overflow Question

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

It also says that you use some old Spring Integration version. Consider upgrading to the latest one: Spring Integration

Also, please, learn how to ask questions here on Stack Overflow: How to Ask. It is really very hard to read questions with a lot of typos and no proper formatting for code.

英文:

Hm. 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: https://stackoverflow.com/questions/76515730/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

Also, please, learn how to ask questions here on StackOveflow: https://stackoverflow.com/help/how-to-ask. It is really very hard to read questions with a lot of typos and no proper formatting for code.

huangapple
  • 本文由 发表于 2023年6月26日 23:10:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76557983.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定