You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Bilgin Ibryam <bi...@gmail.com> on 2016/10/26 16:56:51 UTC

how to invoke long running task

Hi all,

I have a use case where the use triggers an actions that takes a
couple of minutes computation.
What would be best way to invoke such an action in ISIS? Currently it
runs in the calling thread and simply the UI hands for a while.

Ideally I like to run that in a background thread, but also give the
user some indication of progress of the background task. I wonder if
there is anything in the framework or addons that could help me.

Thanks,

-- 
Bilgin Ibryam
Camel Committer at ASF & Integration Architect at Red Hat
Blog: http://ofbizian.com | Twitter: @bibryam

Camel Design Patterns https://leanpub.com/camel-design-patterns
Instant Apache Camel Message Routing http://www.amazon.com/dp/1783283475

Re: how to invoke long running task

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Thanks for that, Martin.

I've updated https://issues.apache.org/jira/browse/ISIS-1176 with this
info.

On 30 October 2016 at 12:39, Martin Grigorov <mg...@apache.org> wrote:

> Hi,
>
>
> On Sat, Oct 29, 2016 at 7:43 PM, Dan Haywood <dan@haywood-associates.co.uk
> >
> wrote:
>
> > inline
> >
> > On 29 October 2016 at 13:05, Bilgin Ibryam <bi...@gmail.com> wrote:
> >
> > >
> > >
> > > Are there any examples of simple wicket widget that refresh from the
> > > backend? What would be the closes code sampel to that?
> > >
> > >
> > [4] http://examples7x.wicket.apache.org/atmosphere/?0
> >
> > the source code link is to the right hand side.
> >
> > @martin-g - do you know of any other resources/approaches?
> >
>
> The simplest way is to use
> AbstractTimerAjaxBehavior/AjaxSelfUpdatingBehavior. This would do polling,
> i.e. every N seconds an Ajax call will be made to check whether there is
> new data to show.
>
> If you need to do server push, i.e. whenever new data comes to push it
> immediately to the client then I'd suggest Wicket Native WebSocket instead
> of Atmosphere. Nowadays all browsers support WebSocket (IE10+ and all
> others) and almost everyone deploys on web server that support JSR 356 -
> https://ci.apache.org/projects/wicket/guide/7.x/
> guide/nativewebsockets.html.
> It's usage is as easy as Wicket Ajax.
>
> Another option is Server Send Events (
> https://github.com/wicketstuff/core/tree/master/
> wicket-html5-parent/wicket-html5,
> demo:
> https://github.com/wicketstuff/core/tree/master/
> wicket-html5-parent/wicket-html5-examples/src/main/java/
> org/wicketstuff/html5/eventsource
> )
>
>
> >
> >
> >
> > >
> >
>

Re: how to invoke long running task

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Sat, Oct 29, 2016 at 7:43 PM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> inline
>
> On 29 October 2016 at 13:05, Bilgin Ibryam <bi...@gmail.com> wrote:
>
> >
> >
> > Are there any examples of simple wicket widget that refresh from the
> > backend? What would be the closes code sampel to that?
> >
> >
> [4] http://examples7x.wicket.apache.org/atmosphere/?0
>
> the source code link is to the right hand side.
>
> @martin-g - do you know of any other resources/approaches?
>

The simplest way is to use
AbstractTimerAjaxBehavior/AjaxSelfUpdatingBehavior. This would do polling,
i.e. every N seconds an Ajax call will be made to check whether there is
new data to show.

If you need to do server push, i.e. whenever new data comes to push it
immediately to the client then I'd suggest Wicket Native WebSocket instead
of Atmosphere. Nowadays all browsers support WebSocket (IE10+ and all
others) and almost everyone deploys on web server that support JSR 356 -
https://ci.apache.org/projects/wicket/guide/7.x/guide/nativewebsockets.html.
It's usage is as easy as Wicket Ajax.

Another option is Server Send Events (
https://github.com/wicketstuff/core/tree/master/wicket-html5-parent/wicket-html5,
demo:
https://github.com/wicketstuff/core/tree/master/wicket-html5-parent/wicket-html5-examples/src/main/java/org/wicketstuff/html5/eventsource
)


>
>
>
> >
>

Re: how to invoke long running task

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
inline

On 29 October 2016 at 13:05, Bilgin Ibryam <bi...@gmail.com> wrote:

>
>
> Are there any examples of simple wicket widget that refresh from the
> backend? What would be the closes code sampel to that?
>
>
[4] http://examples7x.wicket.apache.org/atmosphere/?0

the source code link is to the right hand side.

@martin-g - do you know of any other resources/approaches?




>

Re: how to invoke long running task

Posted by Bilgin Ibryam <bi...@gmail.com>.
Thanks Dan,

inline

