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 Sun, 04 May 2008 16:31:43 GMT

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


Mime
View raw message