Skip to content

DiKode

Coding Journal

Menu
  • Home
  • Author
  • Contact Me
  • Category
    • Java
    • Javascript
  • Privacy Policy
Menu

jPOS Server in-out

Posted on April 10, 2018October 12, 2020 by didikhari

In this post i will share about jPOS Server in-out, have you experienced a case where you as a server need to initiate request? it could be network management message. This post is related topic with my previous post about jPOS Client Receive Request From Remote Server

We are lucky, jPOS can handle this case. all we need to do is to set <in> and <out> inside server configuration. If you look at org.jpos.q2.iso.QServer you will find initIn() and initOut() methods thats actually read <in> and <out> tags.

Ok, lets start the implementation.

First, we need to create server configuration that have <in> and <out> tag inside.

lets name it 10_server.xml

[xml highlight=”15-16″]

8888
300
10

 

 

NETWORK_IN
NETWORK_OUT

[/xml]

Ok, you can see in line 15 and 16 above, that we have <in> and <out> tags configuration. SO? so what if we have it? is it really matter? YES! because we can use it to config a mux, we know that we use a mux to send a message and whenever we need the mux, we can use NameRegistrar to get the mux’s object.

Ok, lets continue to the next configuration.

We will create mux configuration that connected to above server through <in> and <out> tags.

Lets name it 11_server_mux.xml

[xml highlight=”3-4″]


NETWORK_OUT
NETWORK_IN
unhandled

[/xml]

with above configuration, our server now has ability to send a request message using port 8888. And as i said before, we can get the mux object using NameRegistrar [java]NameRegistrar.get(“mux.my-server-mux”);[/java]. Please note the value on hilighted line (3 and 4) is reverse from server (line 15-16) <in> and <out> tags.

And bellow class is [java]id.web.didikhari.MyRequestListener[/java] we need this class listener to get the request message from client.

package id.web.didikhari;

import java.io.IOException;

import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISORequestListener;
import org.jpos.iso.ISOSource;

/**
* This is sample request listener that always response success DE#39 = "00"
* You can use Transaction Manager in real application.
* @author didik
*/
public class MyRequestListener implements ISORequestListener {

public boolean process(ISOSource source, ISOMsg reqMsg) {
try {
ISOMsg respMsg = (ISOMsg) reqMsg.clone();
respMsg.setResponseMTI();
respMsg.set(39, "00");
source.send(respMsg);
} catch (ISOException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}

}

 

That’s all we need to create jPOS Server in-out case. Hope it can help.

i have uploaded code for this post on bitbucket, you can get it here

jPOS Server in-out

9 thoughts on “jPOS Server in-out”

  1. suwardi says:
    April 17, 2018 at 12:22 pm

    Dik,

    Ada source lengkapnya tidak untuk postingan ini?

    Reply
    1. didikhari says:
      April 23, 2018 at 4:01 am

      Ada bang, tapi belum sempet di upload.. nanti di share link nya kalau udah di upload.. hehe

      Reply
    2. didikhari says:
      April 23, 2018 at 2:16 pm

      Sudah di upload bang wardi, link ada di post nya ya. 😀

      Reply
  2. suwardi says:
    May 2, 2018 at 4:09 pm

    Mantap bro

    Reply
  3. julius says:
    June 4, 2018 at 9:18 am

    hallo,

    Thank you for sharing this.

    How does someone track timeout incase of no response from client.

    thank you

    Reply
    1. didikhari says:
      June 24, 2018 at 11:38 pm

      Hi,if youre using mux.request() if its return null, its means timeout.

      Reply
  4. Shihab Alkaff says:
    August 20, 2018 at 2:48 am

    halo bang…
    makin jago aja nih bang 😀
    mau dong dibagi ilmu jpos nya…

    kalau belum pake Q2 dan masi pake ISOMUX behavior nya agak aneh mas,
    kalo di liat2 and di check kaya nya channel.receive dari ISOServer bentrok sama channel.receive dari ISOMUX, jadi nya Response nya Intermittent, kadang jadi Response buat MUX, kadang jadi Request buat Server danmasuk ke RequestListener…
    ada yang bisa di lkukan untuk nangani ini? sselain pindah ke Q2

    Reply
    1. didikhari says:
      August 20, 2018 at 3:07 am

      Hallo hab. Gmn kabar?

      Ak jarang pakai isomux, jadi kurang tah behavior isomux nya.

      Cuman kalau dari issue nya, mungkin bisa dibedain object channel nya, antara isoserver dan isomux. Setting timeout di mux nya jgn terlalu kecil jg hab, sama pastiin kalau key message nya sudah sesuai stan+terminalid dan mti & response mti nya match.

      Reply
      1. Shihab Alkaff says:
        August 20, 2018 at 8:57 am

        baik alhamdulillah,mas didik gimana?
        alhamdulillah ya masi inget 😛

        nah itu dia mas…walaupun channel nya memang beda…tapi kan yang di lakukan channel.receive sama…
        ketika channel.receive di isomux jalan, yauda message TCP nya uda keburu di ambil di isomux
        ketika channel.receive di ISOServer jalan, yauda message dari TCP nya uda di ambil ISOServer jadi kalo kita kirim request pake ISOMUX dari server, response nya malah kadang masuk ke Class Listener yang kita set di ISOSERVER sedangkan mux.request nya malah timeout…

        kalau untuk key management aku uda yakin match karena aku taro beberapa cekpoin jg sebelum get by key… hehe,
        timeout jg sudah 30 detik, dan secara tcp dump pun memang si client sudah mengirim tcp message

        kaya nya ini dulu pernah mas didik alamin pas nanya di user jpos group hhee…
        di thread ini :
        https://groups.google.com/forum/#!topic/jpos-users/YuWsr8HiKMM

        kadang dia sukses, kadang dia timeout, jadi pas timeout ini kaya nya tcp message nya di rebut requestlistener nya isoserver

        nah kaya nya itu solved nya setelah ganti ke Q2 ya om? atau gimana om?
        emng si ISOMUX uda depricated, haha…..uda waktu nya di ganti 😛

        Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Java
  • Javascript
  • jPOS

Recent Post

  • jPOS Server in-out
  • How to Configure Basic Auth Spring RestTemplate
  • Create Custom jPOS ISO8583 Packager
  • Binding Restful XML Parameter
  • Create Dynamic Tree Grid using TreeGrid jQuery Plugin

Tags

Asynchronous Request async request Bind Json Param custom channel custom jPOS packager datatables Design Pattern hibernate http http basic auth http request iso 8583 java javascript jPOS jpos channel jPOS Client jPOS database jPOS deploy directory jPOS Hibernate jpos http jpos rest jPOS Server jpos Space jquery js jsf load balancer moxy mux mux pool prettyfaces primefaces rest client Restful SAF space Specifications spring framework TCP Template Method transaction manager transaction participant tree TreeGrid

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2021 DiKode | Built using WordPress and Responsive Blogily theme by Superb