mixing single shots with batching

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

mixing single shots with batching

Darrell Esau-2
Hi all,

Say I've got an application that's polling on a regular interval for data.  I have a number of "data clients" in the browser that all have different remote method calls.  Since these aren't user-spawned events, I want to batch them up to all send together, thus only using one connection.  

However, during this polling cycle, I've also got user-generated events which result in remote calls.  I don't want any delay on these calls .. so I don't want them batched.

Is there any way that I can mix batched calls and single shot calls?

So .. I'd start a batch, then end it every 5 seconds or so (then immediately start another one).  During these batches however, I'd want to send off calls at any time, outside the batch.

Thanks!

-d

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: mixing single shots with batching

david@butterdev.com
Maybe I don't understand your question but ... there is nothing special
you need to do this.  Simply batch the calls you want batched and make
the user-generated calls normally.

On 01/17/2012 12:32 PM, Darrell Esau wrote:

> Hi all,
>
> Say I've got an application that's polling on a regular interval for
> data.  I have a number of "data clients" in the browser that all have
> different remote method calls.  Since these aren't user-spawned
> events, I want to batch them up to all send together, thus only using
> one connection.
>
> However, during this polling cycle, I've also got user-generated
> events which result in remote calls.  I don't want any delay on these
> calls .. so I don't want them batched.
>
> Is there any way that I can mix batched calls and single shot calls?
>
> So .. I'd start a batch, then end it every 5 seconds or so (then
> immediately start another one).  During these batches however, I'd
> want to send off calls at any time, outside the batch.
>
> Thanks!
>
> -d
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: mixing single shots with batching

Mike Wilson
Administrator
In reply to this post by Darrell Esau-2
No, the batch APIs only handles one batch at a time so while a batch is open (between beginBatch and endBatch) every call will belong to this batch.
 
Though, the logic that handles this in engine.js is really really simple, so you could easily override this behaviour by swapping in and out your desired active batch in the property:
    dwr.engine._batch
depending on if a call belongs to the "5s" or "single shot" category.
 
Best regards
Mike Wilson
 
Darrell Esau wrote:
Hi all,

Say I've got an application that's polling on a regular interval for data.  I have a number of "data clients" in the browser that all have different remote method calls.  Since these aren't user-spawned events, I want to batch them up to all send together, thus only using one connection.  

However, during this polling cycle, I've also got user-generated events which result in remote calls.  I don't want any delay on these calls .. so I don't want them batched.

Is there any way that I can mix batched calls and single shot calls?

So .. I'd start a batch, then end it every 5 seconds or so (then immediately start another one).  During these batches however, I'd want to send off calls at any time, outside the batch.

Thanks!

-d

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: mixing single shots with batching

Darrell Esau-2
Interesting.

So -- let me walk through this --

1) I start a batch for polling
2) Add a few methods
3) At this point, I want to single shot something, so I save off dwr.engine._batch to some variable, then set dwr.engine._batch to null.
4) Call my single shot method
5) Reassign dwr.engine._batch to the saved batch, continue adding poll methods 
6) After some timer event, end the batch (then start a new one)

Does that sound correct/safe?  I've got a bunch of red flags going off in my head .. 

-d



On Tue, Jan 17, 2012 at 2:04 PM, Mike Wilson <[hidden email]> wrote:
No, the batch APIs only handles one batch at a time so while a batch is open (between beginBatch and endBatch) every call will belong to this batch.
 
Though, the logic that handles this in engine.js is really really simple, so you could easily override this behaviour by swapping in and out your desired active batch in the property:
    dwr.engine._batch
depending on if a call belongs to the "5s" or "single shot" category.
 
Best regards
Mike Wilson
 
Darrell Esau wrote:
Hi all,

Say I've got an application that's polling on a regular interval for data.  I have a number of "data clients" in the browser that all have different remote method calls.  Since these aren't user-spawned events, I want to batch them up to all send together, thus only using one connection.  

However, during this polling cycle, I've also got user-generated events which result in remote calls.  I don't want any delay on these calls .. so I don't want them batched.

Is there any way that I can mix batched calls and single shot calls?

So .. I'd start a batch, then end it every 5 seconds or so (then immediately start another one).  During these batches however, I'd want to send off calls at any time, outside the batch.

Thanks!

-d


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: mixing single shots with batching

Mike Wilson
Administrator
Yes, that's what I had in mind. Most of engine.js actually supports concurrent batches, it's just that the public API uses one global batch for convenience.
 
Best regards
Mike
 
Darrell Esau wrote:
Interesting.

So -- let me walk through this --

1) I start a batch for polling
2) Add a few methods
3) At this point, I want to single shot something, so I save off dwr.engine._batch to some variable, then set dwr.engine._batch to null.
4) Call my single shot method
5) Reassign dwr.engine._batch to the saved batch, continue adding poll methods 
6) After some timer event, end the batch (then start a new one)

Does that sound correct/safe?  I've got a bunch of red flags going off in my head .. 

-d



On Tue, Jan 17, 2012 at 2:04 PM, Mike Wilson <[hidden email]> wrote:
No, the batch APIs only handles one batch at a time so while a batch is open (between beginBatch and endBatch) every call will belong to this batch.
 
Though, the logic that handles this in engine.js is really really simple, so you could easily override this behaviour by swapping in and out your desired active batch in the property:
    dwr.engine._batch
depending on if a call belongs to the "5s" or "single shot" category.
 
Best regards
Mike Wilson
 
Darrell Esau wrote:
Hi all,

Say I've got an application that's polling on a regular interval for data.  I have a number of "data clients" in the browser that all have different remote method calls.  Since these aren't user-spawned events, I want to batch them up to all send together, thus only using one connection.  

However, during this polling cycle, I've also got user-generated events which result in remote calls.  I don't want any delay on these calls .. so I don't want them batched.

Is there any way that I can mix batched calls and single shot calls?

So .. I'd start a batch, then end it every 5 seconds or so (then immediately start another one).  During these batches however, I'd want to send off calls at any time, outside the batch.

Thanks!

-d


Loading...