Space Timeout Listener

48 views
Skip to first unread message

QSwitch

unread,
Aug 1, 2017, 11:57:57 PM8/1/17
to jPOS Users
Dear JPos expert,

I have a case in which my TM participant need to query to a host asynchronously: I send a http request, got an acknowledgment and my host later on (between 1sec - 30secs) will do a callback to my URL with transaction result.

I implement this by putting the context into a space queue with a timeout, let the participant exit with "PREPARED|PAUSE" and once my callback URL got called, I pick the context from the space and resume it. So far this scenario perfectly fulfill my requirement.

Now I need to be able to catch a timeout scenario, in which my host responding more than 30secs or do not respond at all. What is the correct way to catch a space queue timeout ?

Many thanks in advance for any advice.

Alejandro Revilla

unread,
Aug 2, 2017, 8:48:12 AM8/2/17
to jPOS Users
Good to know the PAUSE worked for you.

You just need to configure a property `pause-timeout`(in milis) and your context will be automatically resumed (i.e. set it to 35 seconds)

Your next participant of course will have to see if there's a response or not in the Context in order to tell apart transactions that have been resumed due to a response from the remote host, or because there has been automatically resumed.

Hope this helps, please let us know if this works for you.


--
--
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/49438f09-6112-404e-b45e-f0a969704062%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

QSwitch

unread,
Aug 3, 2017, 3:52:07 AM8/3/17
to jPOS Users
Hi Alejandro,

Thanks for your suggestion, I am able to make "pause-timeout" works, and I can see the flow continues after timeout period. However, it continues as an "aborted" transaction. Is there a way to resume the transaction after timeout normally (not aborted) ?

Alejandro Revilla

unread,
Aug 3, 2017, 10:13:14 PM8/3/17
to jPOS Users

There’s currently no way to do that, when the transaction is automatically resumed due to a timeout, the system assumes that the previous participant has aborted. One way to override that behaviour is by making sure you never timeout, using your own timer task or scheduled executor to resume the context.

The existing code does something like this:

    public static class PausedMonitor extends TimerTask {
        Pausable context;
        public PausedMonitor (Pausable context) {
            super();
            this.context = context;
        }
        @Override
        public void run() {
            cancel();
            context.getPausedTransaction().forceAbort();
            context.resume();
        }
    }

you can see a call to context.getPausedTransaction().forceAbort(); before calling resume.

If it helps, we can make that behaviour configurable (i.e something like abort-on-resume=false) with a default to true.

Would that work for you?




--
--
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.

QSwitch

unread,
Aug 4, 2017, 8:03:03 AM8/4/17
to jPOS Users
Hi Alejandro,

Obviously it will helps me (and others too, I believe).

Many thanks in advace...

Alejandro Revilla

unread,
Aug 4, 2017, 1:38:39 PM8/4/17
to jPOS Users

You can set the new `abort-on-pause-timeout` property to false (defaults to true for backward compatibility).

A nightly build has been forced so you can get the new code from your standard Gradle/Maven build.



--
--
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.

QSwitch

unread,
Aug 7, 2017, 8:01:10 AM8/7/17
to jPOS Users
Hi Alejandro,

Many thanks for the update, it works & really helps me.

Alejandro Revilla

unread,
Aug 7, 2017, 9:34:41 AM8/7/17
to jPOS Users
Excellent. Thank you for your confirmation.



Reply all
Reply to author
Forward
0 new messages