How to configure notification for Human Task in jBPM

jBPM provides options to configure notification emails to be send to any user if the human task is not started or not completed.

We will start with configuring JavaMail sessions via JNDI so that infrastructure for mail is handled.

We would be using “jbpm-server-7.37.0.Final-dist” version for this example.

Configure Mail Session in wildfly

In the standalone configuration for jBPM we need add below configurations.

Configure Socket binding for smtp-port

        <outbound-socket-binding name="mail-notification-smtp">
            <remote-destination host="smtp.gmail.com" port="465"/>
        </outbound-socket-binding>

host -: host name of SMTP server

port -: port no of SMTP server.

Configure Mail-Session in Mail subsystem

            <mail-session name="notification" jndi-name="java:/notificationMailSession" from="youremailid@gmail.com">
                <smtp-server outbound-socket-binding-ref="mail-notification-smtp" ssl="true" username="youremailid@gmail.com" password="yourPassw0rd"/>
            </mail-session>

from -: From address for your emails (Valid email account on SMTP server).

username -: username for the email account

password -: password for the email account.

Add below system property to standalone.xml file.

    <system-properties>      
       <property name="org.kie.mail.session" value="java:/notificationMailSession"/>
    </system-properties>

Configure user info for Human task

Next step would be to configure email info for users used by the human task. You will have to create file named “userinfo.properties” with below content at location “kie-server.war/WEB-INF/classes”.

john=youremailid@gmail.com\:en-UK\:john
Administrator=youremailid@gmail.com:en-UK:Administrator
wbadmin=yourtoemailid@gmail.com:en-UK:wbadmin:[john]

You can enter email details for all users in the above file. Make sure the Administrator user is present in the file.

Configuring Notification for Human task in process definition

Final step would be configure notifications for human task in a process definition. Follow below steps for that.

  1. In buisness-central click on human task for which notification needs to configured.

2. Select “Edit” notifications from the property section in right hand side.

3. Click on “Add” button to add new notification.

4. jBPM allows you to configure 2 types of notifications -: Not Started and Not Completed.

5. Select the type of Notification to be configured by clicking on “Not Started” or “Not Completed” radio button.

6. You can configure Notification time using 3 options

a) Time Period -: You can specify period after which notification would be send in minutes, hours, days, months, years. This also provides repeat option as well.

b) Date -: You can pass actual date along with time zone.

c) Expression -: You pass time in ISO 8601 expressions syntax as well.

7. In Message section you can select.

from -: User from whom notification would be send. You can select only one user

to -: Users or Groups to whom notification will be send. You can select multiple users or groups.

Please ensure the users email info is present userinfo.properties file.

You can then enter email Subject and email Body to be send as part notification.

8. You can add multiple notification by clicking on Add button.

9. Save the file, then build and deploy the project.

10. Since we configured “Not Started” type of notification with time period 1 min. If the human task is not started with in 1 min of process start then a notification email would be triggered.

If you are getting below error when notification is triggered cross check if your username and password is correct. Also in case of gmail check if you enabled Less secure app access in account settings if you are testing in your local.

22:36:00,603 ERROR [org.jbpm.services.task.deadlines.notifications.impl.email.EmailNotificationListener] (EJB default - 3) Unable to send email notification due to 535-5.7.8 Username and Password not accepted. Learn more at

You can refer to https://github.com/kiegroup/jbpm/blob/master/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/deadlines/notifications/impl/email/EmailNotificationListener.java for more details on EmailNotificationListener class.

Refer my blog https://techblogtoprogram.wordpress.com/2020/07/19/configuring-db-based-user-login-and-task-notifications-for-jbpm/ for configuring user info in DB for sending notification.

Published by

Sudhish

A technology enthusiast who loves learning and working on interesting technologies.

