jPOS Server in-out

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″]






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″]



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(“”);[/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 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.set(39, "00");
} catch (ISOException e) {
} catch (IOException e) {
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 responses to “jPOS Server in-out”

  1. suwardi Avatar


    Ada source lengkapnya tidak untuk postingan ini?

    1. didikhari Avatar

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

    2. didikhari Avatar

      Sudah di upload bang wardi, link ada di post nya ya. šŸ˜€

  2. suwardi Avatar

    Mantap bro

  3. julius Avatar


    Thank you for sharing this.

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

    thank you

    1. didikhari Avatar

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

  4. Shihab Alkaff Avatar

    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

    1. didikhari Avatar

      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.

      1. Shihab Alkaff Avatar

        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 :!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 šŸ˜›

Leave a Reply

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