You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bruno Dusausoy <bd...@yp5.be> on 2010/07/06 14:02:18 UTC

File component behavior

Hi,

I'm new to both Camel and EIP so maybe my question/problem is dumb ;).

I have a route defined in Spring as this :
    
    <!-- ActiveMQ beans and usual stuff -->

    <bean id="uploadBean"
class="be.ucm.career.quarterly.upload.UploadBean"/>
    
    <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
        <camel:package>foo.bar</camel:package>
        <camel:route>
            <camel:from uri="file:src/data?noop=true&amp;delay=30000" />
            <camel:bean ref="uploadBean"/>
            <camel:to uri="jms:output" />
        </camel:route>
    </camel:camelContext>

The implementation of "uploadBean" :

public class UploadBean {

	@Handler
	public String upload(@XPath("configuration/loopCount/text()")String
chunkSize) {
		
		System.out.println("Chunk size is : " + chunkSize);
		return "FOO_123";
	}
}

When launching the project with "mvn camel:run", I get this :

[...]
// INFO output
[...]
Chunk size is : 100
[src/data?delay=30000&noop=true] BrokerService                  INFO 
Using Persistence Adapter: AMQPersistenceAdapter(activemq-data\localhost)
[src/data?delay=30000&noop=true] AMQPersistenceAdapter          INFO 
AMQStore starting using directory: activemq-data\localhost
[src/data?delay=30000&noop=true] KahaStore                      INFO  Kaha
Store using data directory activemq-data\localhost\kr-store\state
[src/data?delay=30000&noop=true] AMQPersistenceAdapter          INFO 
Active data files: [1]
[src/data?delay=30000&noop=true] BrokerService                  INFO 
ActiveMQ 5.2.0 JMS Message Broker (localhost) is starting
[src/data?delay=30000&noop=true] BrokerService                  INFO  For
help or more information please see: http://activemq.apache.org/
[                 JMX connector] ManagementContext              INFO  JMX
consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
[src/data?delay=30000&noop=true] KahaStore                      INFO  Kaha
Store using data directory activemq-data\localhost\kr-store\data
[src/data?delay=30000&noop=true] BrokerService                  INFO 
ActiveMQ JMS Message Broker (localhost,
ID:100WCTI150-2821-1278413932666-0:0) started
[src/data?delay=30000&noop=true] TransportConnector             INFO 
Connector vm://localhost Started
[src/data?delay=30000&noop=true] TransportConnector             INFO 
Connector vm://localhost Stopped
[src/data?delay=30000&noop=true] BrokerService                  INFO 
ActiveMQ Message Broker (localhost, ID:100WCTI150-2821-1278413932666-0:0)
is shutting down
[src/data?delay=30000&noop=true] BrokerService                  INFO 
ActiveMQ JMS Message Broker (localhost,
ID:100WCTI150-2821-1278413932666-0:0) stopped
[Fatal Error] output.txt:1:1: Content is not allowed in prolog.
[Fatal Error] :1:1: Content is not allowed in prolog.
[src/data?delay=30000&noop=true] DefaultErrorHandler            ERROR
Failed delivery for exchangeId: b109fe1a-964e-4c70-91b0-bba46fb77766.
Exhausted after delivery attempt: 1 caught:
org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
configuration/loopCount/text(). Reason:
javax.xml.xpath.XPathExpressionException
org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
configuration/loopCount/text(). Reason:
javax.xml.xpath.XPathExpressionException
[...]
// STACK TRACE
[src/data?delay=30000&noop=true] GenericFileOnCompletion        WARN 
Rollback file strategy:
org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy@b9237a
for file: GenericFile[output.txt]

I'm wondering why I get this message, since the XPath is correct : you can
see the output of the method called on the bean at the beginning the
aforementioned snippet.
Moreover, I don't know where did the file component get this "output.txt"
file... :-/

The input.xml file is quite simple :

<?xml version="1.0"?>
<configuration>
    <loopCount>100</loopCount>
</configuration>

Can someone tell me what I'm doing wrong ?

Regards.
-- 
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

Re: AW: File component behavior

Posted by Bruno Dusausoy <bd...@yp5.be>.
On Tue, 6 Jul 2010 15:19:14 +0200, Charles Moulliard
<cm...@gmail.com>
wrote:
> The syntax is not correct
> 
>  <camel:to uri="jms:output" />
> 
> -->
> 
>  <camel:to uri="jms:queue:output" />
> 

