Oracle Service Bus, JMS Request/Response pattern

Inspired by the article of Edwin about JMS Request Reply Interaction Pattern in Soa Suite 11g, i will show a little example of what functionality Oracle Service Bus supplies to implement the jms request/response (reply) pattern.
The solution is quiet simple.

Create the wls resources

  • Create JMS Server, MyJMSServer
  • Create JMS Modules, MyJMSResources
  • Create a Connection Factory, MyConnectionFactory
  • Create 2 queues, MyQueueIn (request message), MyQueueOut (response message)

wls_resources

Create the osb resource

  • Create a new proxy service, JMSRequestResponsePS
  • ps_1
    ps_2
    For the Endpoint URi, insert the url to In-queue
    ps_3
    Check the ‘Is Response Required’ option.
    We will use JMSCorrelationID for the Response Correlation Pattern.
    For the Response URI, insert the url to the Out-queue
    ps_4

Testing
Now test the flow by insert a little xml message in the MyQueueIn queue, wait a few seconds and check the MyQueueOut queue.
Only thing what’s left is to fill in the message flow of the proxy service and add some logica.

Advertisements

About Eric Elzinga
Eric Elzinga I'm an integration consultant located in The Netherlands. Mainly doing projects based on Oracle integration stacks (Oracle SOA Suite/Oracle Service Bus (OSB)), Java development, and opensource integration products.

