Skip to content

Instantly share code, notes, and snippets.

@caisback
Created June 7, 2021 22:02
Show Gist options
  • Select an option

  • Save caisback/72c8ea83ffeb46897a2fd8be77a85896 to your computer and use it in GitHub Desktop.

Select an option

Save caisback/72c8ea83ffeb46897a2fd8be77a85896 to your computer and use it in GitHub Desktop.
Apache Camel Bindy!
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");
@caisback

caisback commented Jun 7, 2021

Copy link
Copy Markdown
Author

@caisback

caisback commented Jun 7, 2021

Copy link
Copy Markdown
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>


@caisback

caisback commented Jun 12, 2021

Copy link
Copy Markdown
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