Thanks a lot !

Regards.

-- 
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

Re: AW: File component behavior

Posted by Charles Moulliard <cm...@gmail.com>.
The syntax is not correct

 <camel:to uri="jms:output" />

-->

 <camel:to uri="jms:queue:output" />

KR,

Charles Moulliard

Senior Enterprise Architect (J2EE, .NET, SOA)
Apache Camel - ServiceMix Committer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Blog : http://cmoulliard.blogspot.com |  Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard | Skype: cmoulliard



On Tue, Jul 6, 2010 at 2:26 PM, Bruno Dusausoy <bd...@yp5.be> wrote:
> On Tue, 6 Jul 2010 14:21:23 +0200, Schneider Christian
> <Ch...@enbw.com> wrote:
>> Hi Bruno,
>>
>> I somtime encountered the error Content not allowed in prolog. This
> always
>> happened when the xml parser read a file that contained no valid xml. So
> it
>> seems to me you have a file output.txt somewhere that is read and
> contains
>> no valid xml.
>>
>> You could try to put a bean after from that simply receives an Exchange
> in
>> a method. So you can debug into this and see where the file comes from.
>>
>
> Ok, thanks.
>
> --
> Bruno Dusausoy
> YP5 Software
> --
> Pensez environnement : limitez l'impression de ce mail.
> Please don't print this e-mail unless you really need to.
>

Re: AW: File component behavior

Posted by Bruno Dusausoy <bd...@yp5.be>.
On Tue, 6 Jul 2010 14:21:23 +0200, Schneider Christian
<Ch...@enbw.com> wrote:
> Hi Bruno,
> 
> I somtime encountered the error Content not allowed in prolog. This
always
> happened when the xml parser read a file that contained no valid xml. So
it
> seems to me you have a file output.txt somewhere that is read and
contains
> no valid xml.
> 
> You could try to put a bean after from that simply receives an Exchange
in
> a method. So you can debug into this and see where the file comes from.
> 

Ok, thanks.

-- 
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

AW: File component behavior

Posted by Schneider Christian <Ch...@enbw.com>.
Hi Bruno,

I somtime encountered the error Content not allowed in prolog. This always happened when the xml parser read a file that contained no valid xml. So it seems to me you have a file output.txt somewhere that is read and contains no valid xml.

You could try to put a bean after from that simply receives an Exchange in a method. So you can debug into this and see where the file comes from.

Greetings

Christian





Christian Schneider
Informationsverarbeitung 
Business Solutions
Handel und Dispatching

Tel : +49-(0)721-63-15482

EnBW Systeme Infrastruktur Support GmbH
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim ­ HRB 108550
Vorsitzender des Aufsichtsrats: Dr. Bernhard Beck
Geschäftsführer: Jochen Adenau, Hans-Günther Meier


-----Ursprüngliche Nachricht-----
Von: Bruno Dusausoy [mailto:bdusausoy@yp5.be] 
Gesendet: Dienstag, 6. Juli 2010 14:02
An: Camel Users ML
Betreff: File component behavior

Hi,

I'm new to both Camel and EIP so maybe my question/problem is dumb ;).

I have a route defined in Spring as this :
    
    <!-- ActiveMQ beans and usual stuff -->

    <bean id="uploadBean"
class="be.ucm.career.quarterly.upload.UploadBean"/>
    
    <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
        <camel:package>foo.bar</camel:package>
        <camel:route>
            <camel:from uri="file:src/data?noop=true&amp;delay=30000" />
            <camel:bean ref="uploadBean"/>
            <camel:to uri="jms:output" />
        </camel:route>
    </camel:camelContext>

The implementation of "uploadBean" :

public class UploadBean {

	@Handler
	public String upload(@XPath("configuration/loopCount/text()")String
chunkSize) {
		
		System.out.println("Chunk size is : " + chunkSize);
		return "FOO_123";
	}
}

When launching the project with "mvn camel:run", I get this :

