仅在另一个处理器不执行时如何执行处理器? [英] How to execute a processor only when another processor is not executing?

查看:82
本文介绍了仅在另一个处理器不执行时如何执行处理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将数据插入/更新到表中.数据库系统不提供"Upsert"功能.因此,我将临时表用于插入,然后合并到最终"表中,最后将截断该临时表.

I am inserting/updating data into a table. The database system does not provide an "Upsert" functionality. Thus I am using a staging table for the insert followed by a merge into the "final" table and finally I am truncating the staging table.

这会导致比赛状态.如果在合并+截断之间的临时表中插入了新数据,则该数据将丢失.

This leads to a race condition. If new data is inserted into the staging table between the merge+truncate this data is lost.

我如何确保不会发生这种情况?

How can I make sure this does not happen?

我试图通过Wait/Notify对此建模,但这也不是一个干净的解决方案.可以填充将数据放入暂存表中" PutDatabaseRecord处理器的队列,并且仍可以执行用于插入/更新的MergeVertica" ExecuteSQL.

I have tried to model this via Wait/Notify, but this is not a clean solution either. The queue for the "Put Data into staging table" PutDatabaseRecord processor could be filled and "MergeVertica for Insert/Update" ExecuteSQL could still execute.

推荐答案

我将使用阈值为60或30秒的 MonitorActivity 处理器,并使用持续发送消息的非活动输出设置为"false".

I would use a MonitorActivity processor with a 60 or 30 sec threshold and use the Inactive output with a Continually Send Messages set to "false".

SQL成功插入到您的 MonitorActivity 的临时连接中,这样,如果在最近X秒钟内未看到任何活动,他将触发一个流文件,该文件将启动您的合并过程.

Have the success of the SQL inserts into staging connection into your MonitorActivity, this way if no activity is seen in the last X seconds he will trigger a flowfile that will start your Merge Process.

https://codeshare.io/aJNNkn

这篇关于仅在另一个处理器不执行时如何执行处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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