Pages

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.

24 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
  6. Shouldn't you close your connections in a finally block?

    ReplyDelete
  7. Hi Edwin
    Thanks for posting nice article but I did not understand how it will work for osb. Are there any disadvantages if we directly produce message to the edn queue from osb? I tried to produce the message but did not see in the queue.

    ReplyDelete
    Replies
    1. Hi,

      Did you this as jms endpoint url
      jms://soa_server:8001/jms.fabric.xaEDNConnectionFactory/jms.fabric.EDNQueue

      no need for foreign server and did you try it in the Java client.

      Good luck

      Delete
  8. I liked your post. Can you please tell me does it work for only EDN-JMS? Can I use osb to publish to EDN-AQ? why did you use mq in transport header? In the transport header you added another business event what is it? I am sorry for asking lot of questions.
    Thanks

    ReplyDelete
    Replies
    1. Hi,

      You can try it with a JCA AQ adapter Business service , don't know what you need to fill for AQ header and payload. probably the same.

      I need to set the MessageType and only mq got this. No problem it works also for jms transport

      I think EDN needs this, to route the message so it does not need to analyze the payload.

      thanks

      Delete
  9. Hi,

    I don't know exactly but I think it is for defining a remote edn event. in this blogpost it should be remote, soa composites can't be part of the same transaction.

    thanks

    ReplyDelete
  10. Hi Biemond,

    I have some couple of questions.

    1. Is there way to subscribe the events using Java API
    2. What level of OWSM security we can use in the event.
    3. If there are no event subscribers, what happened to published message?

    -Madhav

    ReplyDelete
    Replies
    1. Hi,

      1) No use a JMS topic, Only SOA Suite can listen for edn events other can publish , Only advantage of EDN is de event xsd can be seen and used everywhere and no need for JMS configuration.

      2) OWSM only works for web services , EDN is more JMS. In weblogic JMS you can protect the topics and queues.

      3) Gone in the wind. Don't think EDN has durable subcribers like jms topics.

      So JMS is not so bad
      :-)

      Delete
  11. Hi Edwin,

    I successfully could able to post the message to the queue, but was not able to consume this.. and i followed the steps from your post - http://biemond.blogspot.com/2011/06/configure-en-test-jms-based-edn-in-soa.html

    So any idea on why the message is not consumed.

    Please advise.

    Srini

    ReplyDelete
    Replies
    1. Hi,

      did you see this comment
      I have managed to get this working... It worked once I deployed the listener code to the server. I presume that it was throwing away the messages if there were no subscribers to the queue.

      So you need to have a listening and maybe also an edn producing composite to activate EDN

      thanks

      Delete
  12. Thanks Edwin. Really appreciate you for all your posts.

    They really help us.

    ReplyDelete
  13. Hi Edwin,

    We are using mediator to listen a Item Business event (Oracle Applications (PIM)) and from there we use AIA architecture to target applications. But as the message flow is very slow and very heavy they wanted to rewrite the fusion layer with OSB. Iam trying to do a POC on that by using a java client to read business event and then using service callout to call some web service and publish to target application.

    1. Is it possible to use Java client to pull message from business events ?
    2. How business events are working ?

    Thanks,
    Vijay

    ReplyDelete
    Replies
    1. Hi,

      do you mean EDN, just switch to JMS and use a Topic with durable subscripbers or a Queue. it works the same.

      thanks

      Delete
  14. Hi Edwin,

    we all know that OSB can publish to queue/topic in text or byte message formats. Here I am trying to publish Map Message type to a topic with OSB. I am getting error while invoking the service that it is not either text or byte message. I tried the same with BPEL and it worked fine but trying with OSB always failing. Can you please direct me in right direction.
    whether OSB support MapMessage format in queue/topic while publishing?
    if so how.

    Thanks,
    NEX.

    ReplyDelete
    Replies
    1. Hi,

      Did you use a Java Callout to create a byte Message. By the way are you using the OSB JMS transport . BPEL uses the JMS JCA adapter. Maybe you can use that in OSB.

      Thanks

      Delete
    2. Which jar files did you include? The sceenshot doesn't list their names to build it with another IDE.

      Delete
    3. Hi,

      it's made it in Jdeveloper 11.1.1.7 with the matching soa addon.
      I think I used this project https://github.com/biemond/soa11g_examples/tree/master/EDN_JAVA

      jdeveloper/soa/modules/oracle.soa.fabric_11.1.1/fabric-runtime.jar
      jdeveloper/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar
      /oracle_common/modules/oracle.fabriccommon_11.1.1/fabric-common.jar

      thanks

      Delete
  15. Hey Edwin,

    Can you help me on how to get SOA Composites status by a script may be WLST or by Java? i want to fetch the status of some of the composites, how should i proceed?

    ReplyDelete