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

How to write recursive function in flow service

  • 1.  How to write recursive function in flow service

    Posted Fri November 11, 2005 02:50 AM

    Hi, all
    I was trying to find the factorial of a given number using recursion in flow but couldn’t figure it out.
    Can anyone be so kind to tell me how to write recursive functions in developer, any help would be appreciated…


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 2.  RE: How to write recursive function in flow service

    Posted Fri November 11, 2005 04:03 PM

    Hello,

    Yemi Bedu


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 3.  RE: How to write recursive function in flow service

    Posted Sat November 12, 2005 04:57 AM

    Thanks ybedu,
    Your reply is very helpful. I’ve got it.
    Have a nice day too.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: How to write recursive function in flow service

    Posted Wed November 16, 2005 11:27 AM

    I use a document for the recursive invoke and set the scope of the invoke step. Just be careful to clean up the scope document and you’ll be right.

    e.g.
    MAP (setup the document for invoke and map the inputs in)
    INVOKE (same service, with scope set to the document)
    MAP (get the result and cleanup the scope doc)

    Just make sure your service is only returning what it should based on the input/output signature (but that’s standard practice)

    regards,
    Nath


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 5.  RE: How to write recursive function in flow service

    Posted Thu August 27, 2015 08:26 AM

    What is scope??? Can you explain how to use this property with some examples Tq :roll:


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 6.  RE: How to write recursive function in flow service

    Posted Thu August 27, 2015 09:56 AM

    Hi

    Below is my flow service for recursion in developer. Kindly correct the mistakes,

                  1. Map number and temp 
    2. Branch on number
    2.1. Sequence if number>1
    2.1.1 map subtract number by 1
    2.1.2. call the same flow service
    2.1.3. multiply temp with number
    2.2. sequence for default
    2.2.1. Exit from the flow
    

    When I run i ask input for each call and it doesn’t perform multiply operation at the end. Correct my error

    Thank You


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 7.  RE: How to write recursive function in flow service

    Posted Thu August 27, 2015 10:31 AM

    Share the algorithm of your flow service.

    What is your business use case?

    Back to college - try factorial of a number using recursion function.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: How to write recursive function in flow service

    Posted Thu August 27, 2015 10:41 AM

    Hi,

    what about using repeat step:

    1. Map number to temp
    2. map subtract number by 1
    3. Repeat (count = number)
      3.1. Sequence if number>1
      3.1.1. multiply temp with number
      3.1.2. map subtract number by 1
      3.2. Sequence for default (number=1)
      3.2.1. do nothing

    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 9.  RE: How to write recursive function in flow service

    Posted Thu August 27, 2015 03:37 PM

    The above code does not look like a recursion flow service call.

    Have a look at the below screen shots: Just have a close look at the step level comments. Let me know if you have any questions


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 10.  RE: How to write recursive function in flow service

    Posted Thu August 27, 2015 03:38 PM

    The above pseudo code will not work as expected. Have a look at the screen shot above.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 11.  RE: How to write recursive function in flow service

    Posted Fri August 28, 2015 03:49 AM

    Yes Thank you M@he$h :lol: . It’s really helpful.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 12.  RE: How to write recursive function in flow service

    Posted Fri August 28, 2015 12:28 PM

    I know that my suggestion did not contain a recursive call.

    I wanted to show the iterative alternative as recursion is not really a good idea in webMethods.

    Depending on the depth of the recursion and the complexity of structures used as input recursion can lead to severe performance issues (i.e. OutOfThreads, OutOfMemory and/or StackOverflow).

    Regards,
    Holger


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 13.  RE: How to write recursive function in flow service

    Posted Fri August 28, 2015 12:52 PM

    Ok I see a valid point. Thanks for the detailed notes.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 14.  RE: How to write recursive function in flow service

    Posted Mon August 31, 2015 07:03 AM

    Does the loop has limit in webemthod flow language :?:


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 15.  RE: How to write recursive function in flow service

    Posted Mon August 31, 2015 09:25 AM

    What do you mean? Can you be more clear?


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 16.  RE: How to write recursive function in flow service

    Posted Tue September 01, 2015 11:16 AM

    I have list of document, I want to loop over the list to process. Is there any limit for that list in flow language?


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 17.  RE: How to write recursive function in flow service

    Posted Tue September 01, 2015 11:25 AM

    Hello Preethi,

    There is no limit for loop over the list of document.

    The loop flow step is depending on input array property.

    Thanks,
    Prem


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 18.  RE: How to write recursive function in flow service

    Posted Tue September 01, 2015 06:12 PM

    But please keep in mind as many as loops (documentList or recurssive) it could degrade the performance unless your logic for loops handling is done properly (dropping temp doclists and vars etc…)

    HTH,
    RMG


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 19.  RE: How to write recursive function in flow service

    Posted Wed September 02, 2015 07:27 PM

    You can use loop to iterate over a document list, string list. While looping over large documents make sure to take care of performance. You may also right a java code.

    Can you share more details and what is your business use-case.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods