ule子批处理vs foreach vs拆分器聚合器 [英] Mule batch processing vs foreach vs splitter-aggregator

查看:61
本文介绍了ule子批处理vs foreach vs拆分器聚合器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mule中,我要处理很多记录,其中处理包括一些计算,来回数据库等.我们可以使用这些选项来处理记录的集合

In Mule, I have quite many records to process, where processing includes some calculations, going back and forth to database etc.. We can process collections of records with these options

  1. 批处理
  2. ForEach
  3. 拆分器聚合器

  1. Batch processing
  2. ForEach
  3. Splitter-Aggregator

那么它们之间的主要区别是什么?我们什么时候应该偏爱别人?

So what are the main differences between them? When should we prefer one to others?

例如,

Mule批处理选项似乎没有批处理作业范围变量定义.或者,如果我想受益于多线程来固定整个任务呢?或者,如果我想在处理期间修改有效负载,哪个更好?

Mule batch processing option does not seem to have batch job scope variable definition, for example. Or, what if I want to benefit multithreading to fasten the overall task? Or, which is better if I want to modify the payload during processing?

推荐答案

当您写很多"时,我认为它对于主内存来说太多了,这排除了拆分器/聚合器,因为它必须收集所有记录以将它们返回为列表.

When you write "quite many" I assume it's too much for main memory, this rules out spliter/aggregator because it has to collect all records to return them as a list.

我假设您的流或迭代器中有记录,否则您可能会遇到内存问题...

I assume you have your records in a stream or iterator, otherwise you probably have a memory problem...

那么什么时候使用for-each和何时使用批处理?

So when to use for-each and when to use batch?

最简单的解决方案,但有一些缺点:

The most simple solution, but it has some drawbacks:

  1. 它是单线程的(因此对于您的用例而言可能太慢了)
  2. 这是生与死":您无法在循环中收集任何信息,例如记录数
  3. 不支持处理破碎"记录

在循环中,您可以有几个步骤(消息处理器)来处理您的记录(例如,提到的数据库查找).

Within the loop, you can have several steps (message processors) to process your records (e.g. for the mentioned database lookup).

可能是一个缺点,可能是一个优点:循环是同步的. (如果要处理异步,请将其包装在async-scope中.)

May be a drawback, may be an advantage: The loop is synchronous. (If you want to process asynchronous, wrap it in an async-scope.)

有更多要做的事情/要理解的东西,但有更多功能:

A little more stuff to do / to understand, but more features:

  1. 从流中调用时,总是异步的(这可能是一个缺点).
  2. 可以是独立的(例如,内部可以进行民意调查)
  3. 在加载阶段生成的数据太大时,它会自动卸载到磁盘上.
  4. 免费多线程(可配置线程数)
  5. 处理破记录":批处理步骤仅可用于良好/破记录.
  6. 您将在最后获得统计信息(记录数,成功记录数等)

所以看起来您最好使用批处理.

So it looks like you better use batch.

这篇关于ule子批处理vs foreach vs拆分器聚合器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