Creating a fibonacci sequence Service Flow

Does anybody know how to create a service flow in software ag using fibonacci sequence

Hi Ronaldo,

can you describe in detail what you want to achieve exactly?

Most likely you will find some helpful services in the IS Built-In-Services Reference.

Regards,
Holger

Hi,
Refer the services development guide to understand the webMethods flow steps like MAP, INVOKE, REPEAT etc.,

Here is the java code and corresponding flow service.

3 Likes

hi,

can anyone tell what should i Enter in input and output section for printing fibonacci series

Hi Shalloo,

if necccessary you can set input field to maxNumber to specify how many iterations you want to calculate.

output will be the list of calculated numbers as shown in the screenshot above.

previousNumber is initialized to 0 and nextNumber is initialized to 1 in the first step of the flow.
“maxNumber - 1” is the value for repeatCount on the REPEAT-Step.

Regards,
Holger

1 Like

Hi, im trying to recreate this, but it appears i cant get the same result as yours. Can i get some help?

Why not just write a java service and copy paste an example from the web e.g. Java Program to Display Fibonacci Series

If you are not sure about creating java services, refer to this example I gave for checking for prime numbers.

regards,
John.

1 Like

Hi holger, i followed your instructions but it appears that I cant get the same result as I want, may i know how the pipeline is built?

I’m not sure of a “real” case need to create a fibonacci sequence, but perhaps the intent here is to learn how to program in FLOW. Certainly doable as @Mahesh_K_Sreenivas has shared.

Over the years there have been various threads in the forums about FLOW vs Java. When to which. Pros and cons. Often, people thinking a particular code solution is not doable in FLOW when in fact it is. There are 2 sets of (tongue-in-cheek) principles to consider when creating solutions in IS:

  1. Don’t write it in Java.
  2. Don’t write it in Java.
  3. Don’t write it in Java.

One might object to that, using “performance” as rationale – which leads to the other principles:

  1. Don’t optimize yet.
  2. Don’t optimize yet.
  3. Don’t optimize yet. (Profile first)

As noted, lots of FLOW vs. Java discussions on the forums for review. Many good items for consideration. The primary language of IS is FLOW, right?

Edit: Well, the primary language of IS as a platform is Java. But the primary language for developing solutions on IS is FLOW.

1 Like

yes, my intent here is to learn how to program in flow, as I learned it by myself and I can get a little confused by how it works and how to solve the problem if it occurs

You’ll want to share screen shots or descriptions of the specific help you’re seeking or is not working as expected.

1 Like

Sorry, I should have realised. However I wouldn’t pick a fibonacci function as an example in order to learn flow. It’s important to realise that flows has it’s strengths and weaknesses and is suitable for certain patterns and not others.

Flow is great for orchestrating and chaining tasks together, mapping and simple decision making are great in flow. Recursive, complex algorithms, Deep loops and low level data processing (bytes, arrays etc) are not.

So I would say use use flow for top-level service, mapping etc. but don’t be afraid to use java services for code where flow starts to get in the way rather than accelerate development.

As a caveat complex java services are a no no too. Write proper java classes, package as a jar and then use the java service as a simple entry point into your java library. Advantage is that it is easy to debug java classes, but not java service,
regards
John.

It’s okay John, anyway do you have a good example or resource to learn about flow service? I really want to learn, but it seems webMethods has a little resource for learning

This is my output, it kinda works, but didn’t append to toList, and I want to ask, how to set Count on Repeat? I’ve tried “maxNumbers - 1”, “%maxNumbers% - 1” but still doesn’t work

you can only use absolute number or pipeline variables in the count property. You need to do add a subtract step prior to the repeat step. This is a good example of where FLOW starts to fall down and personally I would implement this in java.

We have lots of online training course and a lot of them are free, have a look here

https://knowledge.softwareag.com/totara/catalog/index.php?cfp_multiselect_platformplatfor_8daf9[]=Integration%20%26%20API&catalog_learning_type_panel[]=course&orderbykey=featured&itemstyle=narrow

Here on tech forums you could try looking at this article

The above shows you a good example where a flow service adds value to manage a business integration use case.
regards,
John.

3 Likes

The example from @Mahesh_K_Sreenivas is perfectly reasonable, IMO. The comparison is helpful for learning. Certainly other algorithms would be useful as examples too, but this one seems okay to me.

Reasonable advice.

It is often the case that the argument for using Java is “when things get complex.” with the view that “FLOW is for simple things.” I usually disagree, to at least some degree. You still have to analyze and design appropriate components.

When writing FLOW, one must apply structured programming principles. One concept that often gets overlooked is simple modularity (subroutines). FLOW developers too often throw everything into a single FLOW service. It’s like coding everything in main(). Not good. There can also be a tendency to not define inputs/outputs. Also a tendency for “pipeline litter” and an (ill-advised) desire to use clearPipeline. FLOW provides lots of opportunity to shoot yourself in the foot. :slight_smile:

My guidance, FWIW: use Java for small, focused utilities. IME, creating a library/JAR is a rare need (I can think of only 1 time where we did that; using 3rd-party libraries and hooking them into IS via Java services is also relatively rare but a bit more frequent).

Another tidbit for consideration: if you’re Java developer, resist the urge to “go with what is familiar” and really strive to learn/understand FLOW. Most of the criticisms about FLOW are from C/C++/C#/Java developers who expect/want FLOW to have all the same behaviors/features of these languages. It doesn’t but it has enough, along with the built-in services and adapters, to do significant, “integration-y” things. :slight_smile:

Hi Ghifari,

The instructions above were just additional explanations to Mahesh´s service outline how to initialize the variables.
These are for fibonacci series but not for detecting prime numbers.

Regards,
Holger

so if i insert maxNumber on the Count property, it will work?

Hi Holger, i also tried to make fibonacci series by looking at this forum, but my result is different with @Mahesh_K_Sreenivas , and I really didn’t know where did I make mistake.

I’ve just posted my screenshots here, I would be very glad if you spend a time and help me to fix the problem.

Clean-up your variables at appropriate intervals and see if that helps. Time and again, outdated values cause problems with loop/repeat, because you’re not “resetting” them before the next iteration.

KM

2 Likes