camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glen Mazza (JIRA)" <>
Subject [jira] Created: (CAMEL-489) file component can't handle ArrayList Exchange body
Date Fri, 02 May 2008 01:26:43 GMT
file component can't handle ArrayList Exchange body

                 Key: CAMEL-489
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 1.3.0
            Reporter: Glen Mazza
            Priority: Minor

For CXF usage, the exchange body needs to be an array list (or list of strings) to hold the
Web service request's parameters.  However file components are failing if that is the datatype
of the Exchange message.

The source file at the bottom runs fine, giving this output:

i is: 0
i is: 1
i is: 2
This was called - Body: 0
In file's process
This was called - Body: 1
In file's process
This was called - Body: 2
In file's process

However, if I change the one line of code below marked "----->"  with "params" instead
of "Hello!", this is the output:

i is: 0
This was called - Body: 0
i is: 1
i is: 2
This was called - Body: 1
This was called - Body: 2

The "In file's process" never appears, because for some reason the file component cannot handle
the fact that the Exchange body is a list array.  It appears that either the Camel code needs
to be changed to allow arraylists for file components, or some exception should be raised--it
presently just runs quietly, not giving the user the feedback that an invalid body type is

Source file:

package com.mycompany.camel;

import java.util.ArrayList;
import java.util.List;

import javax.jms.ConnectionFactory;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelTemplate;
import org.apache.camel.component.cxf.CxfConstants;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.impl.DefaultCamelContext;

 * Hello world!
public class CamelSample2 {
   private CamelSample2() {

   public static void main(String[] args) {
      CamelSample2 cs = new CamelSample2();
      try {;
      } catch (Exception e) {

   private void run() throws Exception {
      CamelContext context = new DefaultCamelContext();
      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
      context.addComponent("test-jms", JmsComponent

      context.addRoutes(new RouteBuilder() {
         public void configure() {

            from("test-jms:queue:test.queue").process(new Processor() {
               public void process(Exchange e) {
                   System.out.println("This was called - Body: " + e.getIn().getBody(String.class));
                   final List<String> params = new ArrayList<String>();
---->            e.getOut().setBody("Hello");  // params);
           }).to("file://testfile.txt").process(new Processor() {
              public void process(Exchange e) {
                 System.out.println("In file's process");
      CamelTemplate template = new CamelTemplate(context);
      for (int i = 0; i < 3; i++) {
         System.out.println("i is: " + i);
         template.sendBody("test-jms:queue:test.queue", "" + i);
      Thread.sleep(60000 * 3);  

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message