[jpos-users] ISO Server using Q2

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jpos-users] ISO Server using Q2

Meldri Asan
Hi everyone,

i've create 2 java project using JPos library (Client & Server). I want execute server and client at different place but it must connected each other. This Project was developed using jpos-gateaway tutorial. This project already run smoothly, client send message and get response. But i think something going wrong. Client side is using Q2,but at server side i think Q2 didnt work properly.

this is Client structure code
ClientISOQ2
- src
- com
- client
- iso
- ClientIso.java
- Deploy
- 00_logger.xml
- 10_channel_jpos.xml
- 20_mux.xml
- 99_sysmon.xml
- Log
- iso8583.xml


Server Structure Code
ServerISOQ2
- src
- com
- server
- iso
- ServerIso.java
- Deploy
- 00_logger.xml
- 50_server.xml
- 99_sysmon.xml
- Log
- iso8583.xml

10_channel_jpos.xml
<channel-adaptor name='jpos-channel' class="org.jpos.q2.iso.ChannelAdaptor"
logger="Q2">
<channel name="ServerA-Channel" class="org.jpos.iso.channel.NACChannel" logger="Q2" realm="ServerA-Channel" packager="org.jpos.iso.packager.ISO87APackager">
    <property name="host" value="localhost" />
<property name="port" value="8000" />
        </channel>
<in>jpos-send</in>
<out>jpos-receive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>


20_mux.xml
<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="mymux">
   <in>jpos-receive</in>
   <out>jpos-send</out>
   <ready>ServerA-Channel.ready</ready>
</mux>

50_server.xml
<server class="org.jpos.q2.iso.QServer" logger="Q2"
name="xml-server-8000" realm="xml-server-8000">
<attr name="port" type="java.lang.Integer">8000</attr>
<channel class="org.jpos.iso.channel.XMLChannel"
packager="org.jpos.iso.packager.XMLPackager"
type="server"
logger="Q2"
realm="xml-server-8000">
<property name="timeout" value="180000"/>
</channel>
<request-listener class="com.server.iso.ServerIso" logger="Q2">
</request-listener>
</server>