On 26 October 2016 at 18:13, Dan Haywood <da...@haywood-associates.co.uk> wrote:
> On 26 October 2016 at 17:56, Bilgin Ibryam <bi...@gmail.com> wrote:
>
>> Hi all,
>>
>> I have a use case where the use triggers an actions that takes a
>> couple of minutes computation.
>> What would be best way to invoke such an action in ISIS? Currently it
>> runs in the calling thread and simply the UI hands for a while.
>>
>> Ideally I like to run that in a background thread,
>
>
> this bit is easy, just use the BackgroundService [1] in conjunction with
> the command addon module [2]. then use the Quartz addon module [3] to
> invoke queued up commands.
>

I'll check that.

>
>
>
>
>> but also give the
>> user some indication of progress of the background task.
>
>
>
> ... this bit doesn't yet exist.
>
> We did spike a little counter using Wicket's integration with Atmosphere
> [4] a couple of years ago, just to push the current time down to the web
> browser, but we didn't take it any further.
>
> There are a couple of ways I can see this requirement might be tackled, but
> perhaps the easiest would be to provide some sort of Wicket widget (maybe
> rendered in the footer) that has built-in knowledge of the background
> command queue, and so which could indicate to the user what the status of
> their job(s) are.  When the user clicks on a job it could perhaps render
> the persisted Command (or maybe a view model for a simplified UI / could
> perhaps go to the "target" / most relevant object that has been updated).
>
>
> Interested in your thoughts; we actually have a somewhat similar
> requirement for Estatio, so would be good to kick around some ideas.

Are there any examples of simple wicket widget that refresh from the
backend? What would be the closes code sampel to that?


Thanks

>
> Thx
> Dan
>
>
>
>
>> I wonder if
>> there is anything in the framework or addons that could help me.
>>
>>
> [1] http://isis.apache.org/guides/rgsvc.html#_rgsvc_api_BackgroundService
> [2] https://github.com/isisaddons/isis-module-command
> [3] https://github.com/isisaddons/isis-module-quartz
> [4] http://examples7x.wicket.apache.org/atmosphere/?0
>
>
> Thanks,
>>
>> --
>> Bilgin Ibryam
>> Camel Committer at ASF & Integration Architect at Red Hat
>> Blog: http://ofbizian.com | Twitter: @bibryam
>>
>> Camel Design Patterns https://leanpub.com/camel-design-patterns
>> Instant Apache Camel Message Routing http://www.amazon.com/dp/1783283475
>>



-- 
Bilgin Ibryam
Camel Committer at ASF & Integration Architect at Red Hat
Blog: http://ofbizian.com | Twitter: @bibryam

Camel Design Patterns https://leanpub.com/camel-design-patterns
Instant Apache Camel Message Routing http://www.amazon.com/dp/1783283475

Re: how to invoke long running task

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 26 October 2016 at 17:56, Bilgin Ibryam <bi...@gmail.com> wrote:

> Hi all,
>
> I have a use case where the use triggers an actions that takes a
> couple of minutes computation.
> What would be best way to invoke such an action in ISIS? Currently it
> runs in the calling thread and simply the UI hands for a while.
>
> Ideally I like to run that in a background thread,


this bit is easy, just use the BackgroundService [1] in conjunction with
the command addon module [2]. then use the Quartz addon module [3] to
invoke queued up commands.





> but also give the
> user some indication of progress of the background task.



... this bit doesn't yet exist.

We did spike a little counter using Wicket's integration with Atmosphere
[4] a couple of years ago, just to push the current time down to the web
browser, but we didn't take it any further.

There are a couple of ways I can see this requirement might be tackled, but
perhaps the easiest would be to provide some sort of Wicket widget (maybe
rendered in the footer) that has built-in knowledge of the background
command queue, and so which could indicate to the user what the status of
their job(s) are.  When the user clicks on a job it could perhaps render
the persisted Command (or maybe a view model for a simplified UI / could
perhaps go to the "target" / most relevant object that has been updated).


Interested in your thoughts; we actually have a somewhat similar
requirement for Estatio, so would be good to kick around some ideas.

Thx
Dan




> I wonder if
> there is anything in the framework or addons that could help me.
>
>
[1] http://isis.apache.org/guides/rgsvc.html#_rgsvc_api_BackgroundService
[2] https://github.com/isisaddons/isis-module-command
[3] https://github.com/isisaddons/isis-module-quartz
[4] http://examples7x.wicket.apache.org/atmosphere/?0


Thanks,
>
> --
> Bilgin Ibryam
> Camel Committer at ASF & Integration Architect at Red Hat
> Blog: http://ofbizian.com | Twitter: @bibryam
>
> Camel Design Patterns https://leanpub.com/camel-design-patterns
> Instant Apache Camel Message Routing http://www.amazon.com/dp/1783283475
>