Santhosh S
Santhosh S

Reputation: 1159

XML processing and creating a resource in parallel in Java

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 ?

Upvotes: 0

Views: 129

Answers (1)

Penkov Vladimir
Penkov Vladimir

Reputation: 939

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

Upvotes: 1

Related Questions