简体   繁体   English

XML 在 Java 中并行处理和创建资源

[英]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.输入是 XML。 I need to parse the XML, create the Resources in parallel and update the responses in the Ouputs.我需要解析 XML,并行创建资源并更新输出中的响应。

<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.每个ResourceRequests都由特定的类处理。

What is the best way to create Resources in parallel, aggregate the results and update the xml?并行创建资源、汇总结果并更新 xml 的最佳方法是什么?

you will parse xml file in single thread anyway because the file is linear.无论如何,您将在单线程中解析 xml 文件,因为该文件是线性的。 but you can collect you parsers for each CreateResourceCRequest in a set and start them all in parallel threads after parsing file但是您可以为一组中的每个 CreateResourceCRequest 收集解析器,并在解析文件后在并行线程中启动它们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM