You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Glen Mazza (JIRA)" <ji...@apache.org> on 2008/05/02 03:26:43 UTC

[jira] Created: (CAMEL-489) file component can't handle ArrayList Exchange body

file component can't handle ArrayList Exchange body
---------------------------------------------------

                 Key: CAMEL-489
                 URL: https://issues.apache.org/activemq/browse/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 given.

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 {
         cs.run();
      } catch (Exception e) {
      }
   }

   private void run() throws Exception {
      CamelContext context = new DefaultCamelContext();
      
      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
            "vm://localhost?broker.persistent=false");
      context.addComponent("test-jms", JmsComponent
            .jmsComponentAutoAcknowledge(connectionFactory));

      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>();
                   params.add(e.getIn().getBody(String.class));
---->            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);
      context.start();
      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);  
      context.stop();
   }
}



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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42548#action_42548 ] 

Claus Ibsen commented on CAMEL-489:
-----------------------------------

Glen we are in bad luck recently. The Apache infrastructure changed hardware for the SVN server. So I guess it has the influence of the wiki pages not showing code snippets from the source files.

To enable logging you could do as I (I prefer log4j anytime over Java Util Logging).
- Add log4j.jar to your classpath
- copy a log4j.properties to the root folder where your compiler have generated the .class files of your source code (lo4j.properties must be on the classpath)
You can grap a log4j.properties from the Camel distributions from the examples folder such as: \examples\camel-example-bam\src\main\resources

In the log4j.properties file you can change the log levels from INFO to DEBUG to get much more verbose logging. But the error should be reported at ERROR level so you should see it anyway.

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42549#action_42549 ] 

Claus Ibsen commented on CAMEL-489:
-----------------------------------

The code snippets for the DeadLetterChannel can be viewed using SVN viewer (viewvc)

http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java?view=markup

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42543#action_42543 ] 

Claus Ibsen commented on CAMEL-489:
-----------------------------------

CAMEL-84 is the ticket for the error reporting of no type converters found.

However the problem is that camel-core and all now is used to the fact that some conversions should return null. I am working on a patch. See CAMEL-84

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42542#action_42542 ] 

Claus Ibsen commented on CAMEL-489:
-----------------------------------

It is the problem with type converters. But in Glens use-case the DeadLetterChannel will handle the problem and Camel *does* indeed report an error on this

{code}
2008-05-05 06:09:59,234 [main           ] ERROR DeadLetterChannel              - Failed delivery for exchangeId: ID-claus-acer/1882-1209960593968/0-0. On delivery attempt: 5 caught: org.apache.camel.InvalidPayloadException: No in body available of type: java.io.InputStream but has value: [Hello World] of type: java.util.ArrayList on: FileMessage: issue489 on the exchange: Exchange[FileMessage: issue489]
org.apache.camel.InvalidPayloadException: No in body available of type: java.io.InputStream but has value: [Hello World] of type: java.util.ArrayList on: FileMessage: issue489 on the exchange: Exchange[FileMessage: issue489]
	at org.apache.camel.util.ExchangeHelper.getMandatoryInBody(ExchangeHelper.java:127)
{code}

Glen you should check your log files for such kind of error message as above InvalidPayloadException.
The exchange is moved to the default error queue (see wiki documentation elsewhere on the DeadLetterChannel).

Glen if you need to be able to stream an array of String to a file then you can add your own converter that does the needed conversion for the FileProducer

{code}
    @Converter
    public static InputStream toString(List<String> params) {
        StringBuffer sb = new StringBuffer();
        for (String s : params) {
            sb.append(s).append("\n");
        }
        return IOConverter.toInputStream(sb.toString());
    }
{code}

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Closed: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen closed CAMEL-489.
-----------------------------


> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42539#action_42539 ] 

Claus Ibsen commented on CAMEL-489:
-----------------------------------

I agree with Glen that Camel should have thrown somekind of error when producing the file as it could not generate the content.

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42528#action_42528 ] 

Willem Jiang commented on CAMEL-489:
------------------------------------

Hi Glen,

I think you could add another process between camel-cxf endpoint and camel-file endpoint, 
this process could turn the list into the common object which could be consumed by camel-file endpoint.

Regards,

Willem


> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Glen Mazza (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42547#action_42547 ] 

Glen Mazza commented on CAMEL-489:
----------------------------------

Quote: "Glen you should check your log files for such kind of error message as above InvalidPayloadException."

Where are my "log files"?  I'm not explicitly configuring any logging here--does anyone have any simple samples of configuring logging?  The camel page[1], just provides generic links to commons-logging and log4J, which isn't very convenient or helpful.  (Also, there seems to be something wrong with the website on the DeadLetterChannel[2] (and other pages as well)--code is no longer being shown, it just says: "An error occurred: Connection refused. The system administrator has been notified.")

[1] http://activemq.apache.org/camel/how-do-i-change-the-logging.html
[2] http://activemq.apache.org/camel/dead-letter-channel.html


> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42541#action_42541 ] 

Claus Ibsen commented on CAMEL-489:
-----------------------------------

If this is really the case then I do think the type converter system should handle it and throw a exception since it could not convert it. Dont we have a ticket for this already?

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Issue Comment Edited: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Glen Mazza (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42529#action_42529 ] 

gmazza edited comment on CAMEL-489 at 5/4/08 7:19 AM:
----------------------------------------------------------

Yes, I probably could do that.  But I don't think that fixes the real problem here -- should Camel really just quietly ignore the problem and keep running without giving the needed "In file's process" output?  I would think that if Camel can't process the type, either it (a) goes ahead and prints "In file's process" anyway or (b) throws an exception listing the problem so the user can understand why he's not getting that message--IllegalStateException, perhaps.


      was (Author: gmazza):
    Yes, I probably could do that.  But I don't think that fixes the real problem here--should Camel really just quietly ignore the problem and keep running without giving the needed "In file's process" output?  I would think that if Camel can't process the type, either it (a) goes ahead and prints "In file's process" anyway or (b) throws an exception listing the problem so the user can understand why he's not getting that message--IllegalStateException, perhaps.

  
> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Glen Mazza (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42529#action_42529 ] 

Glen Mazza commented on CAMEL-489:
----------------------------------

Yes, I probably could do that.  But I don't think that fixes the real problem here--should Camel really just quietly ignore the problem and keep running without giving the needed "In file's process" output?  I would think that if Camel can't process the type, either it (a) goes ahead and prints "In file's process" anyway or (b) throws an exception listing the problem so the user can understand why he's not getting that message--IllegalStateException, perhaps.


> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42538#action_42538 ] 

Claus Ibsen commented on CAMEL-489:
-----------------------------------

I have reproduced the problem as a unit test. I do think its because there is no type converter that converts the list of string to something that can be streamed to the file.

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42540#action_42540 ] 

Willem Jiang commented on CAMEL-489:
------------------------------------

Yes, the type converter will return null if there is no right convert method to be called. 
I agree we could add some check point in the file producer to throw the exception when it can't generate the file content.
It could also be the common scenario for the other endpoints.

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Updated: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Hadrian Zbarcea (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hadrian Zbarcea updated CAMEL-489:
----------------------------------

    Fix Version/s: 1.4.0

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 1.4.0
>
>
> 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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Updated: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-489:
------------------------------

    Description: 
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 given.

Source file:
{code}
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 {
         cs.run();
      } catch (Exception e) {
      }
   }

   private void run() throws Exception {
      CamelContext context = new DefaultCamelContext();
      
      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
            "vm://localhost?broker.persistent=false");
      context.addComponent("test-jms", JmsComponent
            .jmsComponentAutoAcknowledge(connectionFactory));

      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>();
                   params.add(e.getIn().getBody(String.class));
---->            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);
      context.start();
      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);  
      context.stop();
   }
}
{code}


  was:
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 given.

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 {
         cs.run();
      } catch (Exception e) {
      }
   }

   private void run() throws Exception {
      CamelContext context = new DefaultCamelContext();
      
      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
            "vm://localhost?broker.persistent=false");
      context.addComponent("test-jms", JmsComponent
            .jmsComponentAutoAcknowledge(connectionFactory));

      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>();
                   params.add(e.getIn().getBody(String.class));
---->            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);
      context.start();
      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);  
      context.stop();
   }
}




Added code block in description

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Glen Mazza (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42553#action_42553 ] 

Glen Mazza commented on CAMEL-489:
----------------------------------

If I understand you correctly, CAMEL-84 (whenever it's fixed) will throw an exception when it cannot find the correct converter type.  That will allow newbies like me to be able to visually see this error from a command-line terminal window without first needing to configure logging.  That sounds good.  If so, this issue can be closed or marked as a duplicate of CAMEL-84.  Also, I updated the logging page with your instructions above so others can quickly reference it.  Thanks!






> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Assigned: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-489:
---------------------------------

    Assignee: Claus Ibsen

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42550#action_42550 ] 

Claus Ibsen commented on CAMEL-489:
-----------------------------------

Glen if you are able to see the ERROR in the log files / system out console etc.

Then you should try adding the type converter shown above the does the conversions from List<String> to InputStream as the FileComponent expects.
Then the ERROR should be gone and you are good.

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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


[jira] Resolved: (CAMEL-489) file component can't handle ArrayList Exchange body

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-489.
-------------------------------

    Resolution: Won't Fix

Hi Glenn

Glad you got it working with the logging. And nice addition to the wiki - thanks ;)

I have closed this as wont fix as it is basically you as the end user that uses a custom object type on the body.
The resolution is to provide your own conversion using the annotation tags etc.

> file component can't handle ArrayList Exchange body
> ---------------------------------------------------
>
>                 Key: CAMEL-489
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-489
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Glen Mazza
>            Assignee: Claus Ibsen
>            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 given.
> Source file:
> {code}
> 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 {
>          cs.run();
>       } catch (Exception e) {
>       }
>    }
>    private void run() throws Exception {
>       CamelContext context = new DefaultCamelContext();
>       
>       ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
>             "vm://localhost?broker.persistent=false");
>       context.addComponent("test-jms", JmsComponent
>             .jmsComponentAutoAcknowledge(connectionFactory));
>       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>();
>                    params.add(e.getIn().getBody(String.class));
> ---->            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);
>       context.start();
>       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);  
>       context.stop();
>    }
> }
> {code}

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