Login
Register

Home

Trainings

Fusion Blog

EBS Blog

Authors

CONTACT US

Kishore Ryali
  • Register

Oracle Gold Partners, our very popular training packages, training schedule is listed here
Designed by Five Star Rated Oracle Press Authors & Oracle ACE's.

webinar new

Search Courses

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.


Kishore Ryali

Comments   

0 #1 Raj1 2008-09-16 19:59
what is the default password for login oc4jadmin ?
Quote
0 #2 kishore Ryali 2008-09-16 20:04
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

Kisho re
Quote
0 #3 Raj1 2008-09-16 22:17
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.
Quote
0 #4 kishore Ryali 2008-09-17 10:04
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
Quote
0 #5 Nilesh Parekh 2008-09-25 02:29
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
Quote
0 #6 kishore Ryali 2008-09-25 08:50
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/50-pb/336-esb-bpel-using-oracle-soa-suite-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
Quote
0 #7 harinathd2003 2008-09-26 19:23
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



smtp.gmail.com
465


pop.gmail.com
995
pop3

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.

Thank s,
Hari
Quote
0 #8 kishore Ryali 2008-09-26 19:56
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.

Kishor e
Quote
0 #9 harinath 2008-09-27 00:39
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.s ervices.notific ation.DefaultNo tificationServi ceImpl.sendEmai lNotification(D efaultNotificat ionServiceImpl. java:256)
at oracle.tip.pc.s ervices.notific ation.Notificat ionServiceImpl. sendEmailNotifi cation(Notifica tionServiceImpl .java:271)
at oracle.bpel.ser vices.notificat ion.queue.sende r.MDBConsumer.d eliverNotificat ion(MDBConsumer .java:256)
at oracle.bpel.ser vices.notificat ion.queue.sende r.MDBConsumer.o nMessage(MDBCon sumer.java:137)
at sun.reflect.Gen eratedMethodAcc essor53.invoke( Unknown Source)
at sun.reflect.Del egatingMethodAc cessorImpl.invo ke(DelegatingMe thodAccessorImp l.java:25)
at java.lang.refle ct.Method.invok e(Method.java:5 85)
at com.evermind.se rver.ejb.interc eptor.joinpoint .EJBJoinPointIm pl.invoke(EJBJo inPointImpl.jav a:35)
at com.evermind.se rver.ejb.interc eptor.Invocatio nContextImpl.pr oceed(Invocatio nContextImpl.ja va:119)
at com.evermind.se rver.ejb.interc eptor.system.DM SInterceptor.in voke(DMSInterce ptor.java:52)
a t com.evermind.se rver.ejb.interc eptor.Invocatio nContextImpl.pr oceed(Invocatio nContextImpl.ja va:119)
at com.evermind.se rver.ejb.interc eptor.system.Se tContextActionI nterceptor.invo ke(SetContextAc tionInterceptor .java:44)
at com.evermind.se rver.ejb.interc eptor.Invocatio nContextImpl.pr oceed(Invocatio nContextImpl.ja va:119)
at com.evermind.se rver.ejb.Invoca tionContextPool .invoke(Invocat ionContextPool. java:55)
at com.evermind.se rver.ejb.Messag eDrivenConsumer .onMessage(Mess ageDrivenConsum er.java:347)
at com.evermind.se rver.ejb.Messag eDrivenConsumer .processMessage s(MessageDriven Consumer.java:2 33)
at com.evermind.se rver.ejb.Messag eDrivenConsumer .run(MessageDri venConsumer.jav a:169)
at com.evermind.ut il.ReleasableRe sourcePooledExe cutor$MyWorker. run(ReleasableR esourcePooledEx ec

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


Thanks ,
Hari
Quote
0 #10 kishore Ryali 2008-09-27 01:10
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
Quote
0 #11 saikrishnapanuganti 2008-12-18 07:38
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
Quote
0 #12 saikrishnapanuganti 2008-12-18 07:47
and one more question, how does the property correlating to the bpel we have deployed that sends an email notification..a s we could have many bpels deployed that sends email notifications..

-saikrishna
Quote
0 #13 kishore Ryali 2008-12-19 12:26
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_interva l" or schedule 3 jobs at those intervals.

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

Kish ore
Quote
0 #14 Anand Dharia 2009-02-20 14:19
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.

Ple ase advice if there is some way to do that.

Thanks
A nand
Quote
0 #15 Pereddy 2009-06-16 05:30
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
Quote
0 #16 DaveB 2009-06-23 10:55
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 address. I keep getting errors indicating "The connection to the server has failed. Account: 'mail.chevy2hot rod.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
Quote
0 #17 Ramagopal 2009-09-02 07:47
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
Quote
0 #18 ravivamshi 2009-12-11 11:49
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?

Vamsh i
Quote
0 #19 GHD straighteners 2010-07-22 03:25
Enjoyed every bit of your blog.Great.
Quote
0 #20 avvi 2010-10-27 16:26
hi....is there a similar feature available in ESB....i.e. can i send the email through an ESB?
Quote
0 #21 priyadharshini.j 2011-01-24 05:10
hi,

i need to pass the value for From account name dynamically from the payload.. is that possible?
curre ntly 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

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

thanks
Quote
0 #22 Ramesh Komalli 2011-12-06 14:59
Hi,

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

Thanks
Ra mesh
Quote
0 #23 Shirish Avancha 2012-03-16 17:43
Hi,

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

Cheers
Quote

Add comment


Security code
Refresh

Search Trainings

Fully verifiable testimonials

Apps2Fusion - Event List

<<  Apr 2024  >>
 Mon  Tue  Wed  Thu  Fri  Sat  Sun 
  1  2  3  4  5  6  7
  8  91011121314
15161718192021
22232425262728
2930     

Enquire For Training

Related Items

Fusion Training Packages

Get Email Updates


Powered by Google FeedBurner