Flowable engine is taking default mail configuration occasionally

Hi Team,

I have created a BPMN with mail service, If the task reaches the due date it will trigger automatic mails based on pattern given in Time cycle in boundary event and I used the below configuration for mail server, am getting the mail as I expected but the issue is occasionally am getting the below error seems the flowable engine is taking default mail configuration, But the issue is occurring randomly.

BPMN

Reminder

Configuration :

flowable.mail.server.default-from=xxx@yyy.com
flowable.mail.server.host=xxx.yyy.com
flowable.mail.server.port=25
flowable.mail.server.username=xxx
flowable.mail.server.password=yyy

Error

org.flowable.common.engine.api.FlowableException: Could not send e-mail in execution be12fd84-c8b3-11ed-b122-0a18177a00ea
	at org.flowable.engine.impl.bpmn.behavior.MailActivityBehavior.handleException(MailActivityBehavior.java:497)
	at org.flowable.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:130)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeActivityBehavior(ContinueProcessOperation.java:286)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.executeSynchronous(ContinueProcessOperation.java:168)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.continueThroughFlowNode(ContinueProcessOperation.java:123)
	at org.flowable.engine.impl.agenda.ContinueProcessOperation.run(ContinueProcessOperation.java:86)
	at org.flowable.common.engine.impl.AbstractEngineConfiguration.lambda$new$0(AbstractEngineConfiguration.java:195)
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:130)
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:114)
	at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:72)
	at org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.java:26)
	at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
	at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:98)
	at org.flowable.common.spring.SpringTransactionInterceptor.lambda$execute$0(SpringTransactionInterceptor.java:57)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
	at org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:57)
	at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
	at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:127)
	at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:115)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : localhost:1025
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1469)
	at org.apache.commons.mail.Email.send(Email.java:1496)
	at org.flowable.engine.impl.bpmn.behavior.MailActivityBehavior.execute(MailActivityBehavior.java:125)
	... 22 common frames omitted
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 1025; timeout 60000
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2210)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:722)
	at javax.mail.Service.connect(Service.java:342)
	at javax.mail.Service.connect(Service.java:222)
	at javax.mail.Service.connect(Service.java:171)
	at javax.mail.Transport.send0(Transport.java:230)
	at javax.mail.Transport.send(Transport.java:100)
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1459)
	... 24 common frames omitted
Caused by: java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:333)
	at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:214)
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160)
	... 31 common frames omitted

Did I miss any configuration ? Kindly suggest me to overcome this issue.

flowable.version - 6.7.0

Are you running in a cluster configuration?
This behavior would suggest one of the nodes is missing the mail configuration, perhaps not running the production profile or something similar.

Hi @gdharley ,

We are running flowable engine in two instances both the instance were pointing same DB and both the instances have the mail configuration, But I don’t know why this issue is occurring occasionally.

Is there any way to debug this ?

Thanks for the reply.

Debugging this will be very difficult as it happens so infrequently, however you can mitigate the issue by setting the email task to be asynchronous. That way, if it does fail, it will be automatically retried up to 3 times.

Hi @gdharley ,

As you mentioned in previous reply the configuration is missing in one of the Environment ( we are using Jenkins to build it is taking configuration from some other location not from the source code so we missed ) , After we fixed that, It is working as expected.

Thanks !

1 Like