Gemuruh Pratama

Read this first

Learn JPOS Part 4 throw rest service to Host

This part actually my experiment to throw rest message to host we will using spring boot as RestFul service and using those service to throw ISOMsg as JSON data upon the request on web.

If you read the previous tutorial (Part 3) the code almost same instead we add new QBean to run webservice when Q2 start.

QBean XML for webservice

<qrest class="com.gl.qbean.QRestService">

</qrest>

QBean class

Actually the Qbean class contain spring boot run method.

import org.jpos.q2.QBeanSupport;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

/**
 * Created by ggpratama on 10/9/2015.
 */
@SpringBootApplication
@ComponentScan(basePackages = "com.gl")
public class QRestService extends QBeanSupport {
    @Override
...

Continue reading →


How to select Query for today date using Java

I have encounter problem to select query from my oracle database using conditional to select record just for current data. After trail and error and searching all around the internet finally I found the solution

Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,0);
calendar.set(Calendar.MINUTE,0);
calendar.set(Calendar.SECOND,0);
Date fromDate = calendar.getTime();

Calendar toCalendar = Calendar.getInstance();
toCalendar.set(Calendar.HOUR_OF_DAY,23);
toCalendar.set(Calendar.MINUTE,59);
toCalendar.set(Calendar.SECOND,59);
Date toDate = toCalendar.getTime();

//Using Hibernate criteria
criteria.add(Restriction.between(datefield,fromDate,toDate));

That’s it.

View →


Learn JPOS Part 3 Transaction Manager and Selector

Hi There, in this is the part 3 I will give you the example about JPOS Transaction Manager and Selector.

I will start with simple scenario in this example we will have JPOS service to response message that coming from client simulator but the service can have the process to handle request based MTI and route to specific participant (based on MTI), for example we will handle message request with MTI 0200 as Transaction and message request with MTI 0800 as Network check.

you can clone the code in Github and choose the SimpleListener Project for this tutorial

https://github.com/Gemuruh-Geo/Learn-JPOS.git

2.png

first we create the JPOS setting

000_mogger.xml

000_mogger.xml is responsible as log the application

<logger name="Q2" class="org.jpos.q2.qbean.LoggerAdaptor">
    <log-listener class="org.jpos.util.SimpleLogListener" />
    <log-listener class="org.jpos.util.BufferedLogListener">
...

Continue reading →


Learn JPOS Part 1

Hi Today I am moving to new company and as part of my work I need to learn switching framework that is JPOS. Today I am start to read the JPOS documentation and try to write some blog post as way to remember and learn.
In the first part I am try to create channel that send the ISO Message and accept ISO Message from listener, before we continue with the code we need to highlight some term from the JPOS framework

ISOChannel

from documentation ISOChannel is interface that encapsulate wire protocol detail to send and receive ISOMessage so we can send and receive ISOMessage via ISOChannel

ISOServer

Briefly ISOServer is listen in a given port and take care the message and passing control for processing using implementation of ISOChannel (ISOListener)

Note: from JPOS user guide this approach is not advisable we should be using Q2

Create service channel as JPOS Client

package com.ge.c1;
...

Continue reading →


Using Java Map rather than if and else (Actually this more appropriate for switch case)

Actually this idea is not such a big stuff rather just find small thing that I found so interesting.
Usually we using if else or maybe switch to create logical condition until some extend the condition became so unreadable because its to long, for example

public class RobotSays{
    private void saysHello(){
        System.out.println("Hallooo Human");
    }
    private void saysGood(){
        System.out.println("I am Good, Human");
    }
    private void saysFine(){
        System.out.println("Technically I am Fine, Human");
    }
    public void robotSaysSomething(String says){
        if(says.equals("Hello")){
            saysHello();
        }else if(says.equals("Good")){
            saysGood();
        }else if(says.equals("Fine")){
            saysFine();
        }
    }
}

Look bit tedious work especially if the condition continue until very long. How about using Map

public
...

Continue reading →


Create your own callback in Java

Creating callback in Java need utilize the interface unlike the javascript there is quite a work to creating callback pattern in Java.

using interface

public interface WordIntf{
    public void saysSomething(String salutation);
}

Create the method that call the interface

public class WordImpl{
    private String salutation;
    public WordImpl(String salutation){
        this.salutation = salutation;
    }
    public void talkToPerson(WordIntf word){
         word.saysSomething(salutation);
    }
}

from my understanding the callback its mean we call the method again and we can Implemented anything inside the interface implementation. From the above example, in method saysSomething I can implement whole conversation to talk with people, but in the first conversation I will attach the salutation to welcome the person.

Concrete Implementation

public class Main{
    public static
...

Continue reading →