0

I am writing a app, which has to create multiple Resources. The input is a XML. I need to parse the XML, create the Resources in parallel and update the responses in the Ouputs.

<Components>
    <Resources>
        <CreateResourceARequest> ...</CreateResourceARequest>
        <CreateResourceBRequest>...</CreateResourceBRequest>
        <CreateResourceCRequest>...</CreateResourceCRequest>
    </Resources>
    <Outputs>
        <CreateResourceAResponse>...</CreateResourceAResponse>
        <CreateResourceBResponse>...</CreateResourceBResponse>
        <CreateResourceCResponse>...</CreateResourceCResponse>
    </Outputs>
<Components>    

Each of the ResourceRequests are handled by a specific Classes.

What is the best way to create Resources in parallel, aggregate the results and update the xml ?

1
  • 4
    I'm sorry, but what do you mean by "in parallel" here? Commented Jul 4, 2011 at 16:13

1 Answer 1

1

you will parse xml file in single thread anyway because the file is linear. but you can collect you parsers for each CreateResourceCRequest in a set and start them all in parallel threads after parsing file

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

2 Comments

sometimes I need to ensure that a resource needs to be created before other resources are created. How do I ensure that ?
exec = Executors.newCachedThreadPool(); exec.execute(new CreateResourceA(input)); exec.execute(new CreateResourceB(input)); exec.execute(new CreateResourceB(input)); exec.shutdown(); while (!exec.isTerminated()){ logger.debug("some tasks are still running"); } ----- currently I am doing it this way, but this does not ensure ResourceA to be created before ResourceB.

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.