Wednesday, September 29, 2010

Sending Mail from OSB 11g (11.1.1.3.0) to Apache JAMES

In this post I will discuss about sending mails from OSB 11g. I will use Java Apache Mail Enterprise Server (JAMES) as a mail server.

First of all download Apache JAMES 2.3.2 Binary (ZIP Format) from
here. Follow below links for installing it and doing initial configuration –

http://james.apache.org/server/head/installation_instructions.html
http://wiki.apache.org/james/JamesQuickstart

I configured a mail server anuj.com and created two users oracle@anuj.com and testuser@anuj.com

Now I will configure Oracle Service Bus. First of all create a SMTP Server resource in OSB configuration. For creating a SMTP server resource go to System Administration --> Global Resources --> SMTP Servers and click on “add” (You have to click on “Create” button in the change center to create a new session for your editing, otherwise “add” button will remain disabled)
Provide the details there as shown below-








After creating SMTP server, I will create one Email business service to send messages to JAMES. You may create a business service inside any OSB project.

I am creating a business service named “TestLocalMailServer” which is a “Messaging Service” type business service –











Click on next and it will ask you to provide message type configuration details(request and response message type) –













I select request message type as “Text” and Response message type as “None” (because no response is expected in email transport as it is a one way process)

Click on next and provide the transport configuration details. Select “email” in transport dropdown list and add an endpoint URI oracle@anuj.com –











Click on next and provide the Email transport configuration. In “SMTP Server” dropdown list, select the SMTP server you created earlier. Provide the “from” and “reply to” details as well –











Now click on “Last” (to choose default for rest of the settings) and you will see below configuration –

















Save the business service details and activate the configuration using Change center.

You are done with the configuration part now and your business service is ready to be tested.

Open the OSB test console by clicking on the “bug” icon against the business service name. Provide the message/text you want to mail across and set the subject line-
















Now click on “Execute” and if processing goes successful then you would see “There was no response.” text under “Response Document” section –








Now to check whether actually mail has been received on JAMES, go to james-2.3.2\apps\james\var\mail\inboxes\oracle directory and should see two files there (for one message) –







Open the file with extension “FileStreamStore” in any text editor and it will show you content below content –










So you are done with sending mails from Oracle Service Bus to Apache JAMES


2 comments:

  1. Hi Anuj,

    Useful article. I tried this on my machine, I was able to set up James and was able to send email from OSB. However, when I test the OSB service, it doesn't send the email instantly. It will send the email if we execute the service again. So if on first execution I send an email to "xyz", nothing will happen, 'xyz' won't get my mail. But if I execute the service again and send an email to '123' then 'xyz' will receive the previous email. '123' however will not receive anything. Do you know what the problem could be?

    Thanks,

    Mustufa

    ReplyDelete
  2. Hi Anuj,

    Thanks. I was able to send out an email from OSB. When I check my inbox I don't see it got delivered to inbox but instead I see the messages in outbox. Do you know what could be the reason for it not getting delivered to my inbox.

    Thanks,
    Osb

    ReplyDelete