这是状态机的用例吗?如果是这样,您建议使用哪个开源软件?

发布于 2024-10-07 16:08:25 字数 674 浏览 3 评论 0原文

我的应用程序需要从多个来源提取数据。以下需要用户定义

  1. 数据源的顺序
  2. 在顺序中,条件(如果有的话)确定是否使用数据源或跳过它

一旦用户定义了上述两项,应用程序将为他的“他随后将使用它来提取数据。

我想要一些指导,了解

  1. 我是否更好地编写自己的代码来处理顺序和条件,或者这是一个状态机用例
  2. 如果它是一个状态机用例那么哪个是提供此支持的更好的开源项目
  3. 有没有状态机规范? SCXML?
  4. 状态机的最佳开源实现有哪些?标准(按此顺序):基于标准、易于调试、易于嵌入、正在积极开发、支持状态机的运行时创建

用例:这是一个多租户应用程序。每个客户都将设计自己的编排并将其保存到数据库中。我们称之为登机客户。一旦客户登机,他的所有请求都将使用他之前保存的编排。

现在假设有 3 个数据源 A、B 和 C。Orchestrion

  • 1 中很少有可能的编排:Pull A、Pull B 和 然后在该订单
  • Orchestrion 2 中拉取 C:拉动 A,如果 A 返回错误,则拉动 B、拉动 B(所以基本上是(A 或 C)和 B)
  • Crchesrion 3:拉动 A、B 和 C。顺序并不重要。全部需要拉动(可能是并行的)

My app needs to pull data from MULTIPLE sources. The following needs to be user defined

  1. Order of the data sources
  2. Within the Order, Conditions (if at all) determine whether to use a data source or skip it

Once the user has defined the above two, the app will assign a name to his "orchestration" that he subsequently will use to pull the data.

I want some guidance on

  1. whether I am better of writing my own code to handle the order and conditions OR is this a state machine use case
  2. If it is a state machine use case then which is the better open source project providing this support
  3. Is there any specification for state machines? SCXML?
  4. Which are the best open source implementations of state machine? Criteria (in this order): Based on standard, easy to debug, easy to embed, actively being developed, support for runtime creation of the state machine

Use case: This is a multi-tenant app. Each customer is going to design his own orcehstration and save it to the db. This we call as boarding the customer. Once a customer has been boarded, all his requests will use the orcestration he had saved earlier.

Now let us say there are 3 data sources A, B and C. Few of the possible orchestrations are

  • Orchestrion 1: Pull A, Pull B and
    then Pull C in that ORDER
  • Orchestrion 2: Pull A, if A returned error then pull B, pull B (so basically (A or C) and B)
  • Crchestrion 3: Pull A, B and C. order DOESNT matter. all need to be pulled (may be in parallel)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心作怪 2024-10-14 16:08:25

使用状态机的经验法则:

  • 您可以将其绘制为启动图,
  • 该过程可能会发生变化,但在给定点(即状态)执行的算法则不然 - 如果算法所做的事情受到
  • 您的 状态影响,那么仍然可以想要将能力扩展到非程序员的人来改变流程

为了您的目的,我将查看 JBoss 业务流程管理套件。您可以使用 XML 表示形式定义和管理状态机,包括允许其他人更改状态机的 GUI 编辑器,然后将其传递给“虚拟机”执行。定义语言提供了许多不同的钩子,用于自定义代码执行和建模更复杂的行为,例如并行流程、迭代活动和计划事件。

针对评论 #1 的更新

  1. 更抽象地说,如果您可以将其绘制为方框和线条(UML 符合条件),那么我认为它符合条件。
  2. 鉴于您所描述的用例,我会将每个数据源建模为一个状态 - 为了方便起见,您可以打破这种一对一映射(即每个状态执行多个数据源)。状态之间的转变决定秩序。根据条件限制转换。
  3. 在我看来,另一个用户驱动这是状态机解决方案最引人注目的原因。 SCXML 或 jPDL (XML 定义 jPBM 运行)实际上是状态的序列化转换为 XML。该 XML 可以在 GUI 中操作 - 两个项目都有基于 Eclipse 的 GUI。这允许数据(即数据源)按照每个用户特定的流程(状态、转换和条件)进行传输。
  4. jPBM 执行引擎是可嵌入的,所以我认为它并不像您怀疑的那么重。 jBPM 的语言 - jPDL - 具有良好的工具支持。我查看了 SCXML,它的功能似乎与 jPDL 大致相同,但文档和成熟度较低。此外,jPBM 允许定义要执行的类作为内联类路径引用,而 SCXML 使用 XML 命名空间的间接寻址。

我会研究并比较 SCXML 和 jPDL 规范。我的印象是 SXCML 是 jPDL 的超集,例如 jPDL 能够将重复任务作为其定义的一部分,而 SCXML 似乎则不然。

Rules of thumb for using a state machine:

  • you can diagram it as a start chart
  • the process is likely the change but the algorithms executed at a given point (i.e. state) are not - still OK if what the algorithm does is impacted by state
  • you want to extend the ability to someone who is not a programmer to alter the process

For your purpose I would look at the JBoss Business Process Management suite. You have the ability to define and manage the state machine using an XML representation, including a GUI editor for allowing others to alter it, and then pass it to a "virtual machine" for execution. The definition language provides a lot of different hooks for custom code execution and modelling more complex behaviors such as processes in parallel, iterative activities and scheduled events.

Update in Response to Comment #1

  1. Speaking more abstractly, if you can draw it as boxes and lines (UML would qualify), then I think it qualifies.
  2. Given the use case you've described I would model each data source as a State - you could break this one-to-one mapping for convenience sake (i.e. execute more than one data source per State). Transitions between States determine Order. Restrict Transitions based on Conditions.
  3. That another user drives this is the most compelling reason for a state machine solution in my opinion. SCXML or jPDL (XML definition jPBM runs) effectively are serializations of the state transitions as XML. This XML can be manipulated in a GUI - both projects have Eclipse based GUIs. This allows data (i.e. Data Sources) to travel with process (State, Transitions and Conditions) specific to each user.
  4. jPBM execution engine is embeddable, so I don't think it's as heavy weight as you suspect. jBPM's language - jPDL - has good tooling support. I reviewed SCXML and it appears to do roughly the same things as jPDL, but documentation and maturity are lower. Also, jPBM allows defining what class to execute as a class path reference inline, whereas SCXML uses the indirection of XML namespaces.

I would study and compare SCXML and the jPDL specs. My impression is that SXCML is superset of jPDL, for instance jPDL has the ability to repeat tasks as part of its definition whereas SCXML does not appear so.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文