[...]
// INFO output
[...]
Chunk size is : 100
[src/data?delay=30000&noop=true] BrokerService                  INFO 
Using Persistence Adapter: AMQPersistenceAdapter(activemq-data\localhost)
[src/data?delay=30000&noop=true] AMQPersistenceAdapter          INFO 
AMQStore starting using directory: activemq-data\localhost
[src/data?delay=30000&noop=true] KahaStore                      INFO  Kaha
Store using data directory activemq-data\localhost\kr-store\state
[src/data?delay=30000&noop=true] AMQPersistenceAdapter          INFO 
Active data files: [1]
[src/data?delay=30000&noop=true] BrokerService                  INFO 
ActiveMQ 5.2.0 JMS Message Broker (localhost) is starting
[src/data?delay=30000&noop=true] BrokerService                  INFO  For
help or more information please see: http://activemq.apache.org/
[                 JMX connector] ManagementContext              INFO  JMX
consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
[src/data?delay=30000&noop=true] KahaStore                      INFO  Kaha
Store using data directory activemq-data\localhost\kr-store\data
[src/data?delay=30000&noop=true] BrokerService                  INFO 
ActiveMQ JMS Message Broker (localhost,
ID:100WCTI150-2821-1278413932666-0:0) started
[src/data?delay=30000&noop=true] TransportConnector             INFO 
Connector vm://localhost Started
[src/data?delay=30000&noop=true] TransportConnector             INFO 
Connector vm://localhost Stopped
[src/data?delay=30000&noop=true] BrokerService                  INFO 
ActiveMQ Message Broker (localhost, ID:100WCTI150-2821-1278413932666-0:0)
is shutting down
[src/data?delay=30000&noop=true] BrokerService                  INFO 
ActiveMQ JMS Message Broker (localhost,
ID:100WCTI150-2821-1278413932666-0:0) stopped
[Fatal Error] output.txt:1:1: Content is not allowed in prolog.
[Fatal Error] :1:1: Content is not allowed in prolog.
[src/data?delay=30000&noop=true] DefaultErrorHandler            ERROR
Failed delivery for exchangeId: b109fe1a-964e-4c70-91b0-bba46fb77766.
Exhausted after delivery attempt: 1 caught:
org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
configuration/loopCount/text(). Reason:
javax.xml.xpath.XPathExpressionException
org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
configuration/loopCount/text(). Reason:
javax.xml.xpath.XPathExpressionException
[...]
// STACK TRACE
[src/data?delay=30000&noop=true] GenericFileOnCompletion        WARN 
Rollback file strategy:
org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy@b9237a
for file: GenericFile[output.txt]

I'm wondering why I get this message, since the XPath is correct : you can
see the output of the method called on the bean at the beginning the
aforementioned snippet.
Moreover, I don't know where did the file component get this "output.txt"
file... :-/

The input.xml file is quite simple :

<?xml version="1.0"?>
<configuration>
    <loopCount>100</loopCount>
</configuration>

Can someone tell me what I'm doing wrong ?

Regards.
-- 
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

Re: File component behavior

Posted by Bruno Dusausoy <bd...@yp5.be>.
On Tue, 6 Jul 2010 14:07:56 +0200, Charles Moulliard
<cm...@gmail.com>
wrote:
> How have you configured the jms component of camel (<camel:to
> uri="jms:output" />) ?
> 

Yes, but I thought I should better leave it off in order to reduce the
noise.
Here is the whole application context :

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

    <bean id="uploadBean"
class="be.ucm.career.quarterly.upload.UploadBean" />

    <bean name="jms" class="org.apache.camel.component.jms.JmsComponent">
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL" value="vm://localhost" />
            </bean>
        </property>
    </bean>

    <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
        <camel:package>be.ucm.career</camel:package>
        <camel:route>
            <camel:from uri="file:src/data?noop=true&amp;delay=30000" />
            <camel:bean ref="uploadBean"/>
            <camel:to uri="jms:output" />
        </camel:route>
    </camel:camelContext>

</beans>

Regards.
-- 
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

Re: File component behavior

Posted by Charles Moulliard <cm...@gmail.com>.
How have you configured the jms component of camel (<camel:to
uri="jms:output" />) ?

Kind regards,

Charles Moulliard

Senior Enterprise Architect (J2EE, .NET, SOA)
Apache Camel - ServiceMix Committer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Blog : http://cmoulliard.blogspot.com |  Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard | Skype: cmoulliard



