Tuesday, June 21, 2011

Publish to EDN from java & OSB with JMS

My previous blogpost was about how to configure the SOA Suite EDN for JMS ( EDN-JMS ) instead of AQ (EDN-DB) and in this blogpost I will show you how you can publish events from Java and OSB.

Before we start you should know that we can only make Remote Event Connections because you are running the Java or OSB process in a different JVM then the SOA Suite. And only asynchronous subscriptions will be supported for remote event connections.

First let's create a Java Client which publish the events directly to the SOA Suite Server. I will use the jars of the SOA Suite. This is not necessary. You can just publish a JMS text message and set some JMS Header properties (MessageType and SideCar )

Make a new JDeveloper  project which contains the following libraries.

Here is my test class.
And this will produce the following event on the EDN Queue.

The second part of this blogpost is how to do this in OSB.
Before we can work on the Proxy or Business Service we need to create a Foreign JNDI Provider on the WebLogic Service. ( You can also use a JNDI Provider of the OSB Configuration project )

Provide the SOA Server details.

Provide the local and remote EDN-JMS JNDI Link names. The Remote JNDI Names are fixed but you can change your  local ones.

Restart the OSB Server and open OEPE or the SBConsole.

Create a new Business Service and choose for Messaging Service as Service Type.

Event is an One Way Operation so only need to set the Request Message Type to text.

Use the Local JNDI names of the Foreign JNDI Provider in the Endpoint URI

 Select Text as Message Type.

Create a Proxy Service which call this Business Service, where we will replace the Body contents with the event data and set some JMS Headers in the Transport Header.
 Replace the body contents in a Replace Action.

My test event, the values of Id and ecid element contains unique UUID values.

And the last part is to set the Messagetype and SideCar JMS Headers
MessageType is always Remote
SideCar in my case

<business-event-sidecar xmlns:ns="http://schemas.oracle.com/events/edl/EmployeeEventEDL"
                        xmlns="http://oracle.com/fabric/sideCar">
<name xmlns="http://oracle.com/fabric/businessEvent">ns:EmployeeEvent-sidecar</name>
</business-event-sidecar>

You can test the Proxy Service in the SBConsole.

5 comments:

  1. Nice Post!
    But while running Java code to publish message to JMS queue of EDN I'm getting below error,
    cannot find constructor JmsRemoteBusinessEventConnectionFactory(javax.jms.QueueConnectionFactory,javax.jms.QueueConnectionFactory,java.util.Queue,javax.transaction.UserTransaction)

    at line ,
    BusinessEventConnectionFactory factory =
    new JmsRemoteBusinessEventConnectionFactory(queueConnectionFactory,
    xaQueueConnectionFactory,
    (Queue)jmsQ,
    userTransaction);
    Please suggest.

    ReplyDelete
  2. Hi,

    I tested it with jdev ps3 and the matching SOA plugin . I think ps4 should also work. Not 11gR2

    Did you use jdev and do you have the same libraries on your project.

    Thanks Edwin

    ReplyDelete
  3. Ya I tested with PS3 only , might be making some mistake will recreate ...
    For the OSB part its working fine with me but JMS endpoint for EDN queue is different ,
    jms://:/weblogic.jms.XAConnectionFactory/jms/fabric/EDNQueue

    ReplyDelete
  4. Hi Edwin, I am trying to run the OSB on my local server whereas the EDNQueue has been configured on remote server. I am getting the Failed to resolve error. I have provided the endpoint of remote Queue, Do you reckon there is a need of any other setting?

    ReplyDelete
  5. Hi,

    what you can do is to go directly to the soa server instead of the foreign jndi

    use this url in the BS service jms://soa:8001/jms.fabric.xaEDNConnectionFactory/jms.fabric.EDNQueue

    good luck

    ReplyDelete