Search code examples
tibcotibco-business-works

Tibco JMS Queue Requestor" or "JMS Queue Sender" Dinamic JMS properties mapping


I am working with Tibco BW5.I have JMS selectors string that looks like this:

SelectorString = "Name='Value' AND Name='Value' AND Name='Value' AND ...." 

I need to use this string in "JMS Queue Requestor" or "JMS Queue Sender" as JMS selectors.

Solution:

For setting selectors to "JMS Queue Requestor" or "JMS Queue Sender" I am using "DynamicProperties" in "Input" tab:

dynamic selectors

For mapping SelectorString to "DynamicProperties" I created "Repeat-Until-True" group with MapData inside.

Repeat condition:

($i >= count(tib:tokenize($Start/root/SelectorString, "AND"))) 

Repeat

I map "name" to:

tib:trim(tib:tokenize(tib:tokenize($Start/root/SelectorString, "AND")[$i], "=")[1])

I map "value" to:

substring-before(substring-after(tib:tokenize(tib:tokenize($Start/root/SelectorString, "AND")[$i], "=")[2], "'"), "'")

Then I set accumulated output to "JMS Queue Requestor" dynamic properties.

Please see screenshot:

Please see attached screenshot

Is there more elegant way to do this ?


Solution

  • Looks like you have not much experience with set-based math ... a typical "sequential programmer's approach to sets":-(

    Assuming that the you have a non-hierarchical statement (containing ONLY "AND" between name value pairs) you can once translate " AND " into a single "special char" (like "¶"), use a for-each XML element with the tokenized string it by this char and then split and trim the name and values inside the for-each.

    Process with mapping

    ActivityInput:

    That's the set-based approach which btw is much faster than the iteration loop (4 simple lines of XPath code)