如何使用Spring Boot和Flowable修改邮件任务数据

问题描述 投票:0回答:1

我创建了邮件任务配置

<serviceTask id="mailtask_name" name="Name" flowable:delegateExpression="${STCustomMail}" flowable:type="mail" >
  <extensionElements>
    <flowable:field name="to">
      <flowable:string><![CDATA[[email protected]]]></flowable:string>
    </flowable:field>
    <flowable:field name="subject">
      <flowable:string><![CDATA[Subject]]></flowable:string>
    </flowable:field>
    <flowable:field name="text">
      <flowable:string><![CDATA[Text]]></flowable:string>
    </flowable:field>
  </extensionElements>
</serviceTask>

和班级:

@Log
@Service
public class STCustomMail implements JavaDelegate {

   private Expression subject;
   private Expression to;
   private Expression text;

   public void execute(DelegateExecution execution) {
      log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
      String subjectText = "New subject";
      execution.setVariable(subject.getValue(execution).toString(), subjectText);
      execution.setVariable(to.getValue(execution).toString(), "[email protected]");
      execution.setVariable(text.getValue(execution).toString(), "newtext");
   }
}

不幸的是,我的STCustomMail类无法正常工作。我无法修改任何邮件数据。

怎么了?

也许有另一种解决方案如何配置/创建动态(?)邮件数据位置?

java spring-boot bpmn flowable
1个回答
1
投票

flowable:delegateExpressionflowable:type不能混在一起。

默认情况下,当flowable:typemail时,Flowable将使用MailActivityBehavior执行电子邮件的发送。这意味着你的JavaDelegate永远不会被调用。

如果要更改邮件活动行为,则需要为其提供自己的实现。为了做到这一点,你需要提供自己的ActivityBehaviorFactory(你可以扩展DefaultActivityBehaviorFactory)并覆盖以下方法:

  • MailActivityBehavior createMailActivityBehavior(ServiceTask serviceTask)
  • MailActivityBehavior createMailActivityBehavior(SendTask sendTask)
© www.soinside.com 2019 - 2024. All rights reserved.