Skip to content

DiKode

Coding Journal

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

jPOS Server Forward Message Simulator

Posted on March 21, 2015October 26, 2017 by didikhari

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.
[xml]

12201
100
10



[/xml]

And the Listener class is:

[java]
package com.didikhari.controller;

import java.io.IOException;

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

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

@Override
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”);
respMsg.setResponseMTI();
requester.send(respMsg);
} catch (ISOException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}

}

[/java]

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:
[xml]

client-send
client-receive
10000

[/xml]

and the 40_client_mux.xml is:
[xml]

client-receive
client-send

[/xml]
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.
[java]
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();
q2.start();
System.out.println(“Starting Deployment”);
}

public static void main(String[] args) {
startQ2();
// give some delay before sent req, cz q2 deployment is async
ISOUtil.sleep(5000);

// 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) {
e.printStackTrace();
}
}

public static ISOMsg createReqMsg(){
ISOMsg reqMsg = new ISOMsg();
reqMsg.setHeader(“ISO011000017”.getBytes());
try {
reqMsg.setMTI(“0200”);
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) {
e.printStackTrace();
}
return reqMsg;
}
}
[/java]


DONE!!
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.
Download Source

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

16 thoughts on “jPOS Server Forward Message Simulator”

  1. phenom says:
    April 1, 2015 at 6:13 am

    ada baiknya tutorial dengan db juga gan…

    Reply
    1. Didik H says:
      April 2, 2015 at 4:12 am

      gan phenom, thanks gan sarannya.. lain kali buat post tentang kombinasi sama db gan.. mkasih ya udah mampir.. 😀

      Reply
  2. Mohamed Kassim says:
    December 18, 2016 at 3:31 pm

    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.

    Reply
    1. Didik H says:
      December 19, 2016 at 2:42 pm

      Thanks for your feed back Mohamed, yes we can use any packager as long as the server and client using same specs.

      Reply
  3. Darma says:
    March 16, 2017 at 4:22 am

    Good jobs gan… really appreciate.

    Reply
  4. Taha Yassine says:
    March 27, 2017 at 1:54 pm

    Hi, I have tried to implements the same things but no result

    Reply
    1. Didik H says:
      April 13, 2017 at 1:05 am

      Hallo, what is the error Taha?

      Reply
  5. Thomas says:
    April 7, 2017 at 9:14 am

    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.

    Reply
    1. Didik H says:
      April 13, 2017 at 1:04 am

      im using 1.9.x jpos version, what is the error?

      Reply
  6. Rofi says:
    October 26, 2017 at 7:19 am

    Mas, saya ko koneksinya gagal terus ya?

    Reply
    1. didikhari says:
      October 26, 2017 at 8:07 am

      gagal error nya apa mas?

      Reply
  7. NM ARUN BALAJI says:
    December 11, 2017 at 12:43 pm

    How to configure client server simulators in jPOS using maven dependency?

    Reply
  8. mt says:
    November 19, 2018 at 7:34 am

    hi . i get error
    Exception in thread “main” java.lang.NoClassDefFoundError: org/jdom/Content
    at Client.startQ2(Client.java:10)
    at Client.main(Client.java:16)
    Caused by: java.lang.ClassNotFoundException: org.jdom.Content
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    why ?

    Reply
  9. Emil says:
    November 22, 2018 at 2:42 am

    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.

    Reply
    1. didikhari says:
      November 26, 2018 at 12:59 pm

      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.

      Reply
  10. Deva says:
    July 28, 2020 at 4:30 am

    Thanks for the post Didik. Download link is not seen in the post. Please post the link to download.

    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