Mule:入站连接器仅在满足业务需求时才消耗

Mule :Inbound connector consuming only if a business requirement is met

我在 mule 服务中有这个要求,它应该仅在业务条件成立时从入站连接器(流消息源)使用。我需要查看数据库是否满足该条件,然后只有我的入站连接器应该启动 consuming.Each 时间,它应该检查该条件并仅在条件为真时使用。建议在 mule 中实现实现的最佳方法。

如果不查看您的流程就很难说您到底想实现什么。通常,如果您希望入站端点使用并且流程正常工作,最好的选择是放置一个 message filterinbound endpoint 之后,它将检查条件并允许 message 传递给 next处理器..

既然你想从数据库中检查条件,你需要在入站端点之后放置一个数据库组件,它将从数据库中获取业务条件的值,然后你可以将 消息过滤器选择路由器消息负载传递给下一个Mule组件

这通常是使用 message filter integration pattern 完成的。

此模式在 Mule 中作为(且仅作为)过滤器实现,其他模式也可以实现这一点,特别是路由器和迂回,但更一致的方式是使用过滤器。

对于 Mule,您有许多过滤器,但是没有现成的 sql 基于查询的过滤器。这说。您有多种选择:

  • a Filter in java, that you could instantiate as a spring bean injected with the datasource and then use as a custom filter 带有 ar 参考。
  • 如果这意味着可重复使用,请作为 DevKit 模块实施。
  • 作为变通方法,实施 sub-flow 利用数据库连接器获取查询结果,然后在流结束时使用表达式过滤器过滤或不过滤。

虽然邮件过滤器在理论上是正确的,但实际上这通常是使用 Database Connector with a SELECT query that determines which rows should be processed in its WHERE clause. You can place the query in a <poll></poll> element at the beginning of a flow to execute the query on a schedule, as illustrated in the second example here 来完成的。