Sometimes we increase the price. Usually when customers call and complain about the price increase we send them products for the old price (the price they bought the product originally). We do have a jsp form for that. So we fill in the information about the customer in the jsp including their old price and submit to a servlet. The servlet has a method called stickPriceToCustomer(HttpServletRequest request, HttpServletResponse response) which set the old price to the customer. So the customer gets the product for the old price.
Now the company decided to increase the price but the company also decided to sell the product for the old price to all existing customers.
In order to do that what I am planning to do is:
Get the list of all customers from production database and populate a new table in my local database with all the information that need to be submitted to the servlet then write another servlet (just in my local) to get a list of customers and form a url object for each customer and submit the url to the other servlet (in production) to call stickPriceToCustomer(HttpServletRequest request, HttpServletResponse response) method in the servlet.
The idea is that we don’t want to do any release to production at this point and I can do this by writing code in my local (my boss doesn’t want to do any code release to production now).
There are about 20,000 users who subscribed to get the product now.
So my concern is the jsp that I submit to the servlet to invoke the method will take a long time to get the response and eventually will time out (Is that okay. Do I have to be concerned about this?).
And also in my local database I am planning to log all the users that got updated.
Alex George wrote:So my concern is the jsp that I submit to the servlet to invoke the method will take a long time to get the response and eventually will time out (Is that okay. Do I have to be concerned about this?).
Why? It sounds like you are submitting one request at a time. Each request takes the same amount of time - it's just that there are a lot of them. (You can really do a bunch at a time assuming your code is thread safe. Kick off 10 such programs to hit the server.) This means you won't get a timeout because each request is short. It will take time to make 20K requests, but not as long as you might expect. Especially if you don't wait and do them linearly.
So I was concerned that this jsp will wait there and time out.
Do you have any suggestions?
Or may be instead of writing a new servlet, I should write a java class and form a url object and submit to the existing servlet one request at a time.
I also need to log the response into my local database.
Any suggestions appreciated.
Alex George wrote:I need to post the request to the existing servlet to set price for each customer. So you think it is better to write a java program that form a url for each user and submit the request for each user. And call this small java program in command line.
I think you should do that too. I didn't realize you were talking about a servlet at your end.
Alex George wrote:I think what you are saying is that instead of writing a servlet at my end, I should write a regular java program and form a url object and submit this to the existing jsp/servlet in production for each user within a loop. This way I can specify some parameters in the method that form the url to pick up customers from 1 to 5000 in one call and 5000 to 10000 in another call and so on and get it done faster.
Correct. That also provides for better error recovery. Your application can log the ones that didn't work for later investigation - and it will be easier to retry just those.
If you guys forgot what this java class does, all this does is to form a url and submit to a jsp to set price for an item for a customer.