This discussion is archived
11 Replies Latest reply: Aug 22, 2013 11:15 AM by 794954 RSS

Oracle service bus: Work manager and Throttling

Swapnil Kharwadkar Newbie
Currently Being Moderated
Hi

Flow is PS_C--->BS_A (based on PS_A)

I created a http protocol based proxy service PS_A and a business service based on PS_A, i.e. BS_A.

Now this BS_A is deployed on four different managed servers. I have implemented failover so at a time copy of only one of the managed severs will be accessed by multiple external clients through PS_C. To say all will hit Managed server-1 copy of BS_A. If Managed server-1 is down then it will hit Managed server-2 copies of BS_A.

I have created a workmanager named "CustomWorkManager" which has MaxThreadConstraint=1. PS_A has not enabled CustomWorkManager. i.e. PS_A works under default policy.


My goal is to process only one request at one time through BS_A.

In business service, BS_A I can see work manager and throttling options.


My question is this:

Scenario I: I make throttling enabled and set maximum concurrency=1 for BS_A
Scenario II: I apply CustomWorkManager to BS_A
Scenario III: I do both Scenario I and Scenario II



What is the difference between I, II and III?

Fundamentally, what is the difference between throttling with maxConcurrency=1 and MaxThreadConstraint of workmanager=1 for a http business service?

