Re: [Stripes-users] Stripes-users Digest, Vol 113, Issue 4

2016-01-26 Thread VANKEISBELCK Remi
Hi Ron,

Sending an email at the end of the task is even easier : you don't need
polling at all !

Simply submit a runnable with your webservice call and response handling
(send the email) to an ExecutorService from the action. This is "fire and
forget" : submission to the executor doesn't block. Then just return a
redirect to the action you want.

Stuff like :

public Resolution submitTaskAndProceed() {
  executorService.submit(new MyTask(this));
  return new RedirectResolution(MyActionAfterSubmitTask.class);
}

As you see the action can be an argument of the task, in case you need it.
I prefer to pass actual required data as it makes your task testable
outside of Stripes.

The whole point here is that your action bean is a regular one. It submits
a job to a thread pool, that's all.

HTH

Rémi

2016-01-25 17:54 GMT+01:00 Ron King :

> The link that Joaquin describes is not quite what I want either. I want to
> allow the user to go ahead and
> continue to work, not wait one minute before they can go on. This seems to
> describe a scenario where a 'wait page' would be updated periodically, and
> I don't want the user to have to wait at all. Sending an email from within
> the action upon completion would work for me as far as notifying the user
> about their form submission.
>
> It appears to me that If I can get the response writer to write out my new
> page at the beginning of the submission, it would satisfy my requirement.
> How can I ensure that the writer is flushed?
>
>
> https://stripesframework.atlassian.net/wiki/display/STRIPES/Wait+Page+for+Long+Events
>
> On Mon, Jan 25, 2016 at 3:00 AM, <
> stripes-users-requ...@lists.sourceforge.net> wrote:
>
>> Send Stripes-users mailing list submissions to
>> stripes-users@lists.sourceforge.net
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>> or, via email, send a message with subject or body 'help' to
>> stripes-users-requ...@lists.sourceforge.net
>>
>> You can reach the person managing the list at
>> stripes-users-ow...@lists.sourceforge.net
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of Stripes-users digest..."
>>
>>
>> Today's Topics:
>>
>>1. Re: Writing to response.writer is not working (Joaquin Valdez)
>>2. Re: Infinite loop issue on stripes layout components inside
>>   jsp tag (Zlatka Mihaylova)
>>
>>
>> --
>>
>> Message: 1
>> Date: Sat, 23 Jan 2016 11:41:57 -0700
>> From: Joaquin Valdez 
>> Subject: Re: [Stripes-users] Writing to response.writer is not working
>> To: r...@rvkb.com, Stripes Users List
>> 
>> Message-ID: 
>> Content-Type: text/plain; charset="utf-8"
>>
>> Hi!
>>
>> Is this the same idea as this:
>>
>>
>> https://stripesframework.atlassian.net/wiki/display/STRIPES/Wait+Page+for+Long+Events
>> ?
>>
>> Joaquin
>>
>> > On Jan 23, 2016, at 10:52 AM, VANKEISBELCK Remi  wrote:
>> >
>> > Hi again,
>> >
>> > Seems like a regular "long running job / polling" scenario. It can be
>> done with current Stripes version, even if it will be less performant if
>> your http client is really non blocking, but that's another story.
>> >
>> > So here's how I'd do this.
>> >
>> > 1/ Server side
>> >
>> > In the ActionBean, I'd submit a task to an executor service (a thread
>> pool) with that long running job that calls the webservice. This task
>> should update the back-end state in some way, so that you can do polling
>> and know when it's done.
>> > The same ActionBean can handle Ajax polling via another event method.
>> This one will be called from some JS code in your page.
>> >
>> > public class MyAction implements ActionBean {
>> >
>> >   public Resolution triggerLongRunningJob() {
>> > // retrieve Executor Service, from servlet context or custom
>> ActionBeanContext
>> > ExecutorService executorService = ... ;
>> > // submit task
>> > executorService.submit(new MyLongRunningTask(...);
>> > // return a redirect resolution to the "wait" screen
>> > return new RedirectResolution(getClass(), "displayWaitScreen")
>> >   }
>> >
>> >   public Resolution displayWaitScreen() {
>> > return new ForwardResolution("/WEB-INF/jsp/wait-screen.jsp");
>> >   }
>> >
>> >   public Resolution poll() {
>> > // find task completion status and return to the client
>> > String jsonTaskCompletion = ... ;
>> > return new StreamingResolution("application/json",
>> jsonTaskCompletion);
>> >   }
>> >
>> >
>> >   // the long running task code is in a Runnable
>> >   private class MyLongRunningTask implements Runnable {
>> > public void run() {
>> >   // call the webservice and update internal state
>> >
>> > }
>> >   }
>> > }
>> >
>> >
>> 

Re: [Stripes-users] Flushing a writer before the ActionBean has completed

2016-01-26 Thread Ron King
Thanks Remi, I'll give this some thought, this helps a lot.
Also, I did come up with a way to prompt the user at the beginning of the
submission.
I pop up a jquery-ui dialog box, instead of trying to use the response
writer
to write a new page.

On Tue, Jan 26, 2016 at 2:15 AM, <
stripes-users-requ...@lists.sourceforge.net> wrote:

> Send Stripes-users mailing list submissions to
> stripes-users@lists.sourceforge.net
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.sourceforge.net/lists/listinfo/stripes-users
> or, via email, send a message with subject or body 'help' to
> stripes-users-requ...@lists.sourceforge.net
>
> You can reach the person managing the list at
> stripes-users-ow...@lists.sourceforge.net
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Stripes-users digest..."
>
>
> Today's Topics:
>
>1. Re: Stripes-users Digest, Vol 113, Issue 4 (VANKEISBELCK Remi)
>
>
> --
>
> Message: 1
> Date: Tue, 26 Jan 2016 09:15:03 +0100
> From: VANKEISBELCK Remi 
> Subject: Re: [Stripes-users] Stripes-users Digest, Vol 113, Issue 4
> To: Stripes Users List 
> Message-ID:
> 

[Stripes-users] Using an executor with Stripes, on Tomcat 8

2016-01-26 Thread Ron King
Remi, from some of my reading, I'm getting the impression
that one should be careful when using threads inside of a
servlet container. How do you do this, can you elaborate?

On Tue, Jan 26, 2016 at 9:23 AM, <
stripes-users-requ...@lists.sourceforge.net> wrote:

> Send Stripes-users mailing list submissions to
> stripes-users@lists.sourceforge.net
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.sourceforge.net/lists/listinfo/stripes-users
> or, via email, send a message with subject or body 'help' to
> stripes-users-requ...@lists.sourceforge.net
>
> You can reach the person managing the list at
> stripes-users-ow...@lists.sourceforge.net
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Stripes-users digest..."
>
>
> Today's Topics:
>
>1. Re: Flushing a writer before the ActionBean has   completed
>   (Ron King)
>
>
> --
>
> Message: 1
> Date: Tue, 26 Jan 2016 09:23:06 -0600
> From: Ron King 
> Subject: Re: [Stripes-users] Flushing a writer before the ActionBean
> has completed
> To: stripes-users@lists.sourceforge.net
> Message-ID:
> <
> can2l1vr_sxg8xo13fun2-vo82r6r2rqvxw5jf0gxjpdezjj...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Thanks Remi, I'll give this some thought, this helps a lot.
> Also, I did come up with a way to prompt the user at the beginning of the
> submission.
> I pop up a jquery-ui dialog box, instead of trying to use the response
> writer
> to write a new page.
>
> On Tue, Jan 26, 2016 at 2:15 AM, <
> stripes-users-requ...@lists.sourceforge.net> wrote:
>
> > Send Stripes-users mailing list submissions to
> > stripes-users@lists.sourceforge.net
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > https://lists.sourceforge.net/lists/listinfo/stripes-users
> > or, via email, send a message with subject or body 'help' to
> > stripes-users-requ...@lists.sourceforge.net
> >
> > You can reach the person managing the list at
> > stripes-users-ow...@lists.sourceforge.net
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of Stripes-users digest..."
> >
> >
> > Today's Topics:
> >
> >1. Re: Stripes-users Digest, Vol 113, Issue 4 (VANKEISBELCK Remi)
> >
> >
> > --
> >
> > Message: 1
> > Date: Tue, 26 Jan 2016 09:15:03 +0100
> > From: VANKEISBELCK Remi 
> > Subject: Re: [Stripes-users] Stripes-users Digest, Vol 113, Issue 4
> > To: Stripes Users List 
> > Message-ID:
> > 

Re: [Stripes-users] Using an executor with Stripes, on Tomcat 8

2016-01-26 Thread VANKEISBELCK Remi
No there's no issue using an ExecutorService inside a container. Most
frameworks use their own thread pools today.

Just create it in an init context listener or something like this, and
shutdown it properly when the app closes.

Cheers

Rémi

2016-01-26 17:23 GMT+01:00 Ron King :

> Remi, from some of my reading, I'm getting the impression
> that one should be careful when using threads inside of a
> servlet container. How do you do this, can you elaborate?
>
> On Tue, Jan 26, 2016 at 9:23 AM, <
> stripes-users-requ...@lists.sourceforge.net> wrote:
>
>> Send Stripes-users mailing list submissions to
>> stripes-users@lists.sourceforge.net
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>> or, via email, send a message with subject or body 'help' to
>> stripes-users-requ...@lists.sourceforge.net
>>
>> You can reach the person managing the list at
>> stripes-users-ow...@lists.sourceforge.net
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of Stripes-users digest..."
>>
>>
>> Today's Topics:
>>
>>1. Re: Flushing a writer before the ActionBean has   completed
>>   (Ron King)
>>
>>
>> --
>>
>> Message: 1
>> Date: Tue, 26 Jan 2016 09:23:06 -0600
>> From: Ron King 
>> Subject: Re: [Stripes-users] Flushing a writer before the ActionBean
>> has completed
>> To: stripes-users@lists.sourceforge.net
>> Message-ID:
>> <
>> can2l1vr_sxg8xo13fun2-vo82r6r2rqvxw5jf0gxjpdezjj...@mail.gmail.com>
>> Content-Type: text/plain; charset="utf-8"
>>
>> Thanks Remi, I'll give this some thought, this helps a lot.
>> Also, I did come up with a way to prompt the user at the beginning of the
>> submission.
>> I pop up a jquery-ui dialog box, instead of trying to use the response
>> writer
>> to write a new page.
>>
>> On Tue, Jan 26, 2016 at 2:15 AM, <
>> stripes-users-requ...@lists.sourceforge.net> wrote:
>>
>> > Send Stripes-users mailing list submissions to
>> > stripes-users@lists.sourceforge.net
>> >
>> > To subscribe or unsubscribe via the World Wide Web, visit
>> > https://lists.sourceforge.net/lists/listinfo/stripes-users
>> > or, via email, send a message with subject or body 'help' to
>> > stripes-users-requ...@lists.sourceforge.net
>> >
>> > You can reach the person managing the list at
>> > stripes-users-ow...@lists.sourceforge.net
>> >
>> > When replying, please edit your Subject line so it is more specific
>> > than "Re: Contents of Stripes-users digest..."
>> >
>> >
>> > Today's Topics:
>> >
>> >1. Re: Stripes-users Digest, Vol 113, Issue 4 (VANKEISBELCK Remi)
>> >
>> >
>> > --
>> >
>> > Message: 1
>> > Date: Tue, 26 Jan 2016 09:15:03 +0100
>> > From: VANKEISBELCK Remi 
>> > Subject: Re: [Stripes-users] Stripes-users Digest, Vol 113, Issue 4
>> > To: Stripes Users List 
>> > Message-ID:
>> >