hello there,
i am using camunda camel extension to build a file listener. the directory is already being watched and moves files when they arrive. therefore i want to go a step further and add some more logic to it.
depending on what file is incoming a different process should start. i was trying to decide this by the following choice():
@Override
public void configure() throws Exception {
log.info("=======================");
log.info("Configuring Routes");
from("file://" + SOURCE_FOLDER)
.choice()
.when(header("CamelFileName").contains("Bestellung"))
.setProperty("creditor", xpath("*//Kunde/text()", String.class))
.to("file://" + ORDER_FOLDER)
.to("camunda-bpm:start?processDefinitionKey=Process_ReceivedOrder")
.when(header("CamelFileName").contains("Rechnung"))
.setProperty("creditor", xpath("*//Kunde/text()", String.class))
.to("file://" + INVOICE_FOLDER)
.to("camunda-bpm:start?processDefinitionKey=Process_ReceivedInvoice")
.otherwise()
.to("file://" + MOVED_FOLDER)
.end().process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
Message message = exchange.getIn();
exchange.setOut(message);
System.out.println("===============");
System.out.println("Processing file: "+exchange.getProperty("CamelFileExchangeFile"));
System.out.println("===============");
}
});
}
when i provide a file, no order nor invoice which means otherwise case, it can process the xml file. but when i try to place a file which name contains “Bestellung/Rechnung” (when-cases) it always end up saying unknown content type. but that doesnt make sense to me because the “otherwise” file is also xml and can be read. i copied my Rechnung.xml-example and renamed it to R3chnung.xml. in this case the content is also NOT unknown… i havent found anything that makes me understand why a simple choice() screws up the content type part… i thought about to create a converter but this still doesnt make me understand why some xml files can be read and some not.
here is my terminal:
16:32:43,347 INFO [org.jboss.as] (Controller Boot Thread) {} WFLYSRV0025: WildFly Full 18.0.0.Final (WildFly Core 10.0.0.Final) started in 7756ms - Started 904 of 1133 services (400 services are lazy, passive or on-demand)
16:32:59,677 INFO [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} ===============
16:32:59,677 INFO [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} Processing file: GenericFile[X:\OV\Beispieldaten\Income\Sonstiges.xml]
16:32:59,679 INFO [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} ===============
16:33:11,216 INFO [org.apache.camel.builder.xml.XPathBuilder] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} Created default XPathFactory __redirected.__XPathFactory@4bee28cc
16:33:11,230 WARNING [org.camunda.bpm.camel.common.ExchangeUtils] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} unkown type of camel body - not handed over to process engine: class org.apache.camel.component.file.GenericFile
16:33:11,266 INFO [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} ===============
16:33:11,266 INFO [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} Processing file: GenericFile[X:\OV\Beispieldaten\Income\Rechnung.xml]
16:33:11,269 INFO [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} ===============
16:33:19,796 INFO [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} ===============
16:33:19,796 INFO [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} Processing file: GenericFile[X:\OV\Beispieldaten\Income\R3chnung.xml]
16:33:19,800 INFO [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} ===============
I have the following dependencies:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<camunda.version>7.7.0</camunda.version>
<camunda.camel.version>0.5</camunda.camel.version>
<camel.version>2.24.2</camel.version>
<jboss.version>7.2.1.Final</jboss.version>
</properties>
<dependencies>
<dependency>
<groupId>org.camunda.spin</groupId>
<artifactId>camunda-spin-core</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<version>${camel.version}</version>
<exclusions>
<exclusion>
<artifactId>jaxb-impl</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jacksonxml</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-cdi</artifactId>
<version>7.13.0-alpha2</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.framework</artifactId>
<version>1.9.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- process engine -->
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
<version>${camunda.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.javaee</groupId>
<artifactId>camunda-ejb-client</artifactId>
<version>${camunda.version}</version>
<scope>compile</scope>
</dependency>
<!-- camunda BPM Apache Camel Integration -->
<dependency>
<groupId>org.camunda.bpm.extension.camel</groupId>
<artifactId>camunda-bpm-camel-cdi</artifactId>
<version>${camunda.camel.version}</version>
<exclusions>
<exclusion>
<artifactId>jaxb-impl</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.camunda.bpm.extension.camel</groupId>
<artifactId>camunda-bpm-camel-blueprint</artifactId>
<version>0.6</version>
</dependency>
<!-- Camel Components -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cdi</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<version>${camel.version}</version>
<exclusions>
<exclusion>
<artifactId>jaxb-impl</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>2.0.0.Final</version>
<scope>provided</scope>
<type>pom</type>
<exclusions>
<exclusion>
<artifactId>xalan</artifactId>
<groupId>org.apache.xalan</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
i orientated myself here: https://github.com/camunda/camunda-bpm-camel
i had a look at the other camel-questions but could not find a solution for my problem though… does anybody see something i dont? what am i doing wrong? should i try to look for another way instead of choice()?
thanks in advance for taking time to read my post.