cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to Create Email Listener in Activiti

visingh
Champ on-the-rise
Champ on-the-rise
Hi,
I am new to activiti. I am trying to create Email Listener. This email listener performs below things.
1) Listens email all the time
2) Create task if a new email received.
3) Attach that email to the created task.

I have created two below Process.
1) Process For listening Emails- I am having Receive task and used execution listener by implementing org.activiti.engine.delegate.JavaDelegate. I am having infinite loop to listen the emails in execution method. See code snippet below.
and once I received email I called below second Process.
public void execute(DelegateExecution execution) throws Exception
   {      

       while(true)
      {         

         downloadEmails("imap", "Server.com", "Port", "account", "password", delegateexecution);         
      }      
   }

I am using below code to invoke second Process
              RuntimeService runtimeService = execution.getEngineServices().getRuntimeService();
              ProcessInstance piObj= runtimeService.startProcessInstanceByKey("MainProcess", HashTable);
2) Process (MainProcess) is having Manual task and Task listener for this task which creates attachment to the task.

By this approach, I am able to listen emails but unable to create task and I do not recive any error too. Please advise where I am doing wrong or I need to follow some other approach.

1 REPLY 1

vasile_dirla
Star Contributor
Star Contributor
Please create a simple unit test to show this behavior.
Your test should not listen an email, it is OK to trigger the action for another event.
this unit test will be a good starting point for investigation.