0

I am using jpos for creation and parsing of ISO8583 messages. Also am using threadpooling in my application to create n number of ISO8583 requests concurrently. I am using NACChannel for sending the request from client to the server. The server is configured to handle 30 different sessions each session having a queue size of 20. So from my client application am sending many ISO8583 requests concurrently but at the server side the same are being processed in a sequential manner on a single session. So my question is

1)How can i send the requests so that all the 30 sessions get utilised using jpos?

2)Is there any other approach to send this requests in different sessions to the server so that the server doesnt process the same sequentially in a single channel?

I am using the following to create the channel :

NACChannel channel = new NACChannel(host,portnumber,packager,"xxxxyyyyzzzz".getBytes());

I also have a q2 implementation of the same too. in the q2 implementation am able to handle request response asynchronously but that too is using a single session.Let me know if i need to share any more code for the same.

Ajay Ganvir
  • 367
  • 2
  • 7
  • 23

2 Answers2

1

Use a MUX (like QMUX).

The MUX will allow you to send multiple messages over the same channel and will properly match the responses.

Take a look at the Client Simulator in the jPOS-EE project (http://jpos.org/doc/jPOS-EE.pdf) as an example.

Make sure you read http://jpos.org/doc/proguide-draft.pdf

apr
  • 1,288
  • 7
  • 8
  • Yep i used a mux. It's allowing me to send multiple messages over the same channel. But all of it on a single session. Only one process id is getting created on the server end. Still proccessing the same asynchronously over a single session. Not on different sessions. – Ajay Ganvir Feb 25 '16 at 04:39
  • You can use multiple channels pulling messages from the same QMUX (in/out queues are the same). You can also use a MUXPool if you want a more deterministic way of distributing the load (i.e. round-robin). – apr Feb 26 '16 at 18:13
0

So if I am a client, I would configure as many channel deploy files as the number of connections you want to the server. Each channel will have a mux associated with it. Wrap all these muxes in a jpos muxpool deploy. This will act as a single huge mux that does round robin selection of the mux and hence the channel. Use the muxpool to send the request (its exactly the same as using the mux). This way all your connections get utilized and if any of your connections are not connected, the pool is smart enough to use the next available mux that is connected.

e.g. Say server is listening on port 9000 and allows 2 connections.

I would create 2 channel adapters as follows, both pointing to the host and port 9000. Do see how each has an in/out element.

<?xml version="1.0" ?>
<channel-adaptor name='HostConnection-1' 
    class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
 <channel class=" org.jpos.iso.channel.NACChannel" logger="Q2" realm="channel-1"
       packager="org.jpos.iso.packager.GenericPackager">       
  <property name="packager-config" value="cfg/host-packager.xml" />
  <property name="host" value='127.0.0.1' />
  <property name="port" value="9000" />
  <property name="timeout" value="1000000" />
  <property name="keep-alive" value="true" />  
</channel>
 <in>host1-send</in>
 <out>host-receive</out>
 <reconnect-delay>10000</reconnect-delay>

<channel-adaptor name='HostConnection-2' 
    class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
 <channel class=" org.jpos.iso.channel.NACChannel" logger="Q2" realm="channel-2"
       packager="org.jpos.iso.packager.GenericPackager">       
  <property name="packager-config" value="cfg/host-packager.xml" />
  <property name="host" value='127.0.0.1' />
  <property name="port" value="9000" />
  <property name="timeout" value="1000000" />
  <property name="keep-alive" value="true" />  
</channel>
 <in>host2-send</in>
 <out>host2-receive</out>
 <reconnect-delay>10000</reconnect-delay>
</channel-adaptor>

Now create 2 muxes. The muxes wire the channels in/out to its in/out

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="host-mux-1">
 <in>host1-receive</in>
 <out>host11-send</out>
 <ready>HostConnection-1.ready</ready> <!-- needs to be adaptor name + .ready-->
 <unhandled>host-unhandled</unhandled>

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="host-mux-2">
 <in>host2-receive</in>
 <out>host12-send</out>
 <ready>HostConnection-2.ready</ready> <!-- needs to be adaptor name + .ready-->
 <unhandled>host-unhandled</unhandled>
</mux>

Now create a muxpool deploy file.

<mux class="org.jpos.q2.iso.MUXPool" logger="Q2" name="host-mux">
 <muxes>host-mux-1 host-mux-1</muxes>
 <strategy>round-robin</strategy>
</mux>

Get the muxpool by name from the jpos' nameregistrar instance and fire the request. It uses the muxes configured in pool to fire requests in a round robin way.

When its a small number of connection, this works well, as the number grows, you may want to programatically consider creating these channels and muxes.

chhil
  • 442
  • 4
  • 12