Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 11.46.38 AM

Proces email with the new UMS adapter of SOA Suite PS5

With the release of Soa Suite Patch Set 5 we can now try out the new UMS adapter. UMS stands for User Messaging Service but in this case it only supports email. The UMS adapter allows you to listen for new mail or send a mail from a service component. Combined with BPEL it’s now relative  easy to process email bodies or attachments. Remember that in PS5 the UMS adapter is still a  preview version so you can’t claim support and you can only use the Oracle forums for your ums questions.

It’s important to know that the UMS adapter does not work like a JMS topic or like EDN. So you can’t have two UMS adapters which are polling on the same mailbox.

In this blogpost I will show you how to setup and configure UMS, Listen plus send a mail and handle attachments.

We start with configuring our SOA Suite domain.

1st step is to copy two UMS libraries to your SOA Suite domain folder. Copy sdpmessagingclient.jar and sdpmessagingcommon.jar to the lib folder of the SOA Suite WebLogic Domain. You can find these jars at MiddlewareHome\Oracle_SOA1\communications\modules\oracle.sdp.client_11.1.1

2nd Install the UMS resource adapter.  Open the WebLogic Console and deploy the UMSAdapter.rar, you can find this adapter at MiddlewareHome\Oracle_SOA1\soa\connectors . Make sure you targeted this Resource Adapter to the SOA managed WebLogic server. And restart the SOA Suite Server.

3rd Check if the usermessagingdriver-email and usermessagingserver applications are active and targeted to the to the SOA managed WebLogic server. You can check this in the deployments of the weblogic console.

4th Configure the UMS Email driver.  For this we need to go the Enterprise Manager application. When everything is Ok you should see the User Messaging Service. Here we can select usermessagingdriver-email and in the menu we can go the Email Driver Properties.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 11.46.38 AM

Here we can set some defaults, like the default mail address, Cost and Speed ( cpu priority )

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 11.54.29 AM

The UMS settings for outgoing mail.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 11.59.05 AM

The incoming settings are more complex because I will read two mail accounts, this is because I need one mail account for every polling UMS adapter.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.04.48 PM

To make this work I can use a “,” between the values so for IncomingMailIDs I use this as value soa@local.nl,soa2@local.nl , do the same for IncomingUserIDs = soa,soa2  and for the IncomingUserPasswords, I use CleartextPassword and also use a “,” between the passwords.

Restart the SOA Suite server.

 

At last we must enable the UMS adapter in JDeveloper.  Go to the JDev11.1.1.6\jdeveloper\integration\seed\soa\configuration folder and open the soa-config.xml. Find the adapterType with this ${UMS_ADAPTER_COMPONENT_NAME_L}  as name and remove the preview = true attribute. Now You will see the new UMS adapter in your SOA Component Palette.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.25.21 PM1

 

In the next part we can finally try this out.

Let’s start with an easy one. Sending a mail from a composite. For this we need to drag the UMS adapter to the External Reference of the Composite.

Don’t change Connection JNDI name.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.32.59 PM

Choose for Outbound Send Notification. You can choose to receive the Mail Message Id as response, else it will be One Way.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.33.21 PM

Provide the Mail Header settings.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.34.12 PM

For Message Schema you got 3 options ( this talks about the mail body ) , off course Opaque, Message is a big String or based on a XML Schema.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.34.55 PM

 

Next we can take a look at incoming part of the UMS adapter. Drag the UMS adapter to exposed Services side of the composite.

Don’t change the default Connection JNDI Name

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.46.35 PM

Choose Listener as Operation Mode, Polling does not work in this Preview Adapter and the UMS email driver already polls every few seconds.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.46.51 PM

Provide the mail adress this must match with your incoming UMS configuration.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.47.33 PM

Also provide the message type.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.47.47 PM

 

We can also define a message filter which can accept or ignore the incoming mails. The pattern string should be a java regexp. To test this pattern you can use this url  http://www.regexplanet.com/advanced/java/index.html

Too bad this feature does not work yet in this technical preview.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.48.19 PM

 

And also you can do a custom Java Callout ( I didn’t test it and don’t know the possibilities of this feature).

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 12.48.44 PM

 

To test this I need to add the employee xml in the body of the mail ( not as attachment)  and send it to soa@local.nl. As response I will get a mail.

The request I will receive in SOA Suite.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 1.04.25 PM

And the response

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 1.05.45 PM

 

Last part of this blogpost is about, how to handle mail attachments.

For this I will use the second mail address soa2@local.nl and also change the message type to String. A BPEL service component will write these attachments to a server location.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 1.13.47 PM

This is the request I received in the BPEL component. You can see that we only get a reference to the attachments.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 1.13.17 PM

So in BPEL we need to use a ForEach to handle every attachment and write this to a file.

Proces email with the new UMS adapter of SOA Suite PS5 Screen Shot 2012 05 18 at 1.17.29 PM

To load the attachment and assign it to the file adapter input variable I need to use ora:getAttachmentContent

<assign name=”AssignInput”>
<copy>
<from>ora:getAttachmentContent(‘ReceiveMail_InputVariable’,’body’
,’/ns3:message/ns3:attachment/ns3:Attachment[$ForEachCounter]’)
</from>
<to>$InvokeWriteFile_InputVariable.opaque</to>
</copy>
</assign>

and this leads to two files.

Here you can download the UMS workspace https://github.com/biemond/soa11g_examples/tree/master/UmsSOA

9 Comments

  1. vikas June 22, 2015
    • Navakanth September 11, 2015
  2. Kiran February 25, 2015
  3. sameeralwosaby May 1, 2014
  4. Abhi July 10, 2013
  5. CM October 31, 2012
    • John July 10, 2014
      • CM July 11, 2014
  6. Betino August 29, 2012