Friday, September 2, 2011

How to send email notifications via BPELs

When business process modeling, there can be requirements to send notifications to some external parties regarding the run-time state of the business process. One general example would be when a particular task is completed, the relevant parties is sent a email.
This functionality is supported by WSO2 BPS via Axis2 mail transport.  So using a activity you can send a request to a particular email address.

There 3 steps involved in setting up the environment.
  • Configure Axis2 mail transport in BPS_HOME/repository/conf/axis2.xml
  • Create WSDL which has mail address as the service address
  • Implement the BPEL process with a invoke activity which sends a mail to configured e-mail address

Configuring Axis2 Mail Transport
In this process we only use mail sending functionality, so we don't want to configure transport receiver. To configure mail transport sender first open up the axis2.xml file which resides in BPS_HOME/repository/conf directory in a text editor and add the following mail transport sender configuration to axis2.xml. Place this after other transport sender configurations.
In the above configuration we have used gmail account we have created for testing purposes. But in production deployment you have to use your own e-mail account.

After you save the axis2.xml after adding above configuration, mail transport configuration is done. Now you can use addresses in mailto: format to as the service endpoint address in WSDL and use Axis2 client API to send e-mails.


Create WSDL which has mail address as the service address
So you can create a partner WSDL which has a service endpoint to a email address. As mail sending act as out-only operation, make sure to modify the portType for sending mails accordingly.


Implement the BPEL process with a invoke activity which sends a mail to configured e-mail address
Now you can use an activity to invoke email sending operation with relevant portType and partner-Links.

1 comment:

Unknown said...

Hello.

I was able to follow your example and works fine. But I would like to have on the email , only one passed text value , corresponding to a bpel variable and not all the soap message. How can make the convert on the fly?