On Tue, Jul 6, 2010 at 2:02 PM, Bruno Dusausoy <bd...@yp5.be> wrote:
> Hi,
>
> I'm new to both Camel and EIP so maybe my question/problem is dumb ;).
>
> I have a route defined in Spring as this :
>
>    <!-- ActiveMQ beans and usual stuff -->
>
>    <bean id="uploadBean"
> class="be.ucm.career.quarterly.upload.UploadBean"/>
>
>    <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
>        <camel:package>foo.bar</camel:package>
>        <camel:route>
>            <camel:from uri="file:src/data?noop=true&amp;delay=30000" />
>            <camel:bean ref="uploadBean"/>
>            <camel:to uri="jms:output" />
>        </camel:route>
>    </camel:camelContext>
>
> The implementation of "uploadBean" :
>
> public class UploadBean {
>
>        @Handler
>        public String upload(@XPath("configuration/loopCount/text()")String
> chunkSize) {
>
>                System.out.println("Chunk size is : " + chunkSize);
>                return "FOO_123";
>        }
> }
>
> When launching the project with "mvn camel:run", I get this :
>
> [...]
> // INFO output
> [...]
> Chunk size is : 100
> [src/data?delay=30000&noop=true] BrokerService                  INFO
> Using Persistence Adapter: AMQPersistenceAdapter(activemq-data\localhost)
> [src/data?delay=30000&noop=true] AMQPersistenceAdapter          INFO
> AMQStore starting using directory: activemq-data\localhost
> [src/data?delay=30000&noop=true] KahaStore                      INFO  Kaha
> Store using data directory activemq-data\localhost\kr-store\state
> [src/data?delay=30000&noop=true] AMQPersistenceAdapter          INFO
> Active data files: [1]
> [src/data?delay=30000&noop=true] BrokerService                  INFO
> ActiveMQ 5.2.0 JMS Message Broker (localhost) is starting
> [src/data?delay=30000&noop=true] BrokerService                  INFO  For
> help or more information please see: http://activemq.apache.org/
> [                 JMX connector] ManagementContext              INFO  JMX
> consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
> [src/data?delay=30000&noop=true] KahaStore                      INFO  Kaha
> Store using data directory activemq-data\localhost\kr-store\data
> [src/data?delay=30000&noop=true] BrokerService                  INFO
> ActiveMQ JMS Message Broker (localhost,
> ID:100WCTI150-2821-1278413932666-0:0) started
> [src/data?delay=30000&noop=true] TransportConnector             INFO
> Connector vm://localhost Started
> [src/data?delay=30000&noop=true] TransportConnector             INFO
> Connector vm://localhost Stopped
> [src/data?delay=30000&noop=true] BrokerService                  INFO
> ActiveMQ Message Broker (localhost, ID:100WCTI150-2821-1278413932666-0:0)
> is shutting down
> [src/data?delay=30000&noop=true] BrokerService                  INFO
> ActiveMQ JMS Message Broker (localhost,
> ID:100WCTI150-2821-1278413932666-0:0) stopped
> [Fatal Error] output.txt:1:1: Content is not allowed in prolog.
> [Fatal Error] :1:1: Content is not allowed in prolog.
> [src/data?delay=30000&noop=true] DefaultErrorHandler            ERROR
> Failed delivery for exchangeId: b109fe1a-964e-4c70-91b0-bba46fb77766.
> Exhausted after delivery attempt: 1 caught:
> org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
> configuration/loopCount/text(). Reason:
> javax.xml.xpath.XPathExpressionException
> org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
> configuration/loopCount/text(). Reason:
> javax.xml.xpath.XPathExpressionException
> [...]
> // STACK TRACE
> [src/data?delay=30000&noop=true] GenericFileOnCompletion        WARN
> Rollback file strategy:
> org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy@b9237a
> for file: GenericFile[output.txt]
>
> I'm wondering why I get this message, since the XPath is correct : you can
> see the output of the method called on the bean at the beginning the
> aforementioned snippet.
> Moreover, I don't know where did the file component get this "output.txt"
> file... :-/
>
> The input.xml file is quite simple :
>
> <?xml version="1.0"?>
> <configuration>
>    <loopCount>100</loopCount>
> </configuration>
>
> Can someone tell me what I'm doing wrong ?
>
> Regards.
> --
> Bruno Dusausoy
> YP5 Software
> --
> Pensez environnement : limitez l'impression de ce mail.
> Please don't print this e-mail unless you really need to.
>