JaxbDataFormat dataFormat = new JaxbDataFormat(); dataFormat.setContextPath("com.somepath.xml"); from("jms:topic:myTopic?transacted=true&connectionFactory=myJmsConnectionFactory") .transacted() .unmarshal(dataFormat) .routeId("myRouteId")
JaxbDataFormat jaxb = new JaxbDataFormat("com.example.foobar"); from("ftp://user:pass@server:21/inbox") .unmarshal().zip() .split(xpath("//foo")) .unmarshal(jaxb) .to("jpa:com.example.foobar.Foo")
public TransformingMessagesRoute() { xmlJsonFormat = new XmlJsonDataFormat(); xmlJsonFormat.setForceTopLevelObject(true); xmlJsonFormat.setTrimSpaces(true); xmlJsonFormat.setSkipNamespaces(true); xmlJsonFormat.setRemoveNamespacePrefixes(true); }
@Override public void configure() throws Exception { JaxbDataFormat jdf = new JaxbDataFormat(); jdf.setContextPath("org.kie.camel.embedded.camel.testdomain"); jdf.setPrettyPrint(true); from("direct:test-session").policy(new KiePolicy()).unmarshal(jdf).to("kie-local://ksession").marshal(jdf); from("direct:unmarshall").policy(new KiePolicy()).unmarshal(jdf); from("direct:marshall").policy(new KiePolicy()).marshal(jdf); } });
public Object deserialize(Writable record) throws SerDeException { Text text = (Text) record; String[] valArray = text.toString().split(","); CustomDataFormat dataObject = new CustomDataFormat(); dataObject.setFname(valArray[0]); dataObject.setLname(valArray[1]); rows.set(0, dataObject.getFname()); rows.set(1, dataObject.getLname()); return rows; }
from(source) .process(exchange -> decryptIfEncrypted(pgpEncryptionDetails)) to(destination); ProcessDefinition decryptIfEncrypted(PGPEncryptionDetails pgpEncryptionDetails) { if (isPgpEncryped()) { PGPDataFormat pgpDataFormat = new PGPDataFormat(); pgpDataFormat.setKeyFileName(pgpEncryptionDetails.getPrivateKeyPath()); pgpDataFormat.setPassword(pgpEncryptionDetails.getPassphrase()); pgpDataFormat.setKeyUserid(pgpEncryptionDetails.getUserId()); return new ProcessDefinition().unmarshal(pgpDataFormat); } return new ProcessDefinition(); }
CsvDataFormat csv = new CsvDataFormat(); CSVConfig config = new CSVConfig(); config.setDelimiter('|'); // your delimiter here csv.setConfig(config); from("timer://foo?fixedRate=true&delay=0&period=2000"). to("http://graph.facebook.com/nike").unmarshal().json(JsonLibrary.Gson,Map.class) .marshal(csv).convertBodyTo(String.class).to("file:target/output");
final CsvDataFormat csv = new CsvDataFormat(";"); csv.setLazyLoad(true); csv.setSkipFirstLine(true); from(in).unmarshal(csv).split(body()).streaming().parallelProcessing() .bean(validator, "validateNumber") .filter(header(ValidateProcess.Valid).isEqualTo(true)) .throttle(tps).bean(validator, "validate") .marshal().csv() .to(out).log("done.").end();
Map<String, DataFormatDefinition> dataFormats = getContext().getDataFormats(); if (dataFormats == null) { dataFormats = new HashMap<>(); } dataFormats.put("yourFormat", new DataFormatDefinition(new CustomDataFormat())); restConfiguration()....jsonDataFormat("yourFormat")
JaxbDataFormat jaxb = new JaxbDataFormat("add.your.namespace.to.the.ObjectFactory"); jaxb.setPrettyPrint(true); from("seda:out?concurrentConsumers=20") .process(new process_1()) .marshal(jaxb) .process(new process_2());
/** * Creates a JAXB data format for marshalling and unmarshalling * the specified class to/from its native XML representation. * * @param xmlClass the class that this data format will be able to marshal and unmarshal * @return the Camel {@link DataFormatDefinition} instance for use in routes */ public static JaxbDataFormat jaxb(Class<?> xmlClass) { JaxbDataFormat dataFormat = new JaxbDataFormat(false); dataFormat.setContextPath(xmlClass.getPackage().getName()); return dataFormat; }
final CsvDataFormat format = new CsvDataFormat(); format.setUseMaps(true); format.setDelimiter(","); from("direct:start") .unmarshal(format) .process(new Processor() { @Override public void process(final Exchange exchange) throws Exception { final List<Map<String, String>> body = exchange.getIn().getBody(List.class); // transform and/or validate data... });
DataFormat jaxb = new JaxbDataFormat("com.acme.model"); from("activemq:My.Queue"). unmarshal(jaxb). to("mqseries:Another.Queue");
final CsvDataFormat format = new CsvDataFormat(); format.setUseMaps(true); format.setDelimiter(","); from("direct:start") .unmarshal(format) .process(new Processor() { @Override public void process(final Exchange exchange) throws Exception { final List<Map<String, String>> body = exchange.getIn().getBody(List.class); for (final Map<String, String> row : body) { LOG.info("new row: {}", row); } } });
DataFormat jaxb = new JaxbDataFormat("com.acme.model"); from("activemq:My.Queue"). unmarshal(jaxb). to("mqseries:Another.Queue");
DataFormat jaxb = new JaxbDataFormat("com.acme.model");
DataFormat jaxb1 = new JaxbDataFormat("foo.bar:bar.foo");
@Override protected RouteBuilder createRouteBuilder() throws Exception { routeBuilder = new RouteBuilder() { public void configure() throws Exception { JaxbDataFormat def = new JaxbDataFormat(); def.setPrettyPrint(true); def.setContextPath("org.drools.pipeline.camel"); from("direct:test-with-session").policy(new DroolsPolicy()). unmarshal(def).to("drools:node/ksession1").marshal(def); } }; return routeBuilder; }
@Override protected RouteBuilder createRouteBuilder() throws Exception { routeBuilder = new RouteBuilder() { public void configure() throws Exception { JaxbDataFormat def = new JaxbDataFormat(); def.setPrettyPrint(true); // TODO does not work: def.setContextPath( "org.drools.camel.testdomain:org.drools.pipeline.camel" ); def.setContextPath("org.drools.pipeline.camel"); from("direct:test-with-session").policy(new DroolsPolicy()).unmarshal(def).to("drools:node/ksession1").marshal(def); from("direct:test-no-session").policy(new DroolsPolicy()).unmarshal(def).to("drools:node").marshal(def); } }; return routeBuilder; }
@Override protected RouteBuilder createRouteBuilder() throws Exception { routeBuilder = new RouteBuilder() { public void configure() throws Exception { JaxbDataFormat def = new JaxbDataFormat(); def.setPrettyPrint(true); // TODO does not work: def.setContextPath( "org.drools.camel.testdomain:org.drools.pipeline.camel" ); def.setContextPath("org.drools.pipeline.camel"); from("direct:test-with-session").policy(new DroolsPolicy()). unmarshal(def).to("drools:node/ksession1").marshal(def); } }; return routeBuilder; } }