03-23-2018 02:38 PM
Hi
Is there any way to pass external properties to process bpmn file with spring boot from application.properties file.
Example :
<activiti:field name="from">
<activiti:string><![CDATA[${recipient}@gmail.com]]></activiti:string>
</activiti:field>
I am trying to pass the recipient value from application.properties file in spring boot application.
I tried with java delegate and expression .
I have passed value to process using process variables but I dont want recipient email address to be passed in process variables or to be persisted to DB.
Is there any way we can pass the recipient variable value to process bpmn file without persisting or as process variable to the process.
I see the following exception
org.activiti.engine.ActivitiException: Unknown property used in expression: Error task has been created in ${recipient}.
03-23-2018 04:50 PM
I was able to solve this
I have used the Java Delegate approach.
1.Create a Java Delegate Class with the properties you need to pass .
2.Generate getters and setters for these properties.
3.Pull the values from application.properties or any other property file you are using for your application.
4.For pulling the values in spring boot application I used @Value annotation .
5.Below is how my process bpmn looks like
<serviceTask id="createMailTask" name="Create Mail Task"
activiti:type="mail" activiti:class="com.org.activiti.model.TestInjectedField">
<extensionElements>
<activiti:field name="to"
expression="${testInjectedField.recipient}" />
</activiti:field>
.
.
.
.
.
</extensionElements>
</serviceTask>
6.Java Delegate Class
com.org.activiti.model
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("testInjectedField")
public class TestInjectedField implements JavaDelegate {
@Value("${recipient}")
private String recipient;
public String getRecipient() {
return recipient;
}
public void setRecipient(String recipient) {
this.recipient = recipient;
}
public void execute(DelegateExecution execution) throws Exception {
}
}
Thanks
Explore our Alfresco products with the links below. Use labels to filter content by product module.