【问题标题】:Mule custom filemessagereceiver - polling configurationMule 自定义 filemessagereceiver - 轮询配置
【发布时间】:2016-08-02 05:51:25
【问题描述】:

我是新来的骡子。我想使用 poll() 方法从本地文件夹接收文件。谁能告诉我如何为自定义 filemessagereceiver 编写覆盖 poll() ?

【问题讨论】:

  • 为什么要使用自定义文件消息接收器,而开箱即用的文件入站端点会为您轮询?
  • 覆盖 FMR 的用例是什么?

标签: java mule mule-studio mule-component mule-el


【解决方案1】:

在扩展FileReceiverCustomFileReceiver类中,您可以像这样重写所有继承的方法,例如processFilespoll

public class CustomFileReceiver extends FileMessageReceiver {

public CustomFileReceiver(org.mule.api.transport.Connector connector, FlowConstruct flowConstruct, InboundEndpoint endpoint,
        String readDir, String moveDir, String moveToPattern, long frequency) throws CreateException {
    super(connector, flowConstruct, endpoint, readDir, moveDir, moveToPattern, frequency);
}

@Override
public void poll() {
    // perform your special poll

}

}

HTH

【讨论】:

  • 谢谢阿尼尔库马尔。我做了同样的方法,但我无法在 poll() 方法中列出文件。无法为 listFiles() 添加覆盖注释。如果我删除注释,则会收到警告为“方法 CustomFileMessageReceiver.listFiles() 不会覆盖从 FileMessageReceiver 继承的方法,因为它是不同包的私有方法”。
  • listFiles() 方法的作用域是默认的,它不能被 FileMessageReceiver 覆盖。如果您的要求是覆盖默认作用域方法以及 poll() 方法,那么您需要扩展 AbstractPollingMessageReceiver 或 AbstractMessageReceiver 并在自定义类中模仿 FileMessageReceiver 的逻辑。
  • 然后使用标签
  • 抱歉回复晚了。我尝试了与您提到的相同的方法,它工作正常。非常感谢
  • 感谢您的更新,如果对您有帮助,请务必投票/接受答案,以便其他人可以参考和受益。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-20
相关资源
最近更新 更多