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

Java 如何使用Spring Boot和Flowable修改邮件任务数据,java,spring-boot,bpmn,flowable,Java,Spring Boot,Bpmn,Flowable,我创建了邮件任务配置 <serviceTask id="mailtask_name" name="Name" flowable:delegateExpression="${STCustomMail}" flowable:type="mail" > <extensionElements> <flowable:field name="to"> <flowable:string><![CDATA[mail@mail.com]

我创建了邮件任务配置

<serviceTask id="mailtask_name" name="Name" flowable:delegateExpression="${STCustomMail}" flowable:type="mail" >
  <extensionElements>
    <flowable:field name="to">
      <flowable:string><![CDATA[mail@mail.com]]></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>
不幸的是,我的STCustomMail类无法工作。我无法修改任何邮件数据

怎么了

也许还有另一种解决方案可以用来配置/创建动态邮件数据位置?

flowable:delegateExpression和flowable:type不能混合在一起

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

如果您想更改邮件活动行为,您需要为其提供自己的实现。为此,您需要提供自己的ActivityBehaviorFactory,您可以扩展DefaultActivityBehaviorFactory并覆盖以下方法:

MailActivityBehavior CreateMailActivityBehavior服务任务 MailActivityBehavior CreateMailActivityBehavior sendTask sendTask
@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(), "newmail@newmail.com");
      execution.setVariable(text.getValue(execution).toString(), "newtext");
   }
}