jPOS icon indicating copy to clipboard operation
jPOS copied to clipboard

Add regular expression support to Switch participant

Open alcarraz opened this issue 5 years ago • 2 comments

Switch participant is described in jPOS programmer's guide section 9.8.1.

Motivation

Switch participant is a highly performant groups selector, but it lacks the ability of handling multiple different but similar entries (e.g. with a common prefix) that should route to the same groups.

I'm writing this issue to have feedback about the best way of implementing this.

I see two options at a first glance:

  1. Use some prefix to distinguish between regex properties than common ones, like:
<property name="re:100\.30(\.[0-9]{4})?" value="xxx prepareresponse logit close sendresponse"/>
  1. Make Switch implement XMLConfigurable and have something similar to what is done in SelectDestination but just for regexes. e.g.:
<participant class="org.jpos.transaction.participant.Switch"
  logger="Q2" realm="Switch">
  <property name="100.30"
  value="balanceinquiry prepareresponse logit close sendresponse" />
  <regex groups="xxx prepareresponse logit close sendresponse">100\.30\.[0-9]{4}</regex> <!--e.g.: for generic reason code handling-->

In both cases direct properties would have precedence over regex ones, to maintain the efficiency of look up table, if the name is not present as property then we would look iterate over regex in order of definition.

So it behaves efficiently for common transactions but you have the option of leave open cases where there are too many (and infrequent) combinations to list them all one by one, in particular for combinations of function code x reason code.

I'm highly inclined to option 2 but would like better ideas for the syntax.

alcarraz avatar May 25 '20 17:05 alcarraz

I like the latter, but the former is so easy that perhaps it's the way to go. Now the question, just re: as a prefix or regexp: ?

ar avatar May 25 '20 18:05 ar

Can we settle in regex: after java.util.regex package?

I'll take this issue if you agree.

alcarraz avatar May 25 '20 18:05 alcarraz