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

BRANCH step with Regex modification

  • 1.  BRANCH step with Regex modification

    Posted 04/09/26 11:37 AM
    Edited by Kailash Kumar Mishra 04/09/26 11:45 AM

    Hi All,

    webMethods On-Premise 10.15

    There is an existing flow service in which there is a BRANCH step designed as

              Note : A, B, C are symbolic. It will actually be a value like INDC0001A and so on

    Now we need to add more values to this Regex and the Label of the MAP step has become quite lengthy.

    Tried putting the Regex in a Variable (say named Values) in different ways but the BRANCH does not work correctly.

    Kindly suggest if the BRANCH can be designed differently

    Tried options which hasn't worked 

    messageType=D

    Values = /A|B|C|D|E|F|G|H|I|J|K|L|M|N/

    BRANCH on /messageType  (Evaluate Label =False)

                               %Values%:MAP

    Values = /A|B|C|D|E|F|G|H|I|J|K|L|M|N/

    BRANCH (Evaluate Label = True)

                      %messageType%=%Values% : MAP

    Values = A|B|C|D|E|F|G|H|I|J|K|L|M|N

    BRANCH (Evaluate Label = True)

                      %messageType%=/%Values%/ : MAP

     

    Thanks



    ------------------------------
    Kailash Kumar Mishra
    ------------------------------



  • 2.  RE: BRANCH step with Regex modification

    Posted 04/10/26 01:30 AM

    Of the data that you are testing what parts are static vs variable in nature. e.g. is IND static thus have something like /IND[A-Z|0-9].*/

    Alternatively offload the test to a java service that returns a boolean then branch on that



    ------------------------------
    Jerome Green
    ------------------------------



  • 3.  RE: BRANCH step with Regex modification

    Posted 04/10/26 01:59 AM

    Hi Jerome,

    Thanks for your response.

    Yes the data is like :   IND001A , IND211D, IND417B and so on.

    So Java Service is an option here.

    But my attempt to use Variable Substitution in BRANCH will not work out is what you suggest.

    Thanks, 



    ------------------------------
    Kailash Kumar Mishra
    ------------------------------



  • 4.  RE: BRANCH step with Regex modification

    Posted 04/10/26 02:29 AM

    So in terms of a test we are saying if the value starts with IND and has numbers and or uppercase characters then go to this branch else go to default branch.

    If this statement is true then the regex is shared, /IND[A-Z|0-9].*/ will match any of the values you shared. What other permutations would you have on the expression?

    But no, you cannot set the regex in a variable and try to substitute it in. Ideally best to avoid that as

    1. your code is more readable and supportable where you can see the expression directly
    2. should be more efficient than building a java service as you have one less invoke to perform



    ------------------------------
    Jerome Green
    ------------------------------



  • 5.  RE: BRANCH step with Regex modification

    Posted 04/10/26 07:12 AM

    Thanks @Jerome Green for your insights on this.

    Your suggestion of /IND[A-Z|0-9].*/ was great.

    But I see that the current code is like 

    BRANCH on /messageType

         /DU001A|DU211D|DU417B|DU611A|DU031C/   : MAP  ( Do some logic )

        /DU901A|DU731D|DU555B|DU312A|DU030C/   : MAP  ( Do some logic )

        $default : MAP ( do some logic)

    So say if I use the Regex /DU[A-Z|0-9].*/  then it will always match the first MAP under the BRANCH

    BRANCH on /messageType

         /DU[A-Z|0-9].*/   : MAP  ( Do some logic )

        /DU901A|DU731D|DU555B|DU312A|DU030C/   : MAP  ( Do some logic )

        $default : MAP ( do some logic)

    Thanks



    ------------------------------
    Kailash Kumar Mishra
    ------------------------------



  • 6.  RE: BRANCH step with Regex modification

    Posted 04/10/26 09:19 AM

    Thankyou for the additional context and now better see the dilemma.

    In this case I would consider one of the following options:

    1. Externalise the values you need to match, in a database or similar, code a lookup against this store, caching the result, where the result returns a common code for the related values
      1. Pros:
        1. You can update without a code change
      2. Cons:
        1. DB connection issues can interrupt processing so code to accommodate this
    2. Build your lookup using Reference Data service, which will create a CSV under the config folder.
      1. Pros:
        1. Negates need for external data store
      2. Cons:
        1. Involves a code change (i.e. a new release) as a result of updating the CSV file

    Lookup table with a cached flow could be as simple as:

    id,code

    DU901A,STEPB

    DU417B,STEPA

    Then your branches will be labelled STEPA and STEPB



    ------------------------------
    Jerome Green
    ------------------------------



  • 7.  RE: BRANCH step with Regex modification

    Posted 04/13/26 03:25 AM
    Edited by Zainul Abideen 04/13/26 04:28 AM

    Hi Kailash,

    If you want to exclude some specific conditions then put those as upper child steps and your regex in lower steps, then your upper child steps would execute first.
    secondly can you state your words more clearly what do you want to achieve. fortunately I may help with the branching operations.
    like that



    ------------------------------
    Zainul Abideen
    Senior Integration Developer
    Innovation Team
    Riyadh, KSA
    ------------------------------



  • 8.  RE: BRANCH step with Regex modification

    Posted 04/12/26 08:24 PM

    I had this exact challenge last week and couldn't find a flexible regex solution inside WM.

    I opted to load the list of valid values from a configuration file, then lookup the value in the string. eg:

    filterList = 'D123A,D456B,DetcC'    #loaded from config
    
    messageType = 'D456B'
    positionInFilter = pub.string:indexOf(%filterList%,%messagetype%)
    BRANCH:
          positionInFilter > -1

    if doing this, ensure 'messageType' was validated - you don't want to be searching for a blank string or comma.
    One option is to ensure your config list begins and ends with the delimter and wrap delimiters around the search string. Eg:

    messageType = 'D456B'
    filterList = '|D123A|D456B|DetcC|'
    positionInFilter = pub.string:indexOf(%filterList%, |%messagetype%| )

    And as Jerome suggested, creating a 'helper' service to do this and cacheing it's results can be beneficial if the frequency or processing cost of retrieving the configuration is high. 

    Cheers!



    ------------------------------
    Graham Anderson
    ------------------------------



  • 9.  RE: BRANCH step with Regex modification

    Posted 04/13/26 04:37 AM

    What you describe is conceptually a configuration management topic for business logic.

    This is important to keep in mind, because it has implications on the suitability of branch conditions. These are great for things like true/false.

    But in a scenario where the message type determines what business logic should be applied, it is not an ideal approach. I am not saying that you cannot do this. But it has implications on ease-of-maintenance, compliance checks, deployment, testing, and more.

    Ideally there are two stages. First, determine what action should be taken on a given message. Here the use of a configuration file is the appropriate approach. And second, take action via the `branch` step.

    This has already been touched upon, but I wanted to add the conceptual side. Because technically there are many possible ways, but some fit better than others.

    How exactly the configuration is managed, depends on your deployment and other aspects that have not been covered. In general a properties file and a small Java service can help here. I have a free tool for this, if you don't want to write something yourself.

    It is also possible to use a separate service (Flow or Java) and do a lookup there. But a config file is more explicit and makes auditing, updates, and other aspects a lot easier.

    I would advise against a database approach. It makes deployment, updates, and testing a lot more complicated.



    ------------------------------
    All the best,
    Christoph
    ------------------------------



  • 10.  RE: BRANCH step with Regex modification

    Posted 04/13/26 05:42 AM

    Thanks @Jerome Green and @Graham and @Christoph Jahn for the detailed information and options which I can implement.

    Both your inputs were really helpful. I will try the suggested methods.

    Thanks,



    ------------------------------
    Kailash Kumar Mishra
    ------------------------------



  • 11.  RE: BRANCH step with Regex modification

    Posted 04/15/26 11:30 AM

    Hi @Kailash Kumar Mishra,

    Rephrasing what @Jerome Green and @Christoph Jahn have said: you are facing a problem where you are using static code to deal with a dynamic business condition.

    In most cases, code should only handle deterministic operations, leaving business logic and decisions on other kinds of tools (decision models, aggregated queries, named/filter topics/queues, etc.).

    However, not knowing what architectural decisions were made in the environment you have to work with, and your particular constraints, it may well be that code branches are the optimal solution: sometimes we have to compromise on code maintainability in the interests of performance; but alert management that it carries a _recurring_ cost as each new business condition requires recoding.

    IF, and this is a big if, you were in greenfield project, you could have made incoming data to be classified before or as it entered your system, so that it could be routed directly into specific services (for instance, using handles with filters on queues or topics).

    Using configuration files with conditions, trades lookup time (of the property lists) against branching, for the sake of visibility and ease of editing, but it should be considered as programming too, as you now have another type of object to deploy. If processing time is a concern, you could event think of using a property file with the classification rules, compiled on startup time as something as simple as a hash, used by a classification service to tag the data which would then feed a more concise structure of branches.

    If you cannot do much more than recoding regex conditions, REMEMBER to have a _very large_ test set to be sure you are catching all possibilities AND that your change did not affect previous branching cases (a good advice, whatever your choices are).

    All the best,

    Gerardo.



    ------------------------------
    Gerardo Lisboa
    CEO
    INFO-CARE consulting
    Lisbon
    ------------------------------



  • 12.  RE: BRANCH step with Regex modification

    Posted 04/22/26 07:54 AM

    Thanks @Gerardo Lisboa for your sharing your insights on this. 

    It is really great that a lot if ideas have been shared and some really interesting points have come up throughout this discussion in terms of the problem in hand, its categorization and numerous ways in which we may approach each. Quite enlightening it has been this conversation so far.



    ------------------------------
    Kailash Kumar Mishra
    ------------------------------



  • 13.  RE: BRANCH step with Regex modification

    Posted 04/22/26 03:02 PM

    I'm glad I was able to help you.

    Best regards,



    ------------------------------
    Gerardo Lisboa
    CEO
    INFO-CARE consulting
    Lisbon
    ------------------------------