<commit_before>=== QRest

[frame="none",cols="20%,80%"]
|=================================================================
| *What*         | Lightweight REST server
| *When*         | Implemented during 2.2.5
| *Who*          | The jPOS Software team.
| *Where*        | Directory modules/qrest
| *Why*          | Used by local Q2 nodes as audit trail or to SAF its transactions
| *Status*       | Experimental
| *License*      | <<appendix_license,GNU Affero General Public License version 3>>
|=================================================================

.Maven Coordinates
[source,xml]
----
        <dependency>
            <groupId>org.jpos.ee</groupId>
            <artifactId>jposee-qrest</artifactId>
            <version>${jposee.version}</version>
        </dependency>
----

Traditionally, jPOS based REST applications use the Jetty module, Jersey, etc. as described
in the link:http://jpos.org/tutorials[jPOS Tutorials]. But we have situations where we just
need to provide a little `ok` response to say a `/health` endpoint on each Q2 running
(for monitoring purposes).

Configuring Jetty/Jersey and deploying a `war` seems like overkill for these use cases so
we've created a little **QRest** module that can be configured like this:

[source,xml]
----------------------------------------------------------------------------------------
<qrest class='org.jpos.qrest.RestServer' logger='Q2'>
    <property name='port' value='8081' />                                            <1>
    <property name='queue' value='TXNMGR' />                                         <2>
</qrest>
----------------------------------------------------------------------------------------
<1> Listening port
<2> Transaction manager queue name

Once the server receives an HTTP request, it creates a `org.jpos.transaction.Context`, places a reference to the http request
(under the Constant name `REQUEST` (defined in the `org.jpos.qrest.Constants` enum), and to the session in the `SESSION`
constant (so that a `SendResponse` participant can reply) and send it off to the TransactionManager for processing.

The TransactionManager is configured like this:


[source,xml]
----------------------------------------------------------------------------------------
<txnmgr class="org.jpos.transaction.TransactionManager" logger="Q2">
  <property name="queue" value="TXNMGR"/>
  <property name="sessions" value="2"/>
  <property name="max-sessions" value="128"/>
  <property name="debug" value="true"/>

  <participant class="org.jpos.rest.participant.Router">
    <route path="/jpos/myroute/{mypathparam}**" method="GET" name="mygroup1"/>
    <route path="/jpos/myroute/{mypathparam}**" method="POST" name="mygroup2"/>
    <route path="/jpos/fixedroute" method="POST" name="..."/>
    <route path="/q2**" method="GET" name="q2"/>                                    <1>
  </participant>
<commit_msg>removed extra parenthesis - ci skip<commit_after>=== QRest

[frame="none",cols="20%,80%"]
|=================================================================
| *What*         | Lightweight REST server
| *When*         | Implemented during 2.2.5
| *Who*          | The jPOS Software team.
| *Where*        | Directory modules/qrest
| *Why*          | Used by local Q2 nodes as audit trail or to SAF its transactions
| *Status*       | Experimental
| *License*      | <<appendix_license,GNU Affero General Public License version 3>>
|=================================================================

.Maven Coordinates
[source,xml]
----
        <dependency>
            <groupId>org.jpos.ee</groupId>
            <artifactId>jposee-qrest</artifactId>
            <version>${jposee.version}</version>
        </dependency>
----

Traditionally, jPOS based REST applications use the Jetty module, Jersey, etc. as described
in the link:http://jpos.org/tutorials[jPOS Tutorials]. But we have situations where we just
need to provide a little `ok` response to say a `/health` endpoint on each Q2 running
(for monitoring purposes).

Configuring Jetty/Jersey and deploying a `war` seems like overkill for these use cases so
we've created a little **QRest** module that can be configured like this:

[source,xml]
----------------------------------------------------------------------------------------
<qrest class='org.jpos.qrest.RestServer' logger='Q2'>
    <property name='port' value='8081' />                                            <1>
    <property name='queue' value='TXNMGR' />                                         <2>
</qrest>
----------------------------------------------------------------------------------------
<1> Listening port
<2> Transaction manager queue name

Once the server receives an HTTP request, it creates a `org.jpos.transaction.Context`, places a reference to the http request
(under the Constant name `REQUEST` defined in the `org.jpos.qrest.Constants` enum), and to the session in the `SESSION`
constant (so that a `SendResponse` participant can reply) and send it off to the TransactionManager for processing.

The TransactionManager is configured like this:


[source,xml]
----------------------------------------------------------------------------------------
<txnmgr class="org.jpos.transaction.TransactionManager" logger="Q2">
  <property name="queue" value="TXNMGR"/>
  <property name="sessions" value="2"/>
  <property name="max-sessions" value="128"/>
  <property name="debug" value="true"/>

  <participant class="org.jpos.rest.participant.Router">
    <route path="/jpos/myroute/{mypathparam}**" method="GET" name="mygroup1"/>
    <route path="/jpos/myroute/{mypathparam}**" method="POST" name="mygroup2"/>
    <route path="/jpos/fixedroute" method="POST" name="..."/>
    <route path="/q2**" method="GET" name="q2"/>                                    <1>
  </participant>

{'fraction_non_alphanumeric': 0.24952610718593832, 'fraction_numerical': 0.009994830260210237, 'mean_word_length': 2.3529751588677064, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1864226', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1458, 'n_words': 474}