0

我创建了邮件任务配置

<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>

和类:

@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");
   }
}

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

怎么了?

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

4

1 回答 1

1

flowable:delegateExpression并且flowable:type不能混在一起。

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

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

  • MailActivityBehavior createMailActivityBehavior(ServiceTask serviceTask)
  • MailActivityBehavior createMailActivityBehavior(SendTask sendTask)
于 2019-04-14T07:32:58.683 回答