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.

Published by

Sudhish

Seeking for Ultimate Freedom

8 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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s