camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CAMEL-489) file component can't handle ArrayList Exchange body
Date Tue, 06 May 2008 05:01:43 GMT

    [ 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.


Mime
View raw message