25 thoughts on “How to configure notification for Human Task in jBPM”

    1. Hi Ravi,

      Check out the blog “https://techblogtoprogram.wordpress.com/2020/06/02/how-to-configure-executesql-service-task-in-jbpm/” for using ExecuteSQL service task in jBPM.

      Like

  1. thank you for the information.
    Concerning this: “Please ensure the users email info is present userinfo.properties file.”
    What about when there are Groups? What about when there are 10’s of users or tens of different processes with as many x times users assigned to HT?
    What about SSO and users coming from other repos?
    Add each manually to the file? In 2020? Did I misunderstand? This solution makes jbpm a very isolated system

    Like

    1. userinfo.properties file is default implementation (DefaultUserInfo.java) available to map user information to email id’s. If you want to use out of box user implementation then additional implementation like LDAP or DB based available at “https://github.com/kiegroup/jbpm/tree/master/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity” can be used.

      Like

  2. Where is the location for β€œkie-server.war/WEB-INF/classes”.?
    And how to get the user info from an external system? Writing by hand all users in a file that are in jBPM seems a bit too much work prone to errors

    Like

    1. If you are using jbpm Final-dist then kie-server.war would found at “/standalone/deployments” directory. Users can be configured in any external system for authentication and authorization by default you will have to userinfo is configured using “userinfo.properties file” for mapping email ids . If you want to use out of box user implementation then additional implementation like LDAP or DB based available at β€œhttps://github.com/kiegroup/jbpm/tree/master/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/services/task/identity” can be used.

      Liked by 1 person

      1. /standalone/deployments” directory only has war files as it is to be expected but the mentioned above kie-server.war/WEB-INF/classes”. is a directory, not a file.

        Like

      2. kie-server.war is present at the location “/standalone/deployments”. Once you extract or unpack this WAR file then inside “kie-server.war/WEB-INF/classes” directory you have create a file named “userinfo.properties” and add all email information to this file as suggested.

        Like

  3. Hi.
    thank you for the reply.
    unfortunately, wildfly takes care of the expanding the war in the docker image. Although I am guessing the behaviour is the same for any wildfly instalation, so the folder is not there.
    It is under standalone/tmp
    however, adding the file there, produces that error ’email not found for user …”

    Like

    1. Are you running jBPM in docker? Could you confirm which docker image are you using?

      Could you run below command y replacing the image name with image that you are using ?

      “docker run -t -i -p 8080:8080 -p 8001:8001 jboss/jbpm-server-full:latest /bin/bash”

      Then share a snapshot of files present in below location “opt/jboss/wildfly/standalone/deployments”.

      Like

      1. Are you using custom image or is it available in docker hub. If it’s available in docker hub then Don’t add the image, just run below command in you docker client and share the out put. Also just mention the image id.

        Like

  4. I meant snapshot, that is a screenshot of the ls -la command
    We are using the same image (full) v7.41
    The files under deployments are the 3 usual wars: business-central.war jbpm-casemgmt.war and kire-server.war

    Like

    1. If you get the latest *final delivery of jbpm and start it normally, you get the same results as in the docker container. That is, deployment folder with 3 war files as mentioned tmp folder with the expanded expanded wars.

      Like

      1. Don’t add the file to tmp folder it won’t work. You will have to add the file to “opt/jboss/wildfly/standalone/deployments/kie-server.war/WEB-INF/classes” directory.

        If the kie-server.war file available in deployment folder is not in expanded form then extract it,
        ~~~
        jar -xvf kie-server.war
        ~~~
        add the file to “kie-server.war/WEB-INF/classes” directory.
        ~~~
        jar -cvf kie-server.war kie-server
        ~~~
        Then repackage the “kie-server.war”

        Create a custom image using this repackaged war and run it on docker

        Like

  5. Hello Sudhish and thanks for your post ; it’s very helpfull πŸ™‚
    I’m workging for a school and I’d like to install jbpm in it .. but first I make some tests πŸ™‚
    So I tried your solution but I’ve an error when the notification would have to be sent :

    17:11:46,662 WARN [org.kie.server.services.jbpm.ui.FormServiceBase] (default task-9) Unable to find form to render for process ‘EnvoiMail’
    17:11:48,452 WARNING [javax.mail] (default task-9) expected resource not found: /META-INF/javamail.default.address.map
    17:12:09,678 WARN [org.kie.server.services.jbpm.ui.FormServiceBase] (default task-10) Unable to find form to render for task ‘Test envoi mail’ on process ‘EnvoiMail’
    17:12:48,501 INFO [org.jbpm.services.task.deadlines.notifications.impl.email.EmailNotificationListener] (EJB default – 1) Missing mail session or userinfo – skipping email notification listener processing

    Maybe this is my userinfo.properties file that is not read .. ? I put it my /web-inf(classes directory a made a new kie-server.war file.
    But I realized that there’s already a file jbpm.user.info.proerties in that directory. Do yout think I should use that file instead userinfo.properties ?
    Per advance, thanks for your help πŸ™‚

    Like

    1. jbpm.user.info.properties is used if you are storing user information (email details) in a database. I have written a separate blog for that use case https://techblogtoprogram.wordpress.com/2020/07/19/configuring-db-based-user-login-and-task-notifications-for-jbpm/.

      But if you are default implementation for users and groups (application-users and application-roles files) then you will have to add Userinfo.properties file with email details for the user.

      I suspect issue is with your mail session configuration. Can you cross check if you followed all steps mentioned in the blog?

      ~~~
      17:11:48,452 WARNING [javax.mail] (default task-9) expected resource not found: /META-INF/javamail.default.address.map
      ~~~

      Also it would be helpful if you enable debug logs for the package “org.jbpm.services.task.deadlines.notifications.impl.email.EmailNotificationListener”. Below log statement will give you clear idea whether issue is user info or mail session.

      ~~~
      logger.debug(“User info implementation {} and mail session {}”, userInfo, mailSession);
      ~~~

      Like

Leave a comment