• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling a web service in a Thread

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a class with vector.i have a web service which can only fetch 20 records at a time provided the start point and endpoint from a storage of 100 records. so i want to call a thread for 5 times as (sp=0,ep=20)(sp=21,ep=40)... like so and want to fill those values in the vector how can i achieve the same.

Thanks and regards

tirupathi rao.P
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you have that works now in a single request?

Bill
 
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi TirupathiRao,
I don't think that's a good design practice. You'll end up writing extra code to deal with threading mechanism, assembling response and fault handling. What issues do you have in getting all the 100 records in one go?Unless you show all the records in a web page or to process at a time, you can look up for smaller chunks like 20 at a time.
 
TirupathiRao Pattapuraju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Naren Chivukula wrote:Hi TirupathiRao,
I don't think that's a good design practice. You'll end up writing extra code to deal with threading mechanism, assembling response and fault handling. What issues do you have in getting all the 100 records in one go?Unless you show all the records in a web page or to process at a time, you can look up for smaller chunks like 20 at a time.



First Of All thank you Naren ...

Here is the abstract of the limitaion i am facing..Actullay i am consuming the web service provided by the Siebel CRMOD to fetch the Accounts(Thousands of Records) lying there in their server.The limiations is a call can give 100 records at time only so i will loop thru the logic to fetch 100 by 100 by providing start point as 0,100,200.... and add them to a list for later use and will do this loop until the response contain records<100.

Say if there are 5000 records i have to loop for 50 times which is a time consuming process.so i am checking that can i take threads help to achieve this.Can you guide on the same.

Thanks and regards
Tirupathi Rao.P
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi TirupathiRao,

Welcome to JavaRanch.

What Naren has stated is that explicit control on the thread part you should have to take care if you attempt to employ threads. Yes of course that may be an overhead. But considering the advantage and its demand, you can bear the cost of it!
 
Naren Chivukula
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi TirupathiRao,
Thread are usually applied to perform parallel activities of slightly different in behaviour. For example, on a browser user can scroll and at the same time load an applet or call two different web services at the same time and consolidate their responses. If you are planning to use threads for this particular purpose, you'll end up waiting for other threads to complete and join all the threads and eventually construct different thread out comes into a single response. Did you check if you could do all the records in one go? I suspect you would get memory related problems and more likely if your design/coding is not well done.
 
TirupathiRao Pattapuraju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Naren Chivukula wrote:Hi TirupathiRao,
Thread are usually applied to perform parallel activities of slightly different in behaviour. For example, on a browser user can scroll and at the same time load an applet or call two different web services at the same time and consolidate their responses. If you are planning to use threads for this particular purpose, you'll end up waiting for other threads to complete and join all the threads and eventually construct different thread out comes into a single response. Did you check if you could do all the records in one go? I suspect you would get memory related problems and more likely if your design/coding is not well done.



Actullay i have to live with the limiataion posed by the Siebel CRMOD(fetch 100 at time).So i want to reduce the time its is taking to fetch the whole records.that is why i am planning to go with threads.
I want to implement the following logic

class have a boolean like isAnyRecLeft=true; and a vector accList.

create 10 threads at one shot and wait.

if any thread fetches records less than <100

exit the process. if not so create 10 more threads.

like this can i adopt this process .if so can you guide me to deploy this plan.


thanks and regrds
Tirupathi Rao.P
 
Naren Chivukula
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, if you really want to go with that approach knowing downs, it's up to you. I'd rather call sequentially in a for loop as it would not make any difference because you are calling the same web service.

So, what problems are you facing in implementing that? Isn't that straightforward to implement? All you have to do is to create threads and invoke web service.
 
TirupathiRao Pattapuraju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Naren Chivukula wrote:Okay, if you really want to go with that approach knowing downs, it's up to you. I'd rather call sequentially in a for loop as it would not make any difference because you are calling the same web service.

So, what problems are you facing in implementing that? Isn't that straightforward to implement? All you have to do is to create threads and invoke web service.




Thank you very much Naren..As you suggested i will stick to my legacy sequential for loop.

But i just want to give a try with threads to check whether it will be any value addition in terms of over all process time.


Thanks and Regards
Tirupathi Rao.P
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the information. It helped me best way. Thanks....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic