users@jersey.java.net

Re: [Jersey] Application scaling support in Jersey

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 17 Jul 2009 09:55:53 +0200

On Jul 16, 2009, at 9:30 PM, Craig McClanahan wrote:

> Suchitha Koneru (sukoneru) wrote:
>>
>> Thanks Tatu for the suggestion. If I have a list of 50,000 or for
>> example 1000 items, Would Jersey process this list in the form of
>> batches ? Is Batch processing or Handling of large data sets built
>> into Jersey Framework? I am trying to see if there are any
>> annotations in Jersey which I can use in this scenario.
>>
>>
> This is not up to Jersey (or even JAX-RS) ... it is up to how you
> design your API. In this sort of situation, I would probably design
> the server to accept either a single transaction or a collection of
> transactions, and process whatever it received. But its up to the
> client to maintain the state information of how far it has gotten
> through its potentially larger set of transactions yet to submit.
> In a proper REST API, the interactions with the server are
> stateless, so this information isn't the business of the server.
>

Yes.

If you design your application to consume a list of stuff then there
should be no "theoretical" limit on how many entries are to be in the
list that is sent by a client. Thus the if the client wanted to send
50,000 line items, it could make 10 requests sending 5,000 line items,
or make 5 requests sending 10,000 items, or make 1 request with 50,000
items.

When the client sends multiple requests it may be useful to demarcate
the start and end of the batch processing, which is what Craig means
by transactions.

One could POST to a resource to get a new URI, u say, that the client
uses to send batched requests. When the client has finished it sends a
DELETE to u, which indicates to the server the batch is complete. This
is a nice approach, especially for long running batch processes.

Paul.