IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

  • 1.  Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

    Posted Mon July 25, 2016 03:12 AM

    Hi ,

    Regarding Broker Subscription flow service.

    1. Developed a flow service “A” which fetches data from a database(“DB1”) and publishes it to a publishable document(The publishable document contains a document list ) .

    2. Developed a flow service “B” to Subscribe the published document(which contains a document list published by the flow service “A”) and insert into a database “DB2” .

      The “B” (Subscribe) flow service has the below logic.
      i) Subscribes the published document which contains a document list ( published the flow service “A” )
      ii) Loop the document list
      Inside the loop
      Try
      {
      a) Start transaction
      b) Insert adapter (for header table)
      c) Batch insert adapter(for child table)
      d) Commit transaction
      }
      catch
      {
      Invoked - pub.flow:getLastError
      Rollback Transaction

          }
      
    3. Created a Trigger “T”
      Which calls the flow service “B” when the publishable documents has data

    Works State : working fine if I maintain a correct set of data
    Then, Executed flow service “A”
    (Internally the trigger “T” calls the flow service “B” and inserts the data into “DB2” correctly)

    Issue : If I purposely maintain a wrong set of data.
    Then, executed flow service “A”

    Internally the trigger "T" calls the flow service "B" and try to insert the data into "DB2", due to some constraint the data is not inserted 
    And the Transaction is Rolled back 
    
    [b]But trigger "T" repeatedly calls the Subscribe flow service ("B") and keep on tries to insert the wrong records and rollbacks.
    

    How can I handle / stop the repeated execution of the flow service “B” if wrong set of data maintained ?
    [/b]
    Regards,
    Daniel Sebastian .C


    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

    Posted Mon July 25, 2016 07:05 AM

    Hi Daniel,

    Please check the trigger retry properties and retry interval which might be causing your trigger service to run on failures.

    Also check if publishing service is generating publishable document repeatedly which is causing your trigger service to run many a times.

    As far as I know if for single document is published then only single subscription should happen if we handled everything in right manner.


    #Integration-Server-and-ESB
    #webMethods


  • 3.  RE: Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

    Posted Mon July 25, 2016 07:19 AM

    Hi Firoz,

    The trigger retry property has two types
    i) Max attempt reached
    ii) Successful

    In my trigger

    retry until : Max attempt reached
    retry interval : 0


    #webMethods
    #Integration-Server-and-ESB


  • 4.  RE: Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

    Posted Mon July 25, 2016 07:30 AM

    Daniel,

    firstly, you have not picked the best forum to post this question on. This is the forum for general webMethods announcements. A better forum would be the IS/ESB on: Integration-Server-and-ESB Knowledge base articles, news, Community help, and support forum discussions

    To answer your question, if you rollback the transaction, then it is expected that you will get the same message again. Are you in your catch-block also calling pub.flow:throwExceptionForRetry?
    What behavior do you actually want if the database insert fails?
    Generally you would want it to be logged to the service audit database so you can manually resubmit it later (when you have fixed the data issue). In that case, you don’t actually need the transaction management and try-catch block, as the JDBC service will throw an exception. Just configure service auditing on the top-level service to log on error and include pipeline on error. That should ensure only a single execution attempt for each message.


    #webMethods
    #Integration-Server-and-ESB


  • 5.  RE: Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

    Posted Mon July 25, 2016 08:10 AM

    Share the screen shot of trigger properties showing: Transient error handling settings and outline of your subscriber service.

    Also in your subscriber service make sure you have the startTransaction outside the main sequence.


    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back



  • 7.  RE: Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

    Posted Mon July 25, 2016 08:42 AM

    Mr. Jonathan Heywood,

    In catch block I didn’t invoke pub.flow:throwExceptionForRetry.

    (What behavior do you actually want if the database insert fails? ) If any exception occurs in the flow service, it should go into catch block and gets finished.

    But now when exception occurs(inside subscription service) the trigger repeatedly calls again and again the subscription service.

    My need is, if exception occurs the flow service should go into catch block and gets finished, It should not execute repeatedly.

    And can you please elaborate the part
    " [Generally you would want it to be logged to the service audit database so you can manually resubmit it later (when you have fixed the data issue). In that case, you don’t actually need the transaction management and try-catch block, as the JDBC service will throw an exception. Just configure service auditing on the top-level service to log on error and include pipeline on error. That should ensure only a single execution attempt for each message. ]"

    Because the subscribe flow service will receive a document(which contains a document list ).
    And i should iterate(loop over) the document list and insert into the database. So that i perform start and insert transaction inside try and roll back transaction inside catch.


    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

    Posted Mon July 25, 2016 01:05 PM

    Are you sure that the publishing service is not publishing each instance of the document and it is publishing all the once. The subscriber service and trigger looks ok as there is no retry enabled.


    #webMethods
    #Integration-Server-and-ESB


  • 9.  RE: Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

    Posted Mon July 25, 2016 05:24 PM

    Can you please give a try as below.

    Suspend the trigger, enable it again.

    Run the publishing service, and disable the publish step of the publishing service and see the behavior.

    which wM version you are on ? What fix levels do you posses ??


    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: Trigger repeatedly calls the Subscribe flow service if a DB Transaction is Rolled back

    Posted Tue July 26, 2016 08:07 AM

    Hi,

    what is the setting for delayUntilServiceSuccess for the publish step?

    If set to true, all documents will be published together at the end of the service.
    If set to false, each document will be directly published.

    See Build-In-Services-Guide for details.

    Regards,
    Holger


    #Integration-Server-and-ESB
    #webMethods