26 Responses to Oracle Service Bus, JMS Request/Response pattern

  1. Mr.K says:

    Hi eric, very useful post, I have another case, I must listen from one queue then forward every message to two different queue, how could I do that?, Now I already made one business service, but it only forward to one queue only.

    Really thanks in advance.

    • Eric Elzinga says:

      So all messages must be forwarded to both queues? (duplicated?)

      • Mr.K says:

        yeahh…it’s completely true..

      • Mr.K says:

        additional info : in my case, osb need to listen that queue and forward it to multiple application (with different queue too), who consumes the same message for different needed.

        any suggestion?

      • Eric Elzinga says:

        Since you don’t need any logic based on the messages, i would say you could make us of the ‘Store-And-Forward’ mechanisme in the Weblogic Server itself. See this : http://download.oracle.com/docs/cd/E12840_01/wls/docs103/saf_admin/config_jms.html

        Is that what you need? Don’t think you need osb in here, since you you don’t execute logic on the messages. If you do want to let all the messages get processed by some OSB process, you could always use a for-each loop and do several service call outs in it. So you don’t route to the business service but you do several call outs,depending on the amount of the ‘consumers’ you have.

      • Mr.K says:

        Hi eric, thanks for your aid, I prefer publish to service callout, and it works great now…

        I think the best approaching is using SAF but I’m still learning on it :d.

        Thanks

        K

  2. MK says:

    Hi, I’m new in JMS and OSB and testing this scenario.
    Could you write for me sample test message for MyQueueIn?

  3. sahil malhotra says:

    Hi Eric
    Thanks for the nice post. We have slightly different scenario. Our JMS is in different Server, infact it is Apache Active MQ to which we need to connect. Can you please let us know how can we do that using OSB ( we are able to do using composite JMS adapter but when it comes to OSB JMS adapter is not compatible).
    Thanks again
    Regards
    Sahil

  4. sahil malhotra says:

    Hi Eric
    Thanks for the nice post. We have slightly different scenario. Our JMS is in different Server, infact it is Apache Active MQ to which we need to connect. Can you please let us know how can we do that using OSB ( we are able to do using composite JMS adapter but when it comes to OSB JMS adapter is not compatible).
    Thanks again
    Regards
    Sahil

  5. Pierluigi Vernetto says:

    thanks Eric for the nice post, everything works well, keep up the good job

  6. mani says:

    Hi Eric,

    Can you please help I have a query for transaction time for xQuery mapping.
    Request is xmlschema (request.xsd) it is converted into response that is also a schema (response.xsd) for this I create one xQuery mapping source as request.xsd and response as response.xsd.In message flow of proxy I assiging it to one variable and using xQuery functions I get the transaction time for single mapping.
    But I want to get the transaction time for the multiple transactions (request and response is same but using For Each loop the request is to be iterate to number of times like 10,100 like this.
    Can you please provide any guide lines or else I can send the jar file to your mail Id.

    Hope I can expect response from you

    Thanks
    Mani

  7. mani says:

    Hi Eric
    Thanks for nice article.I have a requirement like
    An xml doc with one attribute is published using JMS store. There are multiple subscribers in OSB for that JMS store document.
    Research scope is – Can you trigger different (one or more) subscribers based on certain value for that single attribute.
    For this scenario how can I achieve.Please give your valuable suggestions and directions.

    Thanks
    Mani

    • Eric Elzinga says:

      Hi Mani,

      You could use jms properties and based on these properties use jms selector to decide to which subscriber can pick up the message.

      see this post : http://biemond.blogspot.com/2009/10/jms-request-reply-interaction-pattern.html
      and then one of the comments

      with this you can filter based on the property on a jms message, not on the payload itself

      if you want to filter based on the payload itself you could create some sort of dispatcher proxy service which picks up all the messages and dispatches them to different queues and for example sets those jms properties from the dispatcher.

      • mani says:

        Hi Eric,
        Thanks for reply,in this blog Edwin is explained with SOA but I am asking only in OSB,can you please any suggestions.

  8. mani says:

    Hi Eric,

    Thanks for the nice post. I follow the article but when I test the proxy I got error as

    Validation of ProxyService JMSRequestResponseEE/PS_JMSRequestResponse : ProxyService JMSRequestResponseEE/PS_JMSRequestResponse does not exist failed

    Can you give any suggestions.

    Thanks
    Mani

  9. Eric Elzinga says:

    Put some log activities in your flow to see what steps it does execute.
    the proxy service can be found at the point at which the fault message shows?

    • mani says:

      Hi Eric,
      Thanks for quick reply,When I test the proxy I got the response,but when I see queue I’m not found any messages in queue.
      One more thing is I create
      Create JMS Server, MyJMSServer
      Create JMS Modules, MyJMSResources
      Create a Connection Factory, MyConnectionFactory
      Create 2 queues, MyQueueIn (request message), MyQueueOut (response message)

      In my proxy I take the end point URI like
      jms://localhost:7001/MyConnectionFactory/ MyQueueIn

      I got the response

      But when test my proxy with

      jms://localhost:7001/weblogic.jms.XAConnectionFactory/jms/MyQueueIn

      In this case also I got the response and also I’m not found any messages in queue in both cases.

      Any suggestions.

      Thanks
      Mani

  10. mani says:

    Hi Eric,
    How to dequeue from jms-queue in OSB

    Thanks
    Mani

  11. mani says:

    Hi Eric,
    Can you please send the jar file or project artifacts of the post.

    Thanks
    Mani

  12. Maloti says:

    Hi Eric,

    m new to JMS,please tell me how to create jms server,modules and queues using oracle 10g workshop(OSB).

    Thanks & Regards
    Maloti

  13. Abhay says:

    Need help on using a message selector on a jms proxy service. The message selector should be based on the body of the xml. When i publish the message to the queue using a BS I tried setting the JMSType to weblogic.jms.extensions.XMLMessage and the selector to in the PS to JMS_BEA_SELECT(‘xpath’,’/order/ordertype/text()’)=’new’. But the PS is not able to pick up any messages in the queue. Sample xml message new

    Also where can i find documentation about the jms_bea_select function ?

  14. Rajesh says:

    I was able to test this out. It works as given by you. But not sure, how do I use this in actual context.

    I have a scenario in which I receive a synchronous request from client. I break that request in 3 parts and put message in 3 diffierent JMS queues(think it of as 3 partners), I have to receive the response from all 3 partners and based on the response send the message back to the client.?

    So in the example given by you, the same message is copied to the outQueue? Can I change the message in message processing?

    • Eric Elzinga says:

      Well i haven’t tested the next scenario but you could try this.
      in the request-pipeline do 3 service callouts, all sync, so you will need to get response back from all of them, for a first try just make this sequential.
      now just do a dummy replace of $body after the last one and see what you will get in the response-queue.

      if it works you can base the generated response message on the responses of all 3 service callouts.
      would be a good first test right?

    • Scott Nguyen says:

      Hi Rajesh,

      From your PS, can you can callout to the BS for each message part.

      Remember in your BS, under the JMS Transport tab, make sure you specify:
      1. Response Queues = One for all Request URIs;
      2. Response Pattern = JMSCorrelationID; and
      3. Response URI = MyQueueOut

      Cheers,
      Scott.

  15. Nikhil Jain says:

    Hi,

    My test case is a simple one. JMS Proxy (Publish with QOS- exactly once) –> http Proxy (Publish with QOS- Best Effort)–> http BS. Am getting a BEA-380000 – com.bea.wli.sb.pipeline.PipelineException error while testing from JMS proxy in test console. However, the test is successful while testing from http Proxy.

    I saw one of the threads OSB – BEA-380000 – com.bea.wli.sb.pipeline.PipelineException but it didn’t solve my issue.

    Please advise if anyone has a solution.

    Thanks,
    Nikhil

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: