PA165 Integration Lab - Apache Camel Filip Nguyen Lab Software Architectures and Information Systems Seminar 14 December 16, 2014 Today ● Clone lab project ● Answer questions using the source code ● You may do some advanced stuff later Source code ● https://github.com/nguyenfilip/pa165camel.git ● Contains solved/done seminar lab ○ camel-standalone ○ camel-webapp ● Run StandaloneMain or SpringMain then you have 300 seconds to put orders (xml files) into folders ○ new-input-orders ○ old-input-orders Questions ● What is asserted in RetailStoreRoutesTest? Can you break each assert by modifying the Camel Route? ● What is JaxbBeanProcessor? ● What is JaxbDataFormat? ● StandaloneMain creates newArtificialMessage on startup, can you modify the main so that this doesnt happen? Standardization ● We want to add element around all the items Skis20 Skis220 Enrichment ● We want to add element 17-12-2013 Skis20 Skis220 Problem ● We have a folder with orders in old format as well as folder with orders in new format (but without “created”) New format: Skis20 Skis220 Another Problem ● Also, we want to allow our customers to submit orders using ○ Web Services ○ CSV files Orders formats ● Inspect camel-standalone/orders directory Camel in Standalone Java ● Inspect pa165-camel-lab/pom.xml ● mvn exec:java -Dexec.mainClass=cz.pa165.mains.StandaloneMain ● StandaloneMain.java ● CamelContext ● Watch out for following folders in camel- standalone ○ new-input-orders ○ old-input-orders ○ outputDir ○ errored File Component ● Various parameters: ○ ?recursive=true&flatten=true" ● CamelFileName header Validator ● Validates agaist XSD ● orderSchema.xsd ● Searches the XSD on classpath JAXB ● JaxbDataFormat ● .unmarshal(jaxb) ● .marshal(jaxb) Camel in Web App ● inspect camel-web/pom.xml ● spring-ws-context.xml Camel + Spring WS ● web.xml ● spring-ws-context.xml DefaultWsdl11Definition ● Contract for web service in: src/main/webapp/WEB-INF/order.xsd ● JAXB classes are used to map request/response What we need to do ● Convert request to our format (old or new xml format) ● Route the converted message to our existing commonRoute ● We need to return a sensible response to the Web Service Client Advanced: Create a new CSV route ● This should be done in standalone Camel ● Assume we are getting orders in CSV format from yet another folder ● Use CSV camel component and convert the csv into XML format :-) , Making a Request ● tomcat7:run in camel-web ● modify request.xml curl -H "Content-Type: text/xml" -X POST -d @request.xml http://localhost:8080/camel/order