Transaction processing - multithreading problem

154 views
Skip to first unread message

zab

unread,
Oct 24, 2006, 8:24:32 AM10/24/06
to jPOS Users
Hello All,

I have setup ISO Server using q2 module.
There are transactions that take too long to process.
The time consuming transactions block the channel till when finished.

I have put this in my server config file this:

<server name="z4-server-PostBridge" class="org.jpos.q2.iso.QServer"
logger="Q2">
<attr name="port" type="java.lang.Integer">6002</attr>
<channel name="post.channel"
class="org.jpos.iso.channel.PostChannel"
packager="org.jpos.iso.packager.PostPackager" logger="Q2">

<attr name="minSessions" type="java.lang.Integer">1</attr>
<attr name="maxSessions" type="java.lang.Integer">20</attr>

</channel>
<request-listener class="Postilion" logger="Q2">
.
.
.
.

</request-listener>
</server>


to setup thread pool, I tried this in the config:

<attr name="minSessions" type="java.lang.Integer">1</attr>
<attr name="maxSessions" type="java.lang.Integer">20</attr>

I need your advice, thanks
Zab

Alwyn Schoeman

unread,
Oct 24, 2006, 8:46:32 AM10/24/06
to jpos-...@googlegroups.com
Hi Zab,

From memory (very old memory) I collect that the ISOServer uses 1 thread from the threadpool per connection.  Thus a single thread (unless the session thread is split over a reading and writing thread) is used for reading and writing data to your client.

Now, when data is read from your client, that thread will call the ISORequestListener defined ,in the same thread of control.

So, if your ISORequestListener should block for some reason, then it will block your ISOServer connection to the client.
 
So, make sure your own code doesn't block and if it must block somewhere, use some sync/async implementation to keep the blocking from interfering with your data flow from and to your client.

Luckily if I'm wrong my Alzheimers would take care of the embarrassment.

regards,
Alwyn




--
Alwyn Schoeman

Alejandro Revilla

unread,
Oct 24, 2006, 8:47:13 AM10/24/06
to jpos-...@googlegroups.com
There's one thread pool used to accept multiple sessions, but you
need to use another pool to handle simultaneous transactions within
a session. You may want to have a look at our Connector implementation
and use a similar approach, or consider using the TransactionManager to
deal with your incoming messages.

Alejandro Revilla

unread,
Oct 24, 2006, 8:48:41 AM10/24/06
to jpos-...@googlegroups.com
>
> Luckily if I'm wrong my Alzheimers would take care of the embarrassment.
>
You will have to save the excuse for the next one because you are
absolutetly right.

Alwyn Schoeman

unread,
Oct 24, 2006, 8:51:30 AM10/24/06
to jpos-...@googlegroups.com
Do I know you from somewhere?  :)

zab

unread,
Oct 24, 2006, 10:17:35 AM10/24/06
to jPOS Users
Hi,

I thought q2 creates a new instance of the ISORequestListener class
every time a request comes.

zab

> Alwyn Schoeman- Hide quoted text -- Show quoted text -

Alwyn Schoeman

unread,
Oct 24, 2006, 10:24:19 AM10/24/06
to jpos-...@googlegroups.com
AFAIK it doesn't, and even if it did (which it doesn't), it will only happen once your previous requestlistener is finished processing or if you handed the previous request listener to another thread for processing.
--
Alwyn Schoeman

zab

unread,
Oct 24, 2006, 10:38:44 AM10/24/06
to jPOS Users
OK, I get.

Then, look at this:

My request-listener class does processing in this manner -

public boolean process (ISOSource source, ISOMsg m) {
......
if(message[0].equalsIgnoreCase("0200"))
{

//database call here

m.setResponseMTI();

m.set (new ISOField(39, /* set here return code*/));
// more filed settups ...
source.send(m);
}
}

is there another way I can process incoming messages outside this call
back method process?

or what is my design problem here?

Thanks.

On Oct 24, 5:24 pm, "Alwyn Schoeman" <alwyn.schoe...@gmail.com> wrote:
> AFAIK it doesn't, and even if it did (which it doesn't), it will only happen
> once your previous requestlistener is finished processing or if you handed
> the previous request listener to another thread for processing.
>

Alwyn Schoeman

unread,
Oct 24, 2006, 1:10:25 PM10/24/06
to jpos-...@googlegroups.com
I would say that your database call is taking too much time.  From experience I have found that database calls, especially over a network, can have a significant range of response times.  If each call includes a connect, then you can be sure it will take a long time (possibly seconds).

As Alejandro said you could either use something similar to the Connector (which I either haven't used yet, or too long ago) or you can use your own threadpool inside the ISORequestListener.

For the last one you would create a class implementing Runnable or Callable and execute your class on a Threadpool within ISORequestListener.

On 10/24/06, zab <och...@gmail.com> wrote:

zab

unread,
Oct 25, 2006, 5:25:09 AM10/25/06
to jPOS Users
I created a thread class for database transactions processing. so now
other requests are not being blocked.
thanks. i am still observing.

On Oct 24, 8:10 pm, "Alwyn Schoeman" <alwyn.schoe...@gmail.com> wrote:
> I would say that your database call is taking too much time. From
> experience I have found that database calls, especially over a network, can
> have a significant range of response times. If each call includes a
> connect, then you can be sure it will take a long time (possibly seconds).
>
> As Alejandro said you could either use something similar to the Connector
> (which I either haven't used yet, or too long ago) or you can use your own
> threadpool inside the ISORequestListener.
>
> For the last one you would create a class implementing Runnable or Callable
> and execute your class on a Threadpool within ISORequestListener.
>

Blessing Nhamo Gwatidzo

unread,
Apr 6, 2017, 6:22:34 AM4/6/17
to jPOS Users
Hi 

Can I have a single postbridge on my postilion carrying traffic from different channels ie Traffic from mobile banking, merchant and ATMs comig through a single postbridge.

Blessing Nhamo Gwatidzo

unread,
Apr 6, 2017, 6:25:13 AM4/6/17
to jPOS Users
Can I have a single postbridge on my postilion carrying traffic from different channels ie Traffic from mobile banking, merchant and ATMs comig through a single postbridge

On Tuesday, October 24, 2006 at 2:24:32 PM UTC+2, Zablon Ochomo wrote:

Victor Salaman

unread,
Apr 6, 2017, 6:42:28 AM4/6/17
to jpos-...@googlegroups.com
Why ask here not ACI?  

/V

--
--
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/4fb95559-c685-4142-a470-e8a70661cf93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages