0

I need to implement a Java web service (on websphere) that in turn calls N other web services. I don't want to make it blocking so I was thinking in implementing a thread for each WS it call. Are there any caveats being a web service the parent of the threads ? (The use of a queueing technology for this solution is not an option).

Thanks

1 Answer 1

1

it is certainly doable. the only real caveat is that you are going to have to

1) make sure that all the information the threads need gets passed in. Depending on the technologies you are using, information gets bound to the current thread via ThreadLocal, so you need to make sure the children have everything they need.

2) Coordinating the responses. Might not be an issue, but if you need to coordinate the responses you will need to do something. Also, when the original web service call gets invoked, can you return a response immediately or do you need to wait till the other webservices are invoked?

3) Error conditions. If one of the child web service calls fails, what do you need to do? That depends on your requirements.

Note that invoking N webservices calls shouldn't take too long if N is small. I would try it synchronously before going thru the pain of getting an asynchronous solution, unless you are sure up front that this is not an option.

Sign up to request clarification or add additional context in comments.

2 Comments

Another thing you have to watch out for is to limit the number of threads, so a threadpool is probably better than starting a new thread for each request.
Thanks for your replies. About points 2 and 3, the idea is that after a timeout that's common to all the WS that will be called, the calling WS will assume default values and return a timely response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.