You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by rmorrisey <rm...@csc.com> on 2008/10/01 18:02:12 UTC

Sequence of wicket (ajax) requests

Is it possible for two request cycles to be running on the server
concurrently against the same page/wicket session (including ajax requests)?
I was thinking that wicket forces the requests to be processed sequentially
(so that the two request cycles can't be handled at the same time), but it
seems like this is not the case
-- 
View this message in context: http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19763696.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Sequence of wicket (ajax) requests

Posted by rmorrisey <rm...@csc.com>.
Igor,

I was thinking about doing it with onBeginRequest(), something like:
AIMSSession session = (AIMSSession)getSession();
			synchronized (session) {
				try {
					//Wait for my turn
					while (session.hasActiveRequest()) {
						session.wait();
					}
					//My turn
					session.setActiveRequest(true);
				}
				catch (InterruptedException e) {
					getLog().error("Interrupted waiting for request synch", e);
				}
			}

and in onEndRequest:
AIMSSession session = (AIMSSession)getSession();
			synchronized (session) {
				session.setActiveRequest(false);
				session.notify();
			}

however I got worried that if there is some error and onEndRequest is never
called, my thread will be stuck endlessly. I looked at how wicket
synchronizes the mutator parts; it looks like it does:
RequestCycle.steps()
   RequestCycle.step()
    WebRequestCycleProcessor.resolve()
      synchronized(requestCycle.getSession())
      ...
   RequestCycle.detach()
    RequestCycle.onEndRequest()

I thought that if I could promote the synchronized() block up to
RequestCycle.steps() it would be the safest solution. Does this seem like it
makes sense?:

private final void steps()
{
synchronized (getSession())
{
try/finally...
}
}

I am testing it out (by placing my custom RequestCycle.java earlier in my
classpath) and it seems to work OK. Can you think of any issues with this
approach? and if not is it possible to open up the "final" or provide some
other mechanism so that I don't have to duplicate RequestCycle in full?


igor.vaynberg wrote:
> 
> sure, in onbeginrequest of your request cycle sync on session
> 
> -igor
> 
> On Wed, Oct 1, 2008 at 9:34 AM, rmorrisey <rm...@csc.com> wrote:
>>
>> Igor, Matej, thanks for the replies -
>>
>> I would like to guarantee that only one request cycle is running at a
>> time
>> (for a given wicket session). Is it possible for me to tweak wicket to
>> expanded the part that is synchronized to encompass the RequestCycle's
>> onEndRequest?
>>
>>
>> igor.vaynberg wrote:
>>>
>>> there can be two request cycles running, sure
>>>
>>> it is only the part that accesses and mutates the page is synchronized
>>> for higher throughput
>>>
>>> -igor
>>>
>>> On Wed, Oct 1, 2008 at 9:02 AM, rmorrisey <rm...@csc.com> wrote:
>>>>
>>>> Is it possible for two request cycles to be running on the server
>>>> concurrently against the same page/wicket session (including ajax
>>>> requests)?
>>>> I was thinking that wicket forces the requests to be processed
>>>> sequentially
>>>> (so that the two request cycles can't be handled at the same time), but
>>>> it
>>>> seems like this is not the case
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19763696.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19764365.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19767653.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Sequence of wicket (ajax) requests

Posted by Igor Vaynberg <ig...@gmail.com>.
sure, in onbeginrequest of your request cycle sync on session

-igor

On Wed, Oct 1, 2008 at 9:34 AM, rmorrisey <rm...@csc.com> wrote:
>
> Igor, Matej, thanks for the replies -
>
> I would like to guarantee that only one request cycle is running at a time
> (for a given wicket session). Is it possible for me to tweak wicket to
> expanded the part that is synchronized to encompass the RequestCycle's
> onEndRequest?
>
>
> igor.vaynberg wrote:
>>
>> there can be two request cycles running, sure
>>
>> it is only the part that accesses and mutates the page is synchronized
>> for higher throughput
>>
>> -igor
>>
>> On Wed, Oct 1, 2008 at 9:02 AM, rmorrisey <rm...@csc.com> wrote:
>>>
>>> Is it possible for two request cycles to be running on the server
>>> concurrently against the same page/wicket session (including ajax
>>> requests)?
>>> I was thinking that wicket forces the requests to be processed
>>> sequentially
>>> (so that the two request cycles can't be handled at the same time), but
>>> it
>>> seems like this is not the case
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19763696.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19764365.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Sequence of wicket (ajax) requests

Posted by rmorrisey <rm...@csc.com>.
Igor, Matej, thanks for the replies -

I would like to guarantee that only one request cycle is running at a time
(for a given wicket session). Is it possible for me to tweak wicket to
expanded the part that is synchronized to encompass the RequestCycle's
onEndRequest?


igor.vaynberg wrote:
> 
> there can be two request cycles running, sure
> 
> it is only the part that accesses and mutates the page is synchronized
> for higher throughput
> 
> -igor
> 
> On Wed, Oct 1, 2008 at 9:02 AM, rmorrisey <rm...@csc.com> wrote:
>>
>> Is it possible for two request cycles to be running on the server
>> concurrently against the same page/wicket session (including ajax
>> requests)?
>> I was thinking that wicket forces the requests to be processed
>> sequentially
>> (so that the two request cycles can't be handled at the same time), but
>> it
>> seems like this is not the case
>> --
>> View this message in context:
>> http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19763696.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19764365.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Sequence of wicket (ajax) requests

Posted by Igor Vaynberg <ig...@gmail.com>.
there can be two request cycles running, sure

it is only the part that accesses and mutates the page is synchronized
for higher throughput

-igor

On Wed, Oct 1, 2008 at 9:02 AM, rmorrisey <rm...@csc.com> wrote:
>
> Is it possible for two request cycles to be running on the server
> concurrently against the same page/wicket session (including ajax requests)?
> I was thinking that wicket forces the requests to be processed sequentially
> (so that the two request cycles can't be handled at the same time), but it
> seems like this is not the case
> --
> View this message in context: http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19763696.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Sequence of wicket (ajax) requests

Posted by Matej Knopp <ma...@gmail.com>.
Ajax requests are queued on the client side, so for same page there
would not be two paralel ajax request. It is possible to have more
queues on the client side, but even if you do that, the requests are
still synced on page serverside.

-Matej

On Wed, Oct 1, 2008 at 6:02 PM, rmorrisey <rm...@csc.com> wrote:
>
> Is it possible for two request cycles to be running on the server
> concurrently against the same page/wicket session (including ajax requests)?
> I was thinking that wicket forces the requests to be processed sequentially
> (so that the two request cycles can't be handled at the same time), but it
> seems like this is not the case
> --
> View this message in context: http://www.nabble.com/Sequence-of-wicket-%28ajax%29-requests-tp19763696p19763696.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org