Comments (8)
Smooks should be initiated only once. Can you post the Java code which starts Smooks and filters the doc?
from smooks.
Hi @claudemamo ,
Thank you so much for the response.
We have a common function in Utility class for converting RAW EDI to XML.
The reason for calling convertToXML multiple is because the message content is different for FeedEntry.
public String convertToXml(String messageContent, String smookConfigPath) {
byte[] messageIn = messageContent.getBytes();
Locale defaultLocale = Locale.getDefault();
Locale.setDefault(new Locale("en", "IE"));
// Instantiate Smooks with the config...
Smooks smooks = new Smooks(smookConfigPath);
try {
// Create an exec context - no profiles....
ExecutionContext executionContext = smooks.createExecutionContext();
StringResult result = new StringResult();
smooks.filterSource(executionContext, new StreamSource(new ByteArrayInputStream(messageIn)), result);
Locale.setDefault(defaultLocale);
//smooks.close();
return result.getResult();
} catch (Exception Ex) {
logger.error(Ex.printStackTrace())
throw Ex;
} finally {
smooks.close();
}
}
This above common function is called from a ServiceClass=>
List < CompletableFuture < String >> futures = evaluateXMLFeed.entrySet().parallelStream().map(eachRecord - > CompletableFuture.supplyAsync(
() - > {
try {
String messageContent_PerKey = new String(evaluateXMLFeed.get(eachRecord.getKey()));
//Call to ConvertXML
String xmlText = utility.convertToXml(messageContent_PerKey, "/<ResourcesFolder>/smooks-config.xml");
//Processing Logic Further
return ("ProcessContent");
} catch (Exception ex) {
errorFiles.add(eachRecord.getKey());
Thread.currentThread().interrupt();
logger.error("Failed to process=>" + eachRecord.getKey() + ex.getMessage());
return "Error";
}
}, executor)).collect(Collectors.toList());
from smooks.
It appears to be a defect. I'll follow it up but, in the meantime, can you use Smook profiles instead? It should even lead to better performance.
from smooks.
Thank you @claudemamo for the suggestion. We tried that actually our conversion logic remain the for a specific type of payload and does not vary depending on the content. Any suggestion on when this fix will be be available ?
from smooks.
I might be misunderstanding the problem. If your Smooks configuration remains the same across executions, then you should construct Smooks once outside the parallelStream block. Only the createExecutionContext and filterSource methods need to be inside the block.
from smooks.
Hi @claudemamo , thank you!! i followed your recommendation and that results in below error . For single threaded execution it works fine.
Caused by: org.xml.sax.SAXException: SAX2 driver class org.smooks.cartridges.dfdl.parser.DfdlParser not found
java.lang.ClassNotFoundException: org.smooks.cartridges.dfdl.parser.DfdlParser
at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:230)
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:221)
at org.smooks.delivery.AbstractParser.createXMLReader(AbstractParser.java:313)
at org.smooks.delivery.sax.SAXParser.parse(SAXParser.java:89)
at org.smooks.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:112)
from smooks.
Please post the updated Java code Agnish along with the configs. I will try to reproduce it locally.
from smooks.
Closing stale issue.
from smooks.
Related Issues (20)
- error in opening zip file in Initialisation HOT 4
- Where is ConfigParam? HOT 1
- EDI message processing failed - expected to contain 2 fields. Actually contains 1 fields HOT 1
- Question: Smooks seems to scan all project dependencies - how do I prevent that? HOT 4
- Memory issue with edi to java parsing | smooks version: 2.0.0-RC1 HOT 2
- Class loader used for loading ContentHandlerFactory is not the same as the one set in ApplicationContext
- CSV Reader not escaping double quotes HOT 2
- How to map json to json HOT 3
- Smooks-all for 2.0 HOT 3
- Convert JSON to JSON without a Java Bean HOT 1
- Upgrade to atleast java 9 to use Jakarta EE 9 namespace HOT 3
- springboot 2.3 conflict HOT 2
- factory.toUNEdifact() BigDecimal Value... HOT 2
- cannot be cast to org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.SecurityManager HOT 1
- CVE-2023-51079 in mvel dependency HOT 1
- Selector matches the node despite the namespace URIs being different
- delegate-reader throws "com.fasterxml.aalto.WFCException: Invalid UTF-8" when writing multi-byte characters
- NoSuchFileException when instantiating Smooks HOT 3
- Regression in v2 when the last step in the selector has a predicate index
- <core:delegate-reader> doesn't properly rewrite the attribute xmlns=""
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smooks.