Thanks and Regards,
Swapnil Kharwadkar
  • 1. Re: Oracle service bus: Work manager and Throttling
    AbhishekJ Pro
    Currently Being Moderated
    You have to use option I : I make throttling enabled and set maximum concurrency=1 for BS_A

    Using a work manager with Max Thread Constraint as 1 will make sure that only 1 thread is available on EACH managed server of cluster to a Proxy/Business service using said work manager. So if you apply a Max Thread constraint of 1 on your Business service, you will be able to invoke one instance of Business Service on each manager server(each of these 4 managed servers will be calling the Managed server 1 of target service because of your end point failover configuration), which you do not want.
    Moreover, In case of a JMS PROXY(not your use case but good for understanding), using max thread constraint as 1 does not ensure a single threaded processing model because of two reasons:
    1. There will be one instance of proxy running on each managed server
    2. Each instance of proxy will poll more than one message in a session (by default MaxMessagesPerSession is 10), so if you have 4 managed server and you have applied max thread constraint of 1 on your JMS Proxy, then it can poll 4x10=40 messages concurrently.

    Using throttling will ensure that only one message is dispatched to target service even if business service is deployed on clustered environment. OSB uses an internal queue for this. This queue basically has a restriction to dispatch only one message at a time. When you use throttling, the calling proxy is able to invoke multiple instances of business service, but business service forwards messages to target service one at a time.
  • 2. Re: Oracle service bus: Work manager and Throttling
    Swapnil Kharwadkar Newbie
    Currently Being Moderated
    Hi Abhishek

    I exercised option I.

    Unfortunately that did not work. We executed around 240 transactions and it failed for 1 time out of 240. (239 were successful)

    What i am thinking is of two options:

    1. Make throttling of BS_A enabled, set max concurrency=1 and use work manager with maxThreadConstraint=1 for BS_A (scenario III in my previous post)
    2. Make throttling of BS_A enabled, set max concurrency=1 and use work manager with maxThreadConstraint=1 for PS_A. (BS_A is based on PS_A)

    I will be running tests and post results back. Duplicate test data can not be used for tests in my case so it takes time to prepare data.
    Meanwhile if you have any opinion about above two options, kindly revert.

    Thanks for help. Very much appreciate it.

    Thanks and Regards,
    Swapnil Kharwadkar
  • 3. Re: Oracle service bus: Work manager and Throttling
    AbhishekJ Pro
    Currently Being Moderated
    How did you test your scenario? Did you shutdown/disabled the Managed server 1 to test the failover during the test? Also, how big was the throttling queue and what was the error for the failed message?
  • 4. Re: Oracle service bus: Work manager and Throttling
    Swapnil Kharwadkar Newbie
    Currently Being Moderated
    Basically BS_A selects and updates some values in DB. Throttling has queue for 5000 messages. In logs i could see that the same data has been retrieved for the two consecutive requests. These requests failed when they try to hit actual backend with duplicate values of data received from DB (hitting backend with duplicate data is not allowed). The time difference between to requests to BS_A was around 100 milli seconds.

    I guess following is happening in this scenario (mentioned in CASE I):

    CASE I:

    Four requests received--->BS_A-->forwards first request and do not wait for response for first request-->forwards second request and do not wait for response for second request-->forwards third request and do not wait for response for third request-->forward fourth request and do not wait for response for fourth request

    Responses must be being executed as in parallel with requests.


    What I actual want is:

    CASE II:

    Four requests received--->BS_A-->forwards first request and waits for response for first request-->gives response back for first request-->forwards second request and waits for response for second request-->gives response back for second request-->forwards third request and waits for response for third request-->gives response back for third request-->forward fourth request and waits for response for fourth request-->gives response back for fourth request

    BS_A is of type HTTP and not JMS.

    Any thoughts!

    Thanks and Regards,
    Swapnil Kharwadkar
  • 5. Re: Oracle service bus: Work manager and Throttling
    AbhishekJ Pro
    Currently Being Moderated
    Can you try Routing Option Exactly Once when you call from PS_C to BS_A.
  • 6. Re: Oracle service bus: Work manager and Throttling
    Swapnil Kharwadkar Newbie
    Currently Being Moderated
    Call from PS_C to BS_A is a service callout so it is already a blocking call. Still I set, no difference.
    Also when i tried setting options III of my question post and option II in my reply post, OSB hangs! I get service timeout for each request. Now this is confusing!!
  • 7. Re: Oracle service bus: Work manager and Throttling
    AbhishekJ Pro
    Currently Being Moderated
    From what I understand, the problem is that HTTP is a non transactional transport. So when OSB is implementing throttling, it will consider a request as processed as soon as the HTTP request is sent to the target service and then it will process another request from throttling queue. Also, OSB services are stateless, so one request can not be related to any other request. Your requirement is to have single thread processing in sequence which is not supported OOTB in OSB. One way to achieve true single threaded processing in OSB is given below but not a good way to do it.
    1. Create a JMS queue deployed only on Managed Server 1, change the setting MaximumMessagesPerSession to 1 for this queue.
    2. Put the messages in this JMS queue from PS_C (by calling a new JMS BS_JMS)
    3. Create a new JMS Proxy PS_JMS to read messages from the queue.
    4. Use the WOrk Manager with MaxThreadConstraint as 1 on this JMS Proxy, so there is only one thread for proxy on each Managed Server
    5. From Weblogic console deployment, change the target for the EJB of this JMS Proxy to only Managed Server 1 instead of cluster.

    Now the JMS Proxy will only run on MS1, only 1 thread of proxy will run in cluster and it will pick up only one message at a time from JMS queue. You can then call the BS_A from this JMS proxy and control the behavior as you wish.
    But like I said its an ugly solution. If you can elaborate on overall design and constraints then we might be able to provide a better solution.
    For ex. Why do you need a single threaded processing? Is it a limitation on target service?
    What is the target app/service? Is it DB, HTTP or anything else?
    Why are you using a BS to call from one Proxy to another Proxy?
  • 8. Re: Oracle service bus: Work manager and Throttling
    Anuj Dwivedi Guru
    Currently Being Moderated
    It's not a OSB use case. Still if your customer wants to use OSB for it, then please refer -

    Processing JMS messages in sequence one after another
    Sequential proxy execution in OSB

    Regards,
    Anuj
  • 9. Re: Oracle service bus: Work manager and Throttling
    Swapnil Kharwadkar Newbie
    Currently Being Moderated
    @Abhishek: Thanks for descriptive reply.
    @Anuj: Thanks for links, I am having a look..

    Use case:

    What is the target app/service? Is it DB, HTTP or anything else?
    Back end: Amadeus web services

    Role of DB:
    1. It will store data to attach transaction context to a request. This is to call more than one services in the backend - it is necessary for backend to understand in which context services are being invoked.
    For example, if I need to make PNR related changes, I need to invoke service X and fetch transaction context from back-end. The transaction specific identifier (read session) will be received in header part. After retrieve suppose I need retrieve PNR, I will invoke service Y. When I invoke, I need to put the transaction specific header part received in response of service X and then change body as per request format of service Y (read the response header of X will be the same as request and response header of Y) which will actually make changes and commit in the backend. (So back-end will understand that service X and Y are invoked as a part of single transaction, and transaction can be identified through logs)
    3. Once my X+Y call is over and transaction is committed, the context for transaction specific part received in header to the transaction is removed from back-end. Then I can use session again for the next transaction.
    4. To re-use session I am storing it in DB and retrieving as per need for each call to Amadeus.

    Problem is, it is absolute necessary for all transactions which are being processed simultaneously, to have unique session in header.

    For example,

    I do the following:

    Request 1: receives session from service X, uses for service Y. After use, inserts session in DB. Now context for that session is removed from back-end.
    Request 2: looks for session DB, puts in header and invokes backend. Context for Request 2 is attached to session retrieved from DB.
    Request 3: looks for session DB, puts in header and invokes backend. Context for Request 3 is attached to session retrieved from DB.

    As you can see if Request 2 and Request 3, pick up the same session from DB and invoke back-end, back-end services won't be able to understand which request the session belongs to, and will fail both requests. Ideally Request 2 should retrieve it from DB use for itself and Request 3 should make a call to service X at back-end to receive context. With this new context Request 3 should proceed for transaction.

    Why are you using a BS to call from one Proxy to another Proxy?:

    1. To interact with DB, I use DBAdapter business services with QueryByExample/Update/Insert operation.
    2. My PS_A is proxy which orchestrates these operations. (Read: SelectandUpdateDBForSessionRetrieve, UpdateDBWhenTransactionOver functionaries) Since there are two admin and four managed servers, all copies of PS_A will try to access DB simultaneously, and concurrency will fail.
    3. Hence I made BS_A on the basis of PS_A. BS_A is deployed on all four managed servers, used Load Balancing Algorithm as "None" and gave hard-coded urls of four managed servers in sequence of MS1, MS2, MS3 and MS4.
    4. Idea is if MS1 is ok, all requests will go to BS_A of MS1 only, and if somehow if I make it single threaded *(Read from DB+mark retrieved data as "in use" so other request can not use it)*, concurrency issue will not arise. In case MS1 is down, the requests will automatically forwarded to MS2 and since that is also single threaded, concurrency issue won't arise. In short both fail-over and concurrency can be achieved with BS_A making out of PS_A.

    The problem as you have correctly pointed out, is that OSB is stateless and one request has no relation with another. Somehow, I need to make every retrieve/update/insert to database as single threaded, i.e. once one is done then another should not be done at the same time. Else entire point of this pooling will fail.

    Please share any thoughts you might have. Even another approach to handle this single threaded need will do.

    Thanks and Regards,
    Swapnil Kharwadkar
  • 10. Re: Oracle service bus: Work manager and Throttling
    819690 Newbie
    Currently Being Moderated
    From what I understand, your most basic requirement is that you need to get a session from target system for each transaction by a web service call and use that session for the actual transaction in another web service call.
    Ideally in this kind of scenario let OSB do the orchestration. That is, if possible, ask the service consumer to send a single request for doing both Retrieval of session and doing update/query on PNR. This way you dont have to save the session in a DB. You will receive a single request from consumer, from OSB proxy you will call Service X to get the session details, then within the same Proxy call service Y with the session detail to do the update PNR and return a final response to the service consumer.
  • 11. Re: Oracle service bus: Work manager and Throttling
    794954 Newbie
    Currently Being Moderated

    Hi Abhishek,

     

    I just checked your reply to this.

     

    I have a single threaded requirement.

     

    I did the below 4 steps. 5th step i havent found any EJB on wls.

     

    1. Create a JMS queue deployed only on Managed Server 1, change the setting MaximumMessagesPerSession to 1 for this queue.

    2. Put the messages in this JMS queue from PS_C (by calling a new JMS BS_JMS)

    3. Create a new JMS Proxy PS_JMS to read messages from the queue.

    4. Use the WOrk Manager with MaxThreadConstraint as 1 on this JMS Proxy, so there is only one thread for proxy on each Managed Server

    5. From Weblogic console deployment, change the target for the EJB of this JMS Proxy to only Managed Server 1 instead of cluster.

     

    Also,

     

    Below is one of my query. Appreciate your help for your suggestions

    (

    Below is my process flow

     

    JMSQ -> JMS PS -> BS - > Endpoint

     

    So i have the requirement to send the messages one at a time so i did 2 settings

     

    1. JMS connection -> Max messages per session =1

    2. Created WorkManager with Max threads 1

     

    This works fine in case of normal processing

     

    But now i have a requriement to add a redelivery limit and redelivery interval in the Queue to route to error queue in case of error

     

    So in the delivery failure tab i changed the values..

     

    So when i do this change all the messages are consumed at once retried and roll backed. I need messages to be consumed one by one and retried.

     

    Am i missing some thing? Or singletonprocessing wont work with ReDelivery can anyone please suggest?

     

    Note: I have XA transaction enabled on JMS Proxy and Unit Of Order created on the JMS Connection factory )

    .

    https://forums.oracle.com/message/11154504#11154504

     

    Message was edited by: 794954

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points