jPOS Server Forward Message Simulator

Hi, Today i want to share my code about jPOS Server Forward Message Simulator. The simulator flow is described on my old post here: JPos Server Forward Request Message to Another Server. My old post is talk about the “front end” server that receive request from client and forward to “back end” server, so in this post we will talk about the client and backend server.

jPOS Server Forward Message Simulator
jPOS Server Forward Message Simulator

I have refactor my code from my old post, so maybe you’ll find different term.
We start with the backend server, or on my old post is Server B, first you need to create file named 11_server_B.xml containing this code.

<server class="org.jpos.q2.iso.QServer" logger="Q2" name="Server-B">
    <attr name="port" type="java.lang.Integer">12201</attr>
    <attr name="maxSessions" type="java.lang.Integer">100</attr>	
    <attr name="minSessions" type="java.lang.Integer">10</attr>

    <channel name="Server-B-Channel" class="" logger="Q2"

    <request-listener class="com.didikhari.controller.ServerBListener" logger="Q2">
        <property name="space" value="transient:default" />
        <property name="queue" value="TransactionQueue" />
        <property name="timeout" value="10000" />

And the Listener class is:

package com.didikhari.controller;


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

 * Server B Listener<br/>
 * Listener for Server A Request (Back end Server)
 * @author Didik Hari
public class ServerBListener implements ISORequestListener {

	public boolean process(ISOSource requester, ISOMsg reqMsg) {
		try {
			ISOMsg respMsg = (ISOMsg) reqMsg.clone();
			respMsg.set(124, "HI CLIENT, THIS IS DATA FROM ME! B");
			respMsg.set(39, "00");
		} catch (ISOException e) {
		} catch (IOException e) {
		return false;


The ServerBListener is used for receive request from server A, and send response back.

Thats it the backend server, you can find about configuration front end server on my old post JPos Server Forward Request Message to Another Server

And the last thing we need to do is create a requester class, or called “Client”. For client implementation, we need to create two file configuration named 30_client_channel.xml and 40_client_mux.xml.
First, create 30_client_channel.xml file and give this code:

<channel-adaptor name='client-adaptor' class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
	<channel class="" header="000000000000000000000000"
		packager="com.didikhari.packager.MyPackager" logger="Q2">

		<!-- Server A Address -->
		<property name="host" value="" />
		<property name="port" value="15500" />

and the 40_client_mux.xml is:

<mux class="org.jpos.q2.iso.QMUX" logger="Q2" name="client-mux">

Client channel adaptor will send request message to Server A adress and wait response on it.

But How to start the jPOS Server Forward Message Simulator?? we need to create a class that will call Q2.start method, so the jPOS Library will deploy the configuration we have made.
package com.didikhari.requester;

import java.util.Date;

import org.jpos.iso.ISODate;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOUtil;
import org.jpos.iso.MUX;
import org.jpos.q2.Q2;
import org.jpos.util.NameRegistrar;

 * Requester
 * @author Didik Hari
public class Client {
	public static void startQ2(){
		Q2 q2 = new Q2();
		System.out.println("Starting Deployment");
	public static void main(String[] args) {
		// give some delay before sent req, cz q2 deployment is async
		// Process send and receive data
		try {
			MUX mux = (MUX) NameRegistrar.getIfExists("mux.client-mux");
			ISOMsg reply = mux.request(createReqMsg(), 10 * 1000);
			System.out.println(new String(reply.pack()));
		} catch (ISOException e) {
	public static ISOMsg createReqMsg(){
		ISOMsg reqMsg = new ISOMsg();
		try {
			reqMsg.set(3, "530020");
			reqMsg.set(7, ISODate.getDateTime(new Date()));
			reqMsg.set(11, String.valueOf(System.currentTimeMillis() % 1000000));
			reqMsg.set(12, ISODate.getTime(new Date()));
			reqMsg.set(13, ISODate.getDate(new Date()));
			reqMsg.set(14, "1502");
			reqMsg.set(17, ISODate.getDate(new Date()));
			reqMsg.set(18, "6011");
			reqMsg.set(35, "6011343456sdgfd");
			reqMsg.set(37, "123456789012");
			reqMsg.set(41, "1234567890123456");
			reqMsg.set(124, "GIVE ME DATA FROM SERVER B");
		} catch (ISOException e) {
		return reqMsg;

it’s all the jPOS Server Forward Message Simulator.
You can download my eclipse jPOS Server Forward Message Simulator project by click this link bellow:

Please disable popup blocker for view the link, after you click the link below it will open new tab for downloading the files.

Hope this post can help somebody, thanks for comming in my blog.


  1. Hi Didik H;
    Thank you for the post. I have been trying to run this it is failing getting can’t load com.mandiri.soa.ubp.UBPPackager. I was trying to look where i can modify and my my own packager because i don’t find yours, i can’t get the location for that. The post look very helpful for once i managed to run it.

  2. Good day Didik,
    I am not sure if I am doing this right. I downloaded your files to test. Remapped the JAR files to the ones I have for jPos but I cannot compile and run your client nor the servers.
    Am I missing a step somewhere?
    I have jPos-2.0.4.

  3. hi . i get error
    Exception in thread “main” java.lang.NoClassDefFoundError: org/jdom/Content
    at Client.startQ2(
    at Client.main(
    Caused by: java.lang.ClassNotFoundException: org.jdom.Content
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    why ?

  4. Konsep ISO saya sudah paham nih mas, cuma konsep pengembangan JPos masih buta. Harus belajar dari mana dulu untuk nguasain JPos. kalo ada link tutorial yang bisa dipelajari mohon dishare mas.

    1. Hallo mas, kalau saya dulu coba pelajari dari programmer guide nya mas, ada bahan pembelajaran dikasih di kantor. lumayan bisa lebih paham konsep dasarnya, dan cara custom channel, packager dan QBean. selebihnya coba untuk pelajari code nya, mulai dai class Q2, sampai ke configurable class yang lain seperti QMUX, QServer, Space, NameRegistrar, dll.

Leave a Reply

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