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.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
Expand all | Collapse all

How does finally block work in case of errors

  • 1.  How does finally block work in case of errors

    Posted 05/28/15 10:46 AM

    Hi Everyone

    I have developed a code where in we are connecting to application servers using sftp. Since we have to logout the sessions in case of success/failure, i have implemented the finally block.

    Below is the flow:

    MAIN[EXIT ON SUCCESS]
    -TRY[EXIT ON FAILURE]
    -CATCH[EXIT ON DONE]
    FINALLY[EXIT ON DONE]

    In the catch block, the last step is exit from parent and signal failure, so in case of failures, the finally block is unable to get the pipeline values, since at the exit step, the pipeline is being cleared.

    Could someone please help me know how we can save the pipeline value(session names) in case of errors, so we can log out in finally block.

    Thanks in advance.


    #webMethods
    #Integration-Server-and-ESB


  • 2.  RE: How does finally block work in case of errors

    Posted 05/28/15 11:23 AM

    Use logout as the last step in try block and after the getLastError in the catch block by doing this you don’t need a finally sequence.

    Do you need finally block at any cost?


    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: How does finally block work in case of errors

    Posted 05/28/15 11:29 AM

    Thank you Mahesh for the reply.

    In that case, we need to place logout service in try as well as in catch so during success, it will be implemented in try and in case of error, it will be implemented in Catch block.

    To avoid repetition, i have placed finally block. So is there a way, we can fetch the pipeline data from catch lock too,after exit step is executed?


    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: How does finally block work in case of errors

    Posted 05/28/15 11:34 AM

    Of-course as per my design logout should be in try and catch if you do not want to use finally.

    I hope you do not have any clear pipeline in the catch? Can you confirm. Let me try.


    #webMethods
    #Integration-Server-and-ESB


  • 5.  RE: How does finally block work in case of errors

    Posted 05/28/15 11:39 AM

    No, I do not have a clear pipeline in Catch block. The exit step is clearing the pipeline.

    Please let me know if you need more information.


    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: How does finally block work in case of errors

    Posted 05/28/15 11:49 AM

    For me its as per the design if you specify exit from parent and signal failure, the pipeline data is cleared.

    Use exit from parent and signal success to have the pipeline content so that you can logout in finally block.

    Last option - use the design suggested by me, its just you are calling logout in try and catch. I have used in my project and it works like a charm.

    Any questions?


    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: How does finally block work in case of errors

    Posted 05/28/15 11:49 AM

    For me its as per the design if you specify exit from parent and signal failure, the pipeline data is cleared.

    Use exit from parent and signal success to have the pipeline content so that you can logout in finally block.

    Last option - use the design suggested by me, its just you are calling logout in try and catch. I have used in my project and it works like a charm.

    Any questions?


    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: How does finally block work in case of errors

    Posted 05/28/15 11:55 AM

    If i exit and signal it as success, i will not be able to monitor in MWS for failures, so i will use the logout step in both try and catch.

    Thank you for the help :slight_smile:


    #Integration-Server-and-ESB
    #webMethods


  • 9.  RE: How does finally block work in case of errors

    Posted 05/28/15 11:59 AM

    Yes, I know :slight_smile:

    But for now deal with it, lets see if someone suggests a better solution for your problem.


    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: How does finally block work in case of errors

    Posted 05/28/15 02:06 PM

    Is there any other work in the service after the main/finally sequences?

    If not, it might be an option to exit from flow and signal failure.
    This will cause the flow to exiting immediately.

    exit from parent will only exit the main sequence and if there is an getLastError in the Implementation the failure message might be lost for monitoring if it is not handled properly.

    I agree with Mahesh about the locations where to put the logout service calls.

    Additionally, if your login is inside the try block the session key will not be available in the finally block.

    Regards,
    Holger


    #Integration-Server-and-ESB
    #webMethods