ClientIso.java
public class ClientIso {
    public static void main(String[] args) throws InterruptedException {
    Q2 q2 = new Q2();
        q2.start();
        
        Thread.sleep(5000);
        try {
            QMUX qmux = (QMUX) NameRegistrar.getIfExists("mux.mymux");
            
            try {          
            ISOMsg reply = qmux.request(createReqMsg(), 1000);
            System.out.println(new String(reply.pack()));
} catch (Exception e) {
e.printStackTrace();
System.out.println("Gagal Koneksi");
}

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
   
public static ISOMsg createReqMsg(){
    ISOMsg reqMsg = new ISOMsg();
        //reqMsg.setHeader("ISO011000017".getBytes());
        try {
            reqMsg.setMTI("0800");
            reqMsg.set(11, String.valueOf(System.currentTimeMillis() % 1000000));
            reqMsg.set(41, "12345678");
            reqMsg.set(70, "301");

        } catch (ISOException e) {
            e.printStackTrace();
        }
        return reqMsg;
    }
}


ServerIso.java
public class ServerIso implements ISORequestListener{
public static void main(String[] args) throws IOException, ISOException {
Logger logger = new Logger ();
ISOPackager packager = new GenericPackager("iso8583.xml");
logger.addListener (new SimpleLogListener (System.out));
NACChannel channel = new NACChannel("localhost",8000, packager,null);
((LogSource)channel).setLogger (logger, "channel");
ISOServer server = new ISOServer (8000, channel, null);
server.setLogger (logger, "server");
server.addISORequestListener(new ServerIso());
new Thread (server).start ();
}
@Override
public boolean process(ISOSource source, ISOMsg m) {
try {
System.out.println("server get data");
m.setResponseMTI ();
m.set (39, "00");
source.send (m);
} catch (ISOException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
  }
  return true;
}

}


Log at Client Side
<log realm="Q2.system" at="2017-05-17T13:31:17.504">
  <info>
    Q2 started, deployDir=C:\Users\Acer\workspace\ClientISOQ2\deploy
  </info>
</log>
<log realm="Q2.system" at="2017-05-17T13:31:18.989" lifespan="1448ms">
  <version>
    jPOS 2.1.0-SNAPSHOT master/07c4c14 (2017-05-14 01:19:30 UTC) 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jPOS Community Edition, licensed under GNU AGPL v3.0.
This software is probably not suitable for commercial use.
Please see http://jpos.org/license for details.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iQEcBAEBAgAGBQJMolHDAAoJEOQyeO71nYtFv74H/3OgehDGEy1VXp2U3/GcAobg
HH2eZjPUz53r38ARPiU3pzm9LwDa3WZgJJaa/b9VrJwKvbPwe9+0kY3gScDE1skT
ladHt+KHHmGQArEutkzHlpZa73RbroFEIa1qmN6MaDEHGoxZqDh0Sv2cpvOaVYGO
St8ZaddLBPC17bSjAPWo9sWbvL7FgPFOHhnPmbeux8SLtnfWxXWsgo5hLBanKmO1
1z+I/w/6DL6ZYZU6bAJUk+eyVVImJqw0x3IEElI07Nh9MC6BA4iJ77ejobj8HI2r
q9ulRPEqH9NR79619lNKVUkE206dVlXo7xHmJS1QZy5v/GT66xBxyDVfTduPFXk=
=oP+v
-----END PGP SIGNATURE-----

  </version>
</log>
<log realm="Q2.system" at="2017-05-17T13:31:19.029" lifespan="22ms">
  <info>
    deploy: C:\Users\Acer\workspace\ClientISOQ2\Deploy\10_channel_jpos.xml
  </info>
</log>
<log realm="Q2.system" at="2017-05-17T13:31:19.077" lifespan="46ms">
  <info>
    deploy: C:\Users\Acer\workspace\ClientISOQ2\Deploy\20_mux.xml
  </info>
</log>
<log realm="Q2.system" at="2017-05-17T13:31:19.096" lifespan="17ms">
  <info>
    deploy: C:\Users\Acer\workspace\ClientISOQ2\Deploy\99_sysmon.xml
  </info>
</log>
<log realm="org.jpos.q2.qbean.SystemMonitor" at="2017-05-17T13:31:19.182">
  <info>
    Starting SystemMonitor
  </info>
</log>
<log realm="org.jpos.q2.qbean.SystemMonitor" at="2017-05-17T13:31:19.186">
  <info>
               OS: Windows 7 (6.1)
     process name: 5416@temp33rd-meldri
             host: temp33rd-meldri/192.168.43.215
              cwd: C:\Users\Acer\workspace\ClientISOQ2
       free space: 30.6 GiB
          version: 2.1.0-SNAPSHOT (07c4c14)
         instance: bd199893-058f-432b-ab34-e67fae5045a1
           uptime: 00:00:03.255 (-1.000000)
       processors: 2
           drift : 0
    memory(t/u/f): 15/10/5
         encoding: windows-1252
         timezone: Asia/Bangkok (Indochina Time) +07:00
    watch service: sun.nio.fs.WindowsWatchService
            clock: 1495002679 2017-05-17T06:31:19.208Z
     thread count: 12
     peak threads: 12
     user threads: 8
            Thread[Reference Handler,10,system]
            Thread[Finalizer,8,system]
            Thread[Signal Dispatcher,9,system]
            Thread[Attach Listener,5,system]
            Thread[main,5,main]
            Thread[pool-1-thread-1,5,main]
            Thread[Q2-bd199893-058f-432b-ab34-e67fae5045a1,5,main]
            Thread[Thread-1,5,main]
            Thread[Timer-0,5,main]
            Thread[channel-sender-jpos-send,5,main]
            Thread[channel-receiver-jpos-receive,5,main]
            Thread[SystemMonitor,5,main]
    name-registrar:
      tspace:default: org.jpos.space.TSpace
         key-count: 0
            gcinfo: 0,0
      Q2: org.jpos.q2.Q2
      jpos-channel: org.jpos.q2.iso.ChannelAdaptor
        tx=0, rx=0, connects=0, last=0
      channel.jpos-channel: org.jpos.iso.channel.NACChannel
      logger.Q2: org.jpos.util.Logger
      mux.mymux: org.jpos.q2.iso.QMUX
        tx=0, rx=0, tx_expired=0, tx_pending=0, rx_expired=0, rx_pending=0, rx_unhandled=0, rx_forwarded=0, connected=false, last=0
      logger.Q2.buffered: org.jpos.util.BufferedLogListener
  </info>
</log>
<log realm="ServerA-Channel/127.0.0.1:8000" at="2017-05-17T13:31:19.456" lifespan="275ms">
  <connect>
    Try 0 localhost:8000
  </connect>
</log>
<log realm="ServerA-Channel/127.0.0.1:8000" at="2017-05-17T13:31:21.907" lifespan="4ms">
  <send>
    <isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.ISO87APackager -->
      <field id="0" value="0800"/>
      <field id="11" value="681900"/>
      <field id="41" value="12345678"/>
      <field id="70" value="301"/>
    </isomsg>
  </send>
</log>
<log realm="ServerA-Channel/127.0.0.1:8000" at="2017-05-17T13:31:21.946" lifespan="2484ms">
  <receive>
    <isomsg direction="incoming">
      <!-- org.jpos.iso.packager.ISO87APackager -->
      <field id="0" value="0810"/>
      <field id="11" value="681900"/>
      <field id="39" value="00"/>
      <field id="41" value="12345678"/>
      <field id="70" value="301"/>
    </isomsg>
  </receive>
</log>
0810802000000280000004000000000000006819000012345678301

Log at Server Side
<log realm="server" at="2017-05-17T13:31:10.434">
  <iso-server>
    listening on port 8000
  </iso-server>
</log>
<log realm="server.session/127.0.0.1:4515" at="2017-05-17T13:31:19.240" lifespan="1ms">
  <session-start/>
</log>
<log realm="channel/127.0.0.1:4515" at="2017-05-17T13:31:21.938" lifespan="2698ms">
  <receive>
    <isomsg direction="incoming">
      <!-- org.jpos.iso.packager.GenericPackager[iso8583.xml] -->
      <field id="0" value="0800"/>
      <field id="11" value="681900"/>
      <field id="41" value="12345678"/>
      <field id="70" value="301"/>
    </isomsg>
  </receive>
</log>
server get data
<log realm="channel/127.0.0.1:4515" at="2017-05-17T13:31:21.945" lifespan="4ms">
  <send>
    <isomsg direction="outgoing">
      <!-- org.jpos.iso.packager.GenericPackager[iso8583.xml] -->
      <field id="0" value="0810"/>
      <field id="11" value="681900"/>
      <field id="39" value="00"/>
      <field id="41" value="12345678"/>
      <field id="70" value="301"/>
    </isomsg>
  </send>
</log>

Did i do something wrong? or it was best practice?
Thank you.

Regards,
Meldri

--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: [hidden email]
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/cf6150c4-1841-4b26-a1bb-a8a16d7dc8b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.