Making ISORequestListener to use a ThreadPool

77 views
Skip to first unread message

Titus Rakkesh

unread,
Feb 16, 2017, 5:55:29 AM2/16/17
to jpos-...@googlegroups.com
Dears,
      We have an ISORequestListenerClass implemented and it have the following method. In that all business logic is implemented.


public boolean process(ISOSource source, ISOMsg m) {

}

How we can make this method to be called in independent threads using a thread pool. The issue is we can have lot of slow processing components in the logic. So we need to make each transactions asynchronously processing?

Thanks

Alejandro Revilla

unread,
Feb 16, 2017, 7:16:13 AM2/16/17
to jPOS Users

There’s an easy solution to your problem, and a right solution to your problem.

First the easy one, but please, consider the right one too.

The easiest thing to do is to spawn a thread whenever you receive a transaction.

Imagine you create a little class like this:

    protected class Process implements Runnable {
        ISOSource source;
        ISOMsg m;
        Process (ISOSource source, ISOMsg m) {
            super();
            this.source = source;
            this.m = m;
        }
        public void run () {
            ...
            ...
            Implement your logic here
            ...
            ...
        }

    }

So your process method can be something like this:

public boolean process (ISOSource source, ISOMsg m) {
   new Thread(new Process(source,m)).start();
   return true;
}

You can also use a ThreadPool if you want to put a cap in the number of threads, you’d call pool.execute(new Process (source, m));.

But a better solution is to use the TransactionManager, where you can control the number of sessions and get useful information about the time spent in each participant. When using the TransactionManager, your ISORequestListener just creates a context, places the ISOSource and ISOMsg in it and hands off the context to the TM so it can be processed there.

I suggest you join one of the free webinars provided by Transactility every other Friday (http://www.transactility.com/contact), there you can get additional information on how to use the TM and please believe me, you’ll be tempted to implement the solution mentioned above, it’s the easy one, but once your system start growing, the increased load will be a problem. The TransactionManager will be your friend.




--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CABm7V61QBhdeo_iWoV6Bem2a0su0s7KmG-%3Ds1nYLSGo_hG-zrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Titus Rakkesh

unread,
Feb 16, 2017, 8:08:40 AM2/16/17
to jpos-...@googlegroups.com, a...@jpos.org
Thanks very much for the support and kind advice.

Reply all
Reply to author
Forward
0 new messages