from("myRouteId")
.process(exchange -> {
ObjectMapper mapper = new ObjectMapper();
Map<String, String> map = mapper.convertValue(new SimplePojo(), Map.class);
exchange.getIn().setBody(map);
})
.marshal(new CsvDataFormat().setDelimiter(';').setQuoteMode(QuoteMode.ALL))
.to("file:out/?fileName=ouput-file.csv");
Created
June 7, 2021 22:02
-
-
Save caisback/72c8ea83ffeb46897a2fd8be77a85896 to your computer and use it in GitHub Desktop.
Apache Camel Bindy!
Author
Author
Solved: unmarshall issue:
https://developer.jboss.org/thread/273917
<!-- Working BINDY code as of 08June2021 07:49 -->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint https://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<!--
The namespace for the camelContext element in Blueprint is 'https://camel.apache.org/schema/blueprint'. Additionally,
we can also define namespace prefixes we want to use them in the XPath expressions in our CBR.
While it is not required to assign id's to the <camelContext/> and <route/> elements, it is a good idea
to set those for runtime management purposes (logging, JMX MBeans, ...)
-->
<reference id="bindy"
interface="org.apache.camel.spi.DataFormatResolver" timeout="30000"/>
<camelContext id="_context1" xmlns="http://camel.apache.org/schema/blueprint">
<route id="_routeLeaveEligibilityRamcoActuatorGetEmployees">
<from id="_from1" uri="file:work/ramco/LeaveEligibility/out">
<description>file:work/ramco/LeaveEligibility/out</description>
</from>
<log id="_log1" message="Message $body: ${body}"/>
<unmarshal id="_unmarshal11">
<bindy
classType="ph.edu.dlsu.esb.bpms.leaveeligibility.ramcoactuator.getemployees.CsvEmployee" type="Csv"/>
</unmarshal>
<log id="_log2" message="Unmarshall ${body}"/>
</route>
</camelContext>
</blueprint>
Author
- update pom.xml
<Bundle-SymbolicName>YOUR Bundle SymbolicName Here!</Bundle-SymbolicName>
<Bundle-Name>[YOUR Bundle-Name Here!]</Bundle-Name>
<import-package>org.apache.camel.spi.DataFormatResolver;provide:=true,*</import-package>
- update blueprint.xml
<reference id="bindy" interface="org.apache.camel.spi.DataFormatResolver" timeout="30000"/>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/39528658/camel-bindy-how-to-escape-double-quotes-when-marshalling-csv