Apps To Fusion

.......Our Journey from Apps To Fusion

 
  • Increase font size
  • Default font size
  • Decrease font size


Schedule Email Notification using Oracle BPEL - Part 1

E-mail
User Rating: / 9
PoorBest 
Email notifications are widely used in Oracle Applications for FYI or Action notifications. They can be achieved in many ways using Workflow, PL/SQL, host file etc. As we are all getting geared up for Fusion Middleware, I wanted to explore the option of using BPEL process.

In my article, I will create a bpel process which it scheduled to send email notifications say every 30 min. For simplicity I will do this in two steps which are covered in two articles.

1. Create a bpel process which sends email notification.
2. Schedule the above bpel process to run every 30 min.

This article covers the sending emails using BPEL process. Before I go into the steps of implementing email notification, I will brief you about the environment I'm using for this article.

Environment for this article

  • SOA Suite 10.1.3.1 Basic Installation. So it uses Oracle Lite database.
  • JDeveloper 10.1.3.3.0

For setting up the environment, refer to the SOA Suite Installation article.

The problems I've faced during installation are:
  • Internet Explorer 7.0 - I was getting "The procedure entry point GetProcessImageFileNamew could not be located in the dynamic link library PSAPI.dll" error message at 99% of installation progress bar. So I had to uninstall IE 7.0 to get it working. Funny thing is after you install SOA Suite, you can install IE 7.0 and it works perfectly.

  • Firewall - My McAfee firewall blocked opmn service. So the Recommended installation was failing during installation. Disable your firewall or make exclusion list during installation.

The above two problems were resolved after 4 hrs OWC session with Oracle Support.
 
You can continue with the later part of the article, if your environment is set up.

BPEL Process using Email Activity

Notification services in BPEL are exposed as web services. The notification service sends email using SMTP and receives email from IMAP-based or POP-based email accounts. You can use Email activity in the component palette to add email notification of BPEL process. You can directly enter the required and optional email addresses and message content (subject and body) or you can use the following built-in functions:
  • Identity lookup dialog: Browse the user directory that is configured for use by Oracle BPEL Process Manager—Oracle Internet Directory (OID), JAZN/XML, LDAP, and so on.

  • XPath Expression Builder: For recipient email addresses (To, Cc, Bcc, Reply To), you can use the XPath Expression Builder to get email addresses dynamically from the input.


For my example, I will directly enter the recipient email address, subject and body in email activity fields.

Before using email activity, you must set up configuration details for email accounts in the ns_emails.xml file, found at <SOAHOME>\bpel\system\services\config

Configuring Email Accounts in ns_emails.xml:

ns_emails.xml is found in <SOAHOME>\bpel\system\services\config folder.

1. Make a backup copy of the ns_emails.xml file.

2. Open ns_emails.xml in Text Editor and Change the NotificationMode from "NONE". NotificationMode can be set to the following:
  • EMAIL - If you have only email setup, but not other channels like voice, SMS, fax, etc.
  • ALL     - if you have email and other channels like voice, SMS, fax, etc. set up.

I will be using only email, so I have set NotificationMode to "EMAIL".

3. Configure Default EmailAccount. When Email activity is selected in BPEL process, From Account field is defaulted  with "Default". If "Default" email account is not configured in ns_emails.xml, email notification is not sent to the recipient.

Also this account is used when no account is specified to receive an email notification. This account is also used to send task-related notifications. A default email account must always be specified in the configuration file i.e ns_emails.xml


Change FromAddress, OutgoingServerSettings, IncomingServerSettings elements to your desired email address and your smtp host name as below.


4. This step is Optional. Define the parameters for the additional email account with an additional <EmailAccount> </EmailAccount> structure. For Example: If I defined 'Apps2Fusion' email account, I can use 'Apps2Fusion' in From Account field in Email activity.

   <EmailAccount>
      <Name>Apps2Fusion</Name>
      <GeneralSettings>
        ...
      </GeneralSettings>
      <OutgoingServerSettings>
         ...
      </OutgoingServerSettings>
      <IncomingServerSettings>
         ...
      </IncomingServerSettings>
   </EmailAccount>

5. Save ns_emails.xml


Configuring wf_config.xml:

wf_config.xml is found in <SOAHOME>\bpel\system\services\config folder. It is a workflow configuration file.

Add the below property to wf_config.xml

<property name="oracle.bpel.services.notification.publisher_interval" value="1" />



This property specifies the interval for sending notifications. If this property is absent, the notifications are sent every 15 mins (default) or after starting the SOA Suite.

Once the cofiguration files i.e ns_emails.xml and wf_config.xml are edited, Start your SOA Suite and JDeveloper. If you have already started SOA Suite before editing these configuration files, restart the SOA Suite.

Creating Email Activity in BPEL Process

Open SOA Launch Console and Click on Application Server Control link.
Login with username/password and go to Runtime Ports link at the bottom.
Write down the RMI port number. We will use this port for creating Application Server connection in JDeveloper.

Open JDeveloper. Create Application Server Connection and test it.
RMI Port 12401 is fetched from above screenshot.



Create Integration Server connection using the above application server connection. Test it.

Now I will create Asynchronous BPEL project. My BPEL process looks like in below screenshot.

I will drag the Email Activity from Component Palette (left most frame), on to BPEL process in between the receive and response activities.


Configure the fields in Email activity. From Account is defaulted with 'Default' email account name. Default email account settings are taken from ns_emails.xml

You can also use XPath Builder to set the fields dynamically from input variables.
Click OK. I've renamed the activity to "SendEmail". Email is a complex activity like a subprocess in workflow. You can click on "+" of email activity to expand it. It contains Assign activity which assigns the values for the different parameters of email, and Invoke activity to initiate Notification Service. If NotificationMode parameter in ns_emails.xml is not changed from "NONE", the notification is sustained here.

Save All. Deploy the process on to Integration Server.



Now Login to BPEL Control and Click on the process name in the dashboard.
Click on Post XML Message to manually kick off the process.

Check the email. I've received email successfully.

But the message text came as an attachment. So I went back to my email activity and unchecked Multipart message attachments. I've deployed and ran the process again.

Bravo !!! I got the email notification as I wanted.


You can view the flow and the xml data at each activity. Click on Instances in BPEL Console, then Flow tab.


To revise the whole process to send email notifications, I'm briefing the steps below:
  1. Set your SOA Suite enviroment for development.
  2. Configure ns_emails.xml and wf_config.xml
  3. CreateAsynchronous BPEL Process
  4. Create Email acitivity and enter values for To, Subject and Body fields
  5. Save and Deploy the Process
  6. Manually initiate the process
  7. Check the email

In this article, I've manually initiated the process to send notification. I will automate this step to schedule the bpel process in the next article.

Comments (23)add
Password
written by Raj1 , September 16, 2008
what is the default password for login oc4jadmin ?
report abuse
vote down
vote up
Votes: +0
Re: oc4jadmin password
written by kishore Ryali , September 16, 2008
If you installed SOA Suite, then you will be providing oc4jadmin password at the installation. So it cannt help you in that case. Otherwise if you installed BPEL Process Manager, default password is welcome1

Kishore
report abuse
vote down
vote up
Votes: +0
...
written by Raj1 , September 16, 2008
Thanks for the update. I tried welcome1. The step 4 of 4 (Connection Status) is running forever. Not sure what else I am missing. Yes, I have installed BPEL Process Mgr and not SOA suite.
report abuse
vote down
vote up
Votes: +0
...
written by kishore Ryali , September 17, 2008
Raj,

Did you start BPEL Process Manager from Start > Programs ?
If yes, try to login to Application Server Control and BPEL console page.

If you cannot, then your opmn or olsv2040 (Oracle Lite Database) services are not running.

Kishore
report abuse
vote down
vote up
Votes: +0
Need Help
written by Nilesh Parekh , September 25, 2008
Can you please shed some light on how we can define an Oracle Concurrent Request as a Web Service and call it through BPEL process?

For example:
If we have to fetch some data from 12i using some criteria (for example: employee information should be fetched based on the date parameter provided by user), if we develop a concurrent program to fetch the data, how to define this concurrent request as a web service and develop a BPEL process to access the same and use EBS to write the fetched information to a file using file adapter and to database using database adapter?

Thank you very much in advance!
Nilesh
report abuse
vote down
vote up
Votes: +0
Re: Nilesh
written by kishore Ryali , September 25, 2008
Hi Nilesh,

I didnt understand your example clearly. If you want to fetch some data from database using some criteria, why do you need concurrent program for it? You can use database adapter to call a stored procedure and write it into a file/table depending upon what you want to do.

Regarding concurrent program , you can define a Apps Adapter (http://apps2fusion.com/at/pb/5...-article-i) and create a wrapper around "fnd_request" api (or) define a Database Adapater which calls a stored procedure which make call to fnd_request API.

Kishore
report abuse
vote down
vote up
Votes: +0
Problem in sending Email notification from BPEL
written by harinathd2003 , September 26, 2008
Hi Kishore,

I am trying to send email from BPEL using Email activity.
I configured the ns_emails.xml file properly as below.
when i run the process, it is executing fine without any error.
but i am not receiving any mail.




Default

Oracle BPM
This e-mail address is being protected from spambots. You need JavaScript enabled to view it '> This e-mail address is being protected from spambots. You need JavaScript enabled to view it


smtp.gmail.com
465


pop.gmail.com
995
pop3
This e-mail address is being protected from spambots. You need JavaScript enabled to view it '> This e-mail address is being protected from spambots. You need JavaScript enabled to view it
12345
false
Inbox
1






Could any one suggest me the solution for this problem.
is there anything extra need to be configured for this..

Thanks in advance.

Thanks,
Hari
report abuse
vote down
vote up
Votes: +0
Re: Hari
written by kishore Ryali , September 26, 2008
Hari,

I doubt whether you will be able to send using gmail as outgoingserver without authentication
You can test it by configuring outlook with the settings you used, to send email.
If it works, it will definitely work with BPEL Server.

Kishore
report abuse
vote down
vote up
Votes: +0
Problem in sending Email Notification from BPEL
written by harinath , September 27, 2008
Hi Kishore,

I tested it by configuring outlook with the settings and able to send email using gamil as outgoingserver with authentication only.

--- ns_email.xml---------

I added one more tag to ns_email.xml as below

true
and changed USeSSL tag to true.

But still i am not receving email.


And moreover i am getting error as below

ORABPEL-00000

Exception not handled by the Collaxa Cube system.
An unhandled exception has been thrown in the Collaxa Cube system. The exception reported is: "ORABPEL-10328

Error in sending e-mail message.
Error in sending e-mail message.

at oracle.tip.pc.services.notification.DefaultNotificationServiceImpl.sendEmailNotification(DefaultNotificationServiceImpl.java:256)
at oracle.tip.pc.services.notification.NotificationServiceImpl.sendEmailNotification(NotificationServiceImpl.java:271)
at oracle.bpel.services.notification.queue.sender.MDBConsumer.deliverNotification(MDBConsumer.java:256)
at oracle.bpel.services.notification.queue.sender.MDBConsumer.onMessage(MDBConsumer.java:137)
at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.SetContextActionInterceptor.invoke(SetContextActionInterceptor.java:44)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
at com.evermind.server.ejb.MessageDrivenConsumer.onMessage(MessageDrivenConsumer.java:347)
at com.evermind.server.ejb.MessageDrivenConsumer.processMessages(MessageDrivenConsumer.java:233)
at com.evermind.server.ejb.MessageDrivenConsumer.run(MessageDrivenConsumer.java:169)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExec

Do you have any idea why i am getting this error.


Thanks,
Hari

report abuse
vote down
vote up
Votes: +0
...
written by kishore Ryali , September 27, 2008
Hari,
I didnt try with gmail outgoing server.
The below link may provide with some information.
http://forums.oracle.com/forums/thread.jspa?messageID=2642340�

Kishore

report abuse
vote down
vote up
Votes: -1
Mr.
written by saikrishnapanuganti , December 18, 2008
nice..example
I need to have a 3 bpel processes which executes in three different intervels.
or can we schedule the same bpel to execute in 3 different intervels that sends email notification.
-Saikrishna
Apps Associates
report abuse
vote down
vote up
Votes: +0
Mr.
written by saikrishnapanuganti , December 18, 2008
and one more question, how does the property correlating to the bpel we have deployed that sends an email notification..as we could have many bpels deployed that sends email notifications..

-saikrishna
report abuse
vote down
vote up
Votes: +0
Re: saikrishnapanuganti
written by kishore Ryali , December 19, 2008
Hi Sai,

The second part of this article says about scheduling bpel process using dbms_scheduler package. If you want schedule bpel process to run in 3 different interval, you can play with parameter "repeat_interval" or schedule 3 jobs at those intervals.

To make this bpel process generic, you can input parameter for recipient email add***s in Email Activity the and set it using Assign Activity.

Kishore
report abuse
vote down
vote up
Votes: +1
Need to send email without configuring the ns_emails.xml
written by Anand Dharia , February 20, 2009
Hi,
I need to have a system that will send email from various users. The users are added to the oracle system dynamically and the email ids will be obtained from the fnd_users tables.. So i cannot make changes to the ns_emails.xml file everytime.

Please advice if there is some way to do that.

Thanks
Anand

report abuse
vote down
vote up
Votes: +3
BPEL Email notiifcation
written by Pereddy , June 16, 2009
Hi,

I have tried configuring same way as you explained. Its processing with out any error. I am unable to receive mails.Some one can help me out.

Regards,
Pereddy
report abuse
vote down
vote up
Votes: +0
SMTP Setup
written by DaveB , June 23, 2009
Kishore,
I followed the OTN thread mentioned above to setup SMTP with Hamster. I am using Outlook Express to test the outbound messages to either a yahoo or gmail email add***s. I keep getting errors indicating "The connection to the server has failed. Account: 'mail.chevy2hotrod.com', Server: '127.0.0.1', Protocol: POP3, Port: 110, Secure(SSL): No, Socket Error: 10061, Error Number: 0x800CCC0E" The scenario is I send a test message from Outlook Express to an outside yahoo or gmail account. My Express account is pointing at the hamster email server 127.0.0.1. Shouldn't hamster send the email outside my lan? Once I get this working, I can hook it into BPEL easily. Thanks, DaveB
report abuse
vote down
vote up
Votes: +0
how to send actionable email notifications
written by Ramagopal , September 02, 2009
Hi,

I have followed the steps mentioned by you to receive email notifications. But my requirement is to receive actionable email notifications i.e. i should recieve email which will have action links like Accept , Reject etc. and when I clikc on any one action link corresponding action should take place. Can you please suggest how to achieve this functionality.

Regards
Aparna
report abuse
vote down
vote up
Votes: +0
not able to sendout emails
written by ravivamshi , December 11, 2009
Hi Kishore,

I am trying to use email activity for the first time. i followed the steps in this article.Here the problem is that, i could see the instance got executed and completed. but i never see any email coming into my inbox.neither i see any error msg or any warning. how do i start diagnose this problem?

Vamshi
report abuse
vote down
vote up
Votes: +0
GHD straighteners
written by GHD straighteners , July 22, 2010
Enjoyed every bit of your blog.Great.
report abuse
vote down
vote up
Votes: +0
Email feature in ESB
written by avvi , October 27, 2010
hi....is there a similar feature available in ESB....i.e. can i send the email through an ESB?
report abuse
vote down
vote up
Votes: +0
From account - passing values dynamically from the payload
written by priyadharshini.j , January 24, 2011
hi,

i need to pass the value for From account name dynamically from the payload.. is that possible?
currently only default value of the From account name configured in the BPEL server is taken..

please let me know if that could be possible..
i cannot make changes to the ns_emails.xml file everytime

please let me know know if there are some way to do that..

thanks
report abuse
vote down
vote up
Votes: +1
HTML Email Body
written by Ramesh Komalli , December 06, 2011
Hi,

Could You Post , how to get Email Body in HTML foramt instead of simple Text

Thanks
Ramesh
report abuse
vote down
vote up
Votes: +1
...
written by Shirish Avancha , March 16, 2012
Hi,

This article is well written, I could able to imitate at my first try itself.
Thanks for positing !

Cheers
report abuse
vote down
vote up
Votes: +0
Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

security image
Write the displayed characters


busy
 

404 Not Found

Not Found

The requested URL /images/tent.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Apache Server at www.rossorg.com Port 80