[jpos-users] Space Timeout Listener

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

[jpos-users] Space Timeout Listener

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

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

Re: [jpos-users] Space Timeout Listener

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


On Wed, Aug 2, 2017 at 12:57 AM, QSwitch <[hidden email]> wrote:
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.

--
--
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/49438f09-6112-404e-b45e-f0a969704062%40googlegroups.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%3DkTP8G%2BJDrOfBwkcfd%3D1htvU%2Btg_uc7-QU_cvxM31hkhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [jpos-users] Space Timeout Listener

QSwitch
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) ?


On Wednesday, 2 August 2017 19:48:12 UTC+7, Alejandro Revilla wrote:
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.

--
<a style="font-family:garamond,serif" href="http://twitter.com/apr" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2Fapr\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFRt8creb486OVHOJ12erdzV1NRIg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2Fapr\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFRt8creb486OVHOJ12erdzV1NRIg&#39;;return true;">@apr

--
--
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/e121ae73-3f99-41db-bc15-f849ca7c61f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [jpos-users] Space Timeout Listener

Alejandro Revilla

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?




On Thu, Aug 3, 2017 at 4:52 AM, QSwitch <[hidden email]> wrote:
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) ?


On Wednesday, 2 August 2017 19:48:12 UTC+7, Alejandro Revilla wrote:
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: [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/e121ae73-3f99-41db-bc15-f849ca7c61f7%40googlegroups.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%3DkQXjw5fR3h2ja-FVd8ezHzbtL1VDGVq9DVziJLT25ctw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [jpos-users] Space Timeout Listener

QSwitch
Hi Alejandro,

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

Many thanks in advace...


On Friday, 4 August 2017 09:13:14 UTC+7, Alejandro Revilla wrote:

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?



--
<a style="font-family:garamond,serif" href="http://twitter.com/apr" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2Fapr\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFRt8creb486OVHOJ12erdzV1NRIg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2Fapr\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFRt8creb486OVHOJ12erdzV1NRIg&#39;;return true;">@apr

--
--
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/2c936229-9df8-4564-9de8-35d62b57bcd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [jpos-users] Space Timeout Listener

Alejandro Revilla

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.



On Fri, Aug 4, 2017 at 9:03 AM, QSwitch <[hidden email]> wrote:
Hi Alejandro,

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

Many thanks in advace...


On Friday, 4 August 2017 09:13:14 UTC+7, Alejandro Revilla wrote:

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: [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/2c936229-9df8-4564-9de8-35d62b57bcd8%40googlegroups.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%3D%3DCiqqCb3v5JSV%2B5MgNDsb84XxLELN9%2BcTeToXHjShf3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [jpos-users] Space Timeout Listener

QSwitch
Hi Alejandro,

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

On Saturday, 5 August 2017 00:38:39 UTC+7, Alejandro Revilla wrote:
Done in <a href="https://github.com/jpos/jPOS/commit/1ad478f11a5e59da98a9691875d23a04964b6ed7" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjpos%2FjPOS%2Fcommit%2F1ad478f11a5e59da98a9691875d23a04964b6ed7\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzesZ_KOFUh-N3EOLOA3Wk4bvmjg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjpos%2FjPOS%2Fcommit%2F1ad478f11a5e59da98a9691875d23a04964b6ed7\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzesZ_KOFUh-N3EOLOA3Wk4bvmjg&#39;;return true;">https://github.com/jpos/jPOS/commit/1ad478f11a5e59da98a9691875d23a04964b6ed7

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.


--
<a style="font-family:garamond,serif" href="http://twitter.com/apr" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2Fapr\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFRt8creb486OVHOJ12erdzV1NRIg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftwitter.com%2Fapr\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFRt8creb486OVHOJ12erdzV1NRIg&#39;;return true;">@apr


--
--
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/5d08ef44-340d-4fee-890f-ed489dfe38fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [jpos-users] Space Timeout Listener

Alejandro Revilla
Excellent. Thank you for your confirmation.



--
--
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%3D%3DyhhnHFLzdWOJuBoOzLVQT2HGvkrNZRJ1zyyUUavwQ%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.