[jpos-users] Making ISORequestListener to use a ThreadPool

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jpos-users] Making ISORequestListener to use a ThreadPool

Titus Rakkesh
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

--
--
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: [hidden email]
---
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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: [jpos-users] Making ISORequestListener to use a ThreadPool

Alejandro Revilla

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.




On Thu, Feb 16, 2017 at 7:55 AM, Titus Rakkesh <[hidden email]> wrote:
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

--
--
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: [hidden email]
---
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 [hidden email].
To post to this group, send email to [hidden email].
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.

--
--
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: [hidden email]
---
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CAAgSK%3DkXrsfCHFgrX9%3Dger_fABUN323xRQLAK7NkreuqurgTpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [jpos-users] Making ISORequestListener to use a ThreadPool

Titus Rakkesh
Thanks very much for the support and kind advice.

On Thu, Feb 16, 2017 at 5:45 PM, Alejandro Revilla <[hidden email]> wrote:

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.




On Thu, Feb 16, 2017 at 7:55 AM, Titus Rakkesh <[hidden email]> wrote:
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

--
--
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: [hidden email]
---
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 [hidden email].
To post to this group, send email to [hidden email].
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.

--
--
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: [hidden email]
---
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CAAgSK%3DkXrsfCHFgrX9%3Dger_fABUN323xRQLAK7NkreuqurgTpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
--
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: [hidden email]
---
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CABm7V62MbjEhfLMNuqxojqGHbs1Ev-TW3xhtKLU_%3Dcx6kWPF0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.