gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 10:03:46 26 4
gpt4 key购买 nike

我创建了邮件任务配置

<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 类无法正常工作。我无法修改任何邮件数据。

出了什么问题?

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

最佳答案

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

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

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

  • MailActivityBehavior createMailActivityBehavior(ServiceTask serviceTask)
  • MailActivityBehavior createMailActivityBehavior(SendTask sendTask)

关于java - 如何使用 Spring Boot 和 Flowable 修改邮件任务数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55450485/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com