7.3.3. Correlation Keys

A common requirement when working with processes is ability to assign a given process instance some sort of business identifier that can be later on referenced without knowing the actual (generated) id of the process instance. To provide such capabilities, jBPM allows to use CorrelationKey that is composed of CorrelationProperties. CorrelationKey can have either single property describing it (which is in most cases) but it can be represented as multi valued properties set.

Correlation capabilities are provided as part of interface

CorrelationAwareProcessRuntime

that exposes following methods:

  /**
  * Start a new process instance.  The process (definition) that should
  * be used is referenced by the given process id.  Parameters can be passed
  * to the process instance (as name-value pairs), and these will be set
  * as variables of the process instance.
  *
  * @param processId  the id of the process that should be started
  * @param correlationKey custom correlation key that can be used to identify process instance
  * @param parameters  the process variables that should be set when starting the process instance
  * @return the ProcessInstance that represents the instance of the process that was started
  */
  ProcessInstance startProcess(String processId, CorrelationKey correlationKey, Map<String, Object> parameters);

  /**
  * Creates a new process instance (but does not yet start it).  The process
  * (definition) that should be used is referenced by the given process id.
  * Parameters can be passed to the process instance (as name-value pairs),
  * and these will be set as variables of the process instance.  You should only
  * use this method if you need a reference to the process instance before actually
  * starting it.  Otherwise, use startProcess.
  *
  * @param processId  the id of the process that should be started
  * @param correlationKey custom correlation key that can be used to identify process instance
  * @param parameters  the process variables that should be set when creating the process instance
  * @return the ProcessInstance that represents the instance of the process that was created (but not yet started)
  */
  ProcessInstance createProcessInstance(String processId, CorrelationKey correlationKey, Map<String, Object> parameters);

  /**
  * Returns the process instance with the given correlationKey.  Note that only active process instances
  * will be returned.  If a process instance has been completed already, this method will return
  * null.
  *
  * @param correlationKey the custom correlation key assigned when process instance was created
  * @return the process instance with the given id or null if it cannot be found
  */
  ProcessInstance getProcessInstance(CorrelationKey correlationKey);

Correlation is usually used with long running processes and thus require persistence to be enabled to be able to permanently store correlation information.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值