Oracle SOA Suite Online Training

Interested in learning Oracle SOA Suite 12c?
Learn from the author of this blog!
A complete and comprehensive course on the #1 platform on SOA - Oracle SOA Suite

Click here to find the complete course details
Click here to check the first session on Oracle SOA Suite 12c

================================================================================================

Configuring Email Notification in Oracle SOA Suite 11g

Oracle SOA Suite 11g provides User Message Service(UMS) that enables users to send notifications via various channels like Email, SMS, IM, Voice Mail.

Each of these channels need to be configured first before they can be used.

This post explains you how to use Email channel as the notification service in Oracle SOA Suite 11g.

Once configured, it can be used in the Human Tasks as well as with the Oracle BPEL Extension "Email" activity.


Before anything, I'll just introduce you to the protocols used in EMAIL communication
Sending a Mail
SMTP : protocol to send mail to a mail server

Retrieving a Mail
POP3 : Downloads the mail from the mail server in to a local machine. This will be helpful if you have only one machine in which you'll always check your emails.
IMAP : Doesn't actually download the email to the local server(you can always do it if required). It helps you sync up your mail across machines, and gives the capability of having hierarchical maintenance of your emails ie, you can maintain a folder structure for specific mails. You create a folder in one machine, drag some msg's into it, that will be automatically synced up when you chk your mails from another machine as the changes are not done in your local machine, but the server.  Also, when your INBOX is too huge, it will just retrieve headers to your mail client, only when you click on it, it will actually download the message to show you the details. This makes the performance better than POP3.

For using EMAIL notification service, you may not have your own email servers. You can always use a freely available mail like gmail.

This example shows you how to use gmail as the mail server for Email Notifications.

Configuring Email notification service involves 4 steps(first step can be ignored if your mail server doesn't need SSL)

Step 1 : Import certificates from gmail and add it to your server trust store
Step 2 : Configure email driver properties
Step 3 : Enable notification mode
Step 4 : Testing the configuration

Below procedure lists a step-by-step approach of setting up gmail server as the default mail server for your UMS

Step 1 : Import certificates from gmail and add it to your server trust store
Any email server uses two protocols to send/receive messages.
SMTP for sending mails
Either POP3 or IMAP for receiving mails. Gmail uses IMAP for retrieving mails.
So, you need to get both SMTP and IMAP certificates connecting to the gmail server inorder to send/receive mails to/from your inbox.

You can download the certificates using an opensource software called openssl. First, you need to download and install it.
Downloading SMTP certificate
Open command prompt and cd to openssl_install_folder/bin
Give the below command to view the smtp certificate
openssl s_client -connect smtp.gmail.com:465
Copy the code highlighted in the picture above and paste it to a file and name it smtp_gmail.cert

Similarly, issue the follwing command to view the IMAP certificate
openssl s_client -connect imap.gmail.com:993


Copy the code highlighted in the picture above and paste it to a file and name it imap_gmail.cert

Now that you have both smtp and imap certificates with you, you need to import these to your server trust store
For this, open command prompt and navigate to %JAVA_HOME%/bin
Issue the following command
keytool -import -alias gmail-smtp -keystore gmail-keystore.jks -<location of smtp_gmail.txt>
It asks for password, give a password and pls remember it  as we'll use it later.
Issue a similar command for importing imap certificate
keytool -import -alias gmail-imap -keystore gmail-keystore.jks -<location of imap_gmail.txt>

----------------------
If the above commands dont work, issue the below ones. Note : do this only if the above commands dont work
keytool -import -alias smtp.gmail.com -keystore trusted-certificates.jks -file <location of smtp_gmail.txt>
 keytool -import -alias imap.gmail.com -keystore trusted-certificates.jks -file
<location of imap_gmail.txt>
----------------------
Once you are done with importing the trust certificates to the keystore using the keytool, you need to tell the managed server(soa_server1) that there is a user defined trust store from which it has to look for keystore
This will be done by editing the %MIDDLEWARE_HOME%\user_projects\domains\soa_domain\bin\setDomainEnv.cmd file
Search for -Djavax.net.ssl.trustStore and replace the value with the the gmail-keystore.jks file path that was generated by the keytool command. Also you need to edit -Djavax.net.ssl.trustStorePassword(if not avl, create one). So finally your entries should look somewhat similar to this

-Djavax.net.ssl.trustStore=D:\oracle\Middleware\jdk160_29\bin\demogmailcertstore.jks -Djavax.net.ssl.trustStorePassword=welcome1

Once you are done with this edit, one step is pending, where you will tell the managed server that a custom keystore is setup and has to be considered.
This is done by opening the Admin Console(<adminHost>:<adminPort>/console --> Environments --> Servers --> click on soa_server1)

 
Click on Keystores, and change the Keystores to "Custom Identity and Java Standard Trust"



That's it. You're done with configuring the certificates!!!

Step 2 : Configure email driver properties
This step configures email driver properties like email server details, incoming/outgoing email, passwords, etc.

For this, open EM, traverse as shown to open Email Driver Properties Screen


Configure the below mentioned properties
Property
Value
Comments
-----------------------------
FOR SENDING MAIL
-------------------------------------
OutgoingMailServer
smtp.gmail.com
As mentioned, SMTP is used to send mails
OutgoingMailServerPort
465
This is the port gmail uses for SMTP
OutgoingMailServerSecurity
SSL

OutgoingDefaultFromAddr
<mydefaultmailId@gmail.com>
The default FROM address (if one is not provided in the outgoing message).
OutgoingUsername
<mymailId@gmail.com>

OutgoingPassword
Password of the gmail id
Option to be selected is "Use Cleartext Password"
---------similarly for----
FOR INCOMING MAIL
-------------------------------------
IncomingMailServer
imap.gmail.com
As mentioned, IMAP is used to receive mails
IncomingMailServerPort
993
This is the port gmail uses for IMAP
MailAccessProtocol
IMAP

IncomingMailServerSSL
No need to check this option

IncomingMailIDs


IncomingUserIDs


IncomingUserPasswords



You're done!!!

Step 3 : Enable notification mode
This step lets the server know what mode to use for notifications. Since that we've configured email notification above, we'll enable EMAIL notification mode
Traverse to WorkFlow Config in EM as shown in picture


Setup the required values


Restart the Admin(for step1) & Managed Server(for steps 2&3)
This sets up the required configurations.

Step 4 : Testing the configuration
The last thing that you need to do is test it.

Navigate to Human WorkFlow as  shown

 
Notification Management --> Send Test Notification --> give detials in the popup and chk the mail
 
Hope this helps you in working with EMAIL notification service.

Thanks for going through my post, feel free to provide a feedback!

9 comments:

  1. This post is really good. And It worked well.

    Thanks for Posting..

    ReplyDelete
  2. Nice Post....ultimate explanation...

    ReplyDelete
  3. Nice post..very helpfull..!!

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. Worked for me.. Thank you

    ReplyDelete
  6. wow....amazing.... its working....keep it up man...............

    ReplyDelete
  7. Really a goo post , and it works!

    ReplyDelete