Re: Why can not get the data

2013-08-15 Thread Chris Wolf
Do you just need an Http server for unit testing?  Maybe take a look
at the class HttpTestServer.java in this directory in Git:

https://fisheye6.atlassian.com/browse/camel-git/tests/camel-itest/src/test/java/org/apache/camel/itest/http

On Wed, Aug 14, 2013 at 11:01 PM, yiwang imawan...@gmail.com wrote:
 I rewrite code is as follows:
 public class TestHttpCamel {
 private Main main;

 public static void main(String args[]) throws Exception {

 TestHttpCamel example = new TestHttpCamel();
 example.boot();

 }

 public void boot() throws Exception {
 main = new Main();
 main.enableHangupSupport();
 main.addRouteBuilder(new RouteBuilder() {
 public void configure() {

 from(http://localhost:8080/wms/query_all_handlover_note?type=source;)

 .to(file:d:/temp/outbox?fileName=data.txt);

 }
 });
 main.run();
 }

 }
 still not get the data.I have direct access to
 http://localhost:8080/wms/query_all_handlover_note? Type = source,can
 obtain the json data.  The HTTP routing write wrong or need what
 configuration?



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Why-can-not-get-the-data-tp5737243p5737285.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


How to use hawtio with Camel web app?

2013-07-18 Thread Chris Wolf
I would like to use hawtio's Camel route diagram view for inspecting
and displaying routes.

http://hawt.io/getstarted/index.html

Since the app will be deployed in a private Intranet, I tried their
offline WAR:

https://oss.sonatype.org/content/repositories/public/io/hawt/hawtio-default-offline/1.2-M1/hawtio-default-offline-1.2-M1.war

This didn't work - the first problem was an incompletely declared
WEB-INF/web.xml root element, which I fixed,
this allowed the web app to deploy, but I still see this error in the
server log:


13:02:21,940 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/hawtio]]
Failed to startup blueprint container.
org.osgi.service.blueprint.container.ComponentDefinitionException:
Unable to intialize bean aetherFacade:
org.osgi.service.blueprint.container.ComponentDefinitionException:
Unable to intialize bean aetherFacade

Although I can navigate and inspect MBeans through the JMX view.

If I download the full WAR, which includes a sample Camel context:

https://oss.sonatype.org/content/repositories/public/io/hawt/sample/1.2-M1/sample-1.2-M1.war

This also works, although with a large volume of assorted stack traces
in the log.

I don't need all the extra stuff that the full sample WAR has, e.g.
ActiveMQ because JBoss6 uses
HornetQ, etc.   I just want to know how to combine my Camel web app
with the most minimal hawtio
web app to be able to view/inspect context(s) and routes in diagram view?

I searched the list archive and only found a thread concerning the
initial announcement:

http://camel.465427.n5.nabble.com/ANN-hawtio-a-new-lightweight-HTML5-console-for-Apache-Camel-ActiveMQ-JMX-OSGi-amp-Fuse-Fabric-td5726244.html#a5726248

Does anyone have an idea?

Thanks,


Chris


Re: How to use hawtio with Camel web app?

2013-07-18 Thread Chris Wolf
Thanks for getting back to me.


 This didn't work - the first problem was an incompletely declared
 WEB-INF/web.xml root element, which I fixed,

 What change did you make? Any chance of a pull request or at least a
 gist of the latest version? :)


It was very minor.  I think it it fails because JBoss-6 is configured
to perform schema validation
of web.xml, so I changed the declaration of the root element from:


web-app version=2.4 xmlns=http://java.sun.com/xml/ns/javaee;


to:

web-app version=2.5
   xmlns=http://java.sun.com/xml/ns/javaee;
  xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   xsi:schemaLocation=http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd;

I don't think you need version 2.5, but I just had another web.xml I
copy/pasted from, with the
schemaLocation for 2.5.


I will get back to you on the other items, right now I have it all
ripped apart, temporarily..


Thanks,

Chris


Re: conditional uri

2013-07-16 Thread Chris Wolf
It depends on what you mean by conditional -  if you mean
conditional at route-definition time, you can use property placeholders
and/or Language Expressions.

If you mean conditional at runtime, then I'm pretty sure you can only do that
with producer endpoints (i.e. to endpoints) see:

http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

If you want conditional runtime consumer endpoints, the only solution I have
been able to come up with is dynamically created routes that are created at
runtime; this logic is encapsulated in a custom processor.

-Chris




On Tue, Jul 16, 2013 at 9:46 AM, boris boris.shuk...@barclays.com wrote:
 How could I have a conditional uri string?
 For example,
 I have from uri=prod_uri   in production and from uri=direct:start
 for testing.
 I want to have a single xml file for both and manage uri string
 conditionally.
 Thanks,
 Boris



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/conditional-uri-tp5735724.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Problem: file language expression being interpreted as Spring property-placeholder.

2013-07-10 Thread Chris Wolf
Hello,

I have an endpoint defined as:

to id=file.to.data-decrypted
 
uri=file://{{jboss.server.data.dir}}?idempotent=trueamp;preMove={{jboss.server.data.dir}}/holding/${file:onlyname.noext}.${id}amp;move={{jboss.server.data.dir}}/archiveamp;moveFailed={{jboss.server.data.dir}}/errorsamp;readLock=changed/


Which throws this exception:

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException:
Invalid bean definition with name 'file.to.data-decrypted' defined in
null: Could not resolve placeholder 'id'
at 
org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
at 
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:220)

I am quite sure, previously, I was able to use ${id} in the filename
expression and it was not interpreted as a Spring property
placeholder,
and I didn't reconfigure the opening/closing tokens for property
placeholders.  Anyone have a clue?

Thanks,


Chris


Re: Problem: file language expression being interpreted as Spring property-placeholder.

2013-07-10 Thread Chris Wolf
Thank you! that worked, I used:

fileName=$simple{file:onlyname.noext}.$simple{id}

On Wed, Jul 10, 2013 at 2:57 PM, Claus Ibsen claus.ib...@gmail.com wrote:
 You can use $simple{ xxx } as well as the syntax

 On Wed, Jul 10, 2013 at 7:10 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Hello,

 I have an endpoint defined as:

 to id=file.to.data-decrypted
  
 uri=file://{{jboss.server.data.dir}}?idempotent=trueamp;preMove={{jboss.server.data.dir}}/holding/${file:onlyname.noext}.${id}amp;move={{jboss.server.data.dir}}/archiveamp;moveFailed={{jboss.server.data.dir}}/errorsamp;readLock=changed/


 Which throws this exception:

 Caused by: org.springframework.beans.factory.BeanDefinitionStoreException:
 Invalid bean definition with name 'file.to.data-decrypted' defined in
 null: Could not resolve placeholder 'id'
 at 
 org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:209)
 at 
 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:220)

 I am quite sure, previously, I was able to use ${id} in the filename
 expression and it was not interpreted as a Spring property
 placeholder,
 and I didn't reconfigure the opening/closing tokens for property
 placeholders.  Anyone have a clue?

 Thanks,


 Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 Email: cib...@redhat.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: Why is the file component parameter, consumer.regexPattern not recognized?

2013-07-02 Thread Chris Wolf
Bilgin,

Thanks for that - I was always assuming file2 meant additionally
added.  I ended up using include=regex,
as suggested in file2.html.

Thanks,

Chris

On Wed, Jun 26, 2013 at 7:40 PM, Bilgin Ibryam bibr...@gmail.com wrote:
 Hi Chris,

 are you using Camel 1.x?
 As it says in the documentation, for Camel 2.x, the doc page of file
 component is
 http://camel.apache.org/file2.html

 Bilgin



 On 26 June 2013 22:24, Chris Wolf cwolf.a...@gmail.com wrote:

 ResolveEndpointFailedException: Failed to resolve endpoint:
 file://src/test/data?consumer.regexPattern=.*uu%24noop=true
 due to: There are 1 parameters that couldn't be set on the endpoint
 consumer.
 Check the uri if the parameters are spelt correctly and that they are
 properties
 of the endpoint. Unknown consumer parameters=[{regexPattern=.*uu$}]

 I copypasted the parameter name directly from the doc page:
 http://camel.apache.org/file.html

 Thanks,


 Chris



Re: Problem with DefaultCamelContext EndpointRegistry

2013-07-02 Thread Chris Wolf
Claus,

Thanks, but the fact that attempting to add another instance of the
same Endpoint type results in the
name getting and instance number appended means that some
consideration must have been
given to accommodating multiple instances of the same Endpoint in the
registry, right?

In any case, I gave up on the idea of writing a custom component to
solve the dynamic
consumer problem and instead, create consumer routes, at runtime, with
static consumer URIs,
which solves my problem.

Thanks,

Chris

On Fri, Jun 14, 2013 at 7:16 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Only singleton endpoints should be in the registry.

 Non singleton is prototype based and therefore a new instance is
 created when you call getEndpoint.



 On Wed, Jun 12, 2013 at 7:41 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Ok, have a partial answer - since my Endpoint is not a singleton, I see that
 DefaultCamelContext.getEndpointKey(String uri, Endpoint endpoint)
 appends that %3A2 -
 i.e. :2 - which appears to be an instance qualifier.  The trouble is,
 DefaultEndpoint.getEndpointUri() will always return the URI *without*
 that instance qualifier,
 so it won;t be found in the endpoint registry.

 Is there an example of a Component whose Endpoint is not a singleton,
 that I can look at?
 Or are non-singleton Endpoints some new, untested feature?

 Thanks,

 Chris

 On Wed, Jun 12, 2013 at 3:28 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 I am trying to develop a new component, but it needs to be able to
 have it's endpoint be registered in
 the CamelContext endpoint registry.   Whenever the runtime tries to
 call DefaultCamelContext.getEndpoint(String uri)
 it returns null, even though, in the debugger, I can expand
 DefaultCamelContext.endpoints.map

 ...and see that, for sure, the endpoint is in the registry, except the
 key now has %3A2 appended, so of course,
 the EndpointKey, which looks like:

 dsftp://localhost:21000?binary=truedirectory=target%2Fres%2Fhomefilter=%23cpmdFileFilteridempotent=truelocalWorkDirectory=target%2Fres%2Ftmp%2Flocalmove=archive%2F%24%7Bfile%3Aname%7Dpassword=adpt5separator=UNIXusername=adpt5

 ...won't match, so that explains why
 DefaultCamelContext.getEndpoint(String uri) returns null.


 DefaultCamelContext.endpoints.map:  (other entries removed for clarity)
 {dsftp://localhost:21000binary=truedirectory=target%2Fres%2Fhomefilter=%23cpmdFileFilteridempotent=truelocalWorkDirectory=target%2Fres%2Ftmp%2Flocalmove=archive%2F%24%7Bfile%3Aname%7Dpassword=adpt5separator=UNIXusername=adpt5%3A2=java.lang.ref.SoftReference@f7e5307}

 *** So why does the key in the endpoints.map have %3A2  appended to it? 
 ***

 Thanks,

 Chris



 --
 Claus Ibsen
 -
 www.camelone.org: The open source integration conference.

 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: Cannot get filter() to work with mandatoryBodyAs

2013-07-02 Thread Chris Wolf
Christian - this was a user error on my part and I forgot that I
could/should just overwrite and replace the in body of the
exchange, in which case, I didn't need to filter out the
no-longer-needed upstream message body.

Thanks,


Chris

On Tue, Jun 11, 2013 at 11:19 AM, Christian Müller
christian.muel...@gmail.com wrote:
 Can you try
 .filter(simple(${mandatoryBodyAs(org.apache.camel.component.file.remote.RemoteFile)}))?

 Best,

 Christian Müller
 -

 Software Integration Specialist

 Apache Camel committer: https://camel.apache.org/team
 V.P. Apache Camel: https://www.apache.org/foundation/
 Apache Member: https://www.apache.org/foundation/members.html

 https://www.linkedin.com/pub/christian-mueller/11/551/642


 On Tue, Jun 11, 2013 at 4:12 PM, Chris Wolf cwolf.a...@gmail.com wrote:

 I want to impose a filter such that only messages whose body is of
 type RemoteFile get through,
 So per the documentation:

 http://camel.apache.org/message-filter.html
 http://camel.apache.org/predicate.html
 http://camel.apache.org/simple.html

 I have:

 .filter(simple(${mandatoryBodyAs(RemoteFile.class)}))

 But I get:

 org.apache.camel.CamelExecutionException: Exception occurred during
 execution on the exchange: Exchange[Message: {}]
 at
 org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1332)
 at
 org.apache.camel.builder.ExpressionBuilder$33.evaluate(ExpressionBuilder.java:781)
 at
 org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
 at
 org.apache.camel.support.ExpressionSupport.matches(ExpressionSupport.java:32)
 at
 org.apache.camel.util.ExpressionToPredicateAdapter.matches(ExpressionToPredicateAdapter.java:32)
 at
 org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:75)
 at
 org.apache.camel.processor.FilterProcessor.process(FilterProcessor.java:47)
 []
 Caused by: java.lang.ClassNotFoundException: RemoteFile.class
 at
 org.apache.camel.impl.DefaultClassResolver.resolveMandatoryClass(DefaultClassResolver.java:52)
 at
 org.apache.camel.builder.ExpressionBuilder$33.evaluate(ExpressionBuilder.java:779)
 ... 67 more

 ...even though I imported RemoteFile.  So then I tried:


 .filter(simple(${mandatoryBodyAs(org.apache.camel.component.file.remote.RemoteFile.class)}))

 and I get the same ClassNotFoundException, but with the full classname.

 How can I filter messages, such that only messages whose in-body is
 non-null and of a certain type get through?

 Thanks,

 Chris



Re: SFTP: disconnect on route-suspend

2013-06-25 Thread Chris Wolf
Our project has similar requirements - in addition to parameterizing
the SFTP connection at runtime, not
just at route declaration-time.  I was led to believe that, generally,
consumers can't be parameterized at
runtime, so I made a few attempts at creating my own custom  component
to do SFTP with parameters
passed in at runtime, triggered by Quartz cron trigger.  This worked,
but didn't get automatically
wrapped in JMX wrappers, plus other clunky issues.

I ended up having the quartz/cron trigger send the parameters to a
custom processor which
creates a route at runtime, starting with an SFTP consumer - plus a
background thread that
defines the poll time duration, after which, the thread stops the
route, then removes it.

This all works for us now, including multiple, concurrent connections
(well, only two simultaneous
tested so far)

You might want to try an approach like that.

On Tue, Jun 25, 2013 at 11:21 AM, mdo manfred.doh...@gmail.com wrote:
 Claus Ibsen-2 wrote
 Use stop instead of suspend.

 I know that stopping the route does shut down the endpoints. But we changed
 to suspend/resume a month ago because we noticed that stop/restart leaks
 threads in GlassFish. If I did stop the route I would have to remove and
 recreate it each time Quartz fires. This would also knock down my whole
 approach of initially setting up routes on application startup.

 At the moment I'm looking into endpoint options, something like:
 serverAliveInterval 900
 serverAliveCountMax 0

 This idea was inspired by http://serverfault.com/a/450916

 But this doesn't seem to work neither. JSCH goes nuts and disconnects right
 before logging in and SSH_MSG_KEXDH_INIT sent should get logged.

 Regards, mdo.





 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/SFTP-disconnect-on-route-suspend-tp5734742p5734744.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


camel-jms sometimes not closing connections/sessions

2013-06-21 Thread Chris Wolf
I have a camel app deployed on JBoss-6, which is using HornetQ as the
JMS implementation.

There is a route which listens to JMS topic traffic between some 3rd
party MDBs, which,
I believe use durable, transacted topics, but since the camel route is
just listening (consuming)
I have the most basic configuration:

jms://topic:foo?connectionFactory=#connectionFactory

...where connectionFactory is what is returned by a JNDI lookup, of type
org.hornetq.ra.HornetQRAConnectionFactoryImpl - which is a JCA Resource Adapter.

When I run the process, everything works, but then JBoss complains of improperly
closed JMS sessions. In the server log, I see hundreds of messages like:


09:40:21,397 WARN  [org.hornetq.core.protocol.core.impl.RemotingConnectionImpl]
Connection failure has been detected: Did not receive data from invm:0.
It is likely the client has exited or crashed without closing its connection,
or the network between the server and client has failed. You also might have
configured connection-ttl and client-failure-check-period incorrectly.
Please check user manual for more information. The connection will now
be closed. [code=3]
09:40:21,397 WARN  [org.hornetq.core.server.impl.ServerSessionImpl]
Client connection failed, clearing up resources for session
c7b542a4-da06-11e2-84bb-0250f205


...other times none of these warnings appear.   When run without the
camel part deployed, I never see these
warnings, so I'm thinking it's the Camel JMS component.  Is there a
way to log that session id to positively
verify this is the case, or not?

Also do I see to configure some other settings, such as TTL, etc.?

Any suggestions appreciated, thanks,

Chris

In JBoss, this is the setting to auto-cleanup RA resources, such as
JMS sessions:
https://community.jboss.org/wiki/ConfigCachedConnectionManager


Problem with DefaultCamelContext EndpointRegistry

2013-06-12 Thread Chris Wolf
I am trying to develop a new component, but it needs to be able to
have it's endpoint be registered in
the CamelContext endpoint registry.   Whenever the runtime tries to
call DefaultCamelContext.getEndpoint(String uri)
it returns null, even though, in the debugger, I can expand
DefaultCamelContext.endpoints.map

...and see that, for sure, the endpoint is in the registry, except the
key now has %3A2 appended, so of course,
the EndpointKey, which looks like:

dsftp://localhost:21000?binary=truedirectory=target%2Fres%2Fhomefilter=%23cpmdFileFilteridempotent=truelocalWorkDirectory=target%2Fres%2Ftmp%2Flocalmove=archive%2F%24%7Bfile%3Aname%7Dpassword=adpt5separator=UNIXusername=adpt5

...won't match, so that explains why
DefaultCamelContext.getEndpoint(String uri) returns null.


DefaultCamelContext.endpoints.map:  (other entries removed for clarity)
{dsftp://localhost:21000binary=truedirectory=target%2Fres%2Fhomefilter=%23cpmdFileFilteridempotent=truelocalWorkDirectory=target%2Fres%2Ftmp%2Flocalmove=archive%2F%24%7Bfile%3Aname%7Dpassword=adpt5separator=UNIXusername=adpt5%3A2=java.lang.ref.SoftReference@f7e5307}

*** So why does the key in the endpoints.map have %3A2  appended to it? ***

Thanks,

Chris


Re: Problem with DefaultCamelContext EndpointRegistry

2013-06-12 Thread Chris Wolf
Ok, have a partial answer - since my Endpoint is not a singleton, I see that
DefaultCamelContext.getEndpointKey(String uri, Endpoint endpoint)
appends that %3A2 -
i.e. :2 - which appears to be an instance qualifier.  The trouble is,
DefaultEndpoint.getEndpointUri() will always return the URI *without*
that instance qualifier,
so it won;t be found in the endpoint registry.

Is there an example of a Component whose Endpoint is not a singleton,
that I can look at?
Or are non-singleton Endpoints some new, untested feature?

Thanks,

Chris

On Wed, Jun 12, 2013 at 3:28 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 I am trying to develop a new component, but it needs to be able to
 have it's endpoint be registered in
 the CamelContext endpoint registry.   Whenever the runtime tries to
 call DefaultCamelContext.getEndpoint(String uri)
 it returns null, even though, in the debugger, I can expand
 DefaultCamelContext.endpoints.map

 ...and see that, for sure, the endpoint is in the registry, except the
 key now has %3A2 appended, so of course,
 the EndpointKey, which looks like:

 dsftp://localhost:21000?binary=truedirectory=target%2Fres%2Fhomefilter=%23cpmdFileFilteridempotent=truelocalWorkDirectory=target%2Fres%2Ftmp%2Flocalmove=archive%2F%24%7Bfile%3Aname%7Dpassword=adpt5separator=UNIXusername=adpt5

 ...won't match, so that explains why
 DefaultCamelContext.getEndpoint(String uri) returns null.


 DefaultCamelContext.endpoints.map:  (other entries removed for clarity)
 {dsftp://localhost:21000binary=truedirectory=target%2Fres%2Fhomefilter=%23cpmdFileFilteridempotent=truelocalWorkDirectory=target%2Fres%2Ftmp%2Flocalmove=archive%2F%24%7Bfile%3Aname%7Dpassword=adpt5separator=UNIXusername=adpt5%3A2=java.lang.ref.SoftReference@f7e5307}

 *** So why does the key in the endpoints.map have %3A2  appended to it? ***

 Thanks,

 Chris


Cannot get filter() to work with mandatoryBodyAs

2013-06-11 Thread Chris Wolf
I want to impose a filter such that only messages whose body is of
type RemoteFile get through,
So per the documentation:

http://camel.apache.org/message-filter.html
http://camel.apache.org/predicate.html
http://camel.apache.org/simple.html

I have:

.filter(simple(${mandatoryBodyAs(RemoteFile.class)}))

But I get:

org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange: Exchange[Message: {}]
at 
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1332)
at 
org.apache.camel.builder.ExpressionBuilder$33.evaluate(ExpressionBuilder.java:781)
at 
org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
at 
org.apache.camel.support.ExpressionSupport.matches(ExpressionSupport.java:32)
at 
org.apache.camel.util.ExpressionToPredicateAdapter.matches(ExpressionToPredicateAdapter.java:32)
at org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:75)
at 
org.apache.camel.processor.FilterProcessor.process(FilterProcessor.java:47)
[]
Caused by: java.lang.ClassNotFoundException: RemoteFile.class
at 
org.apache.camel.impl.DefaultClassResolver.resolveMandatoryClass(DefaultClassResolver.java:52)
at 
org.apache.camel.builder.ExpressionBuilder$33.evaluate(ExpressionBuilder.java:779)
... 67 more

...even though I imported RemoteFile.  So then I tried:

.filter(simple(${mandatoryBodyAs(org.apache.camel.component.file.remote.RemoteFile.class)}))

and I get the same ClassNotFoundException, but with the full classname.

How can I filter messages, such that only messages whose in-body is
non-null and of a certain type get through?

Thanks,

Chris


Re: Cannot get filter() to work with mandatoryBodyAs ***DISREGARD***

2013-06-11 Thread Chris Wolf
In the simple language, a type is a string, not a class, so instead of

 
.filter(simple(${mandatoryBodyAs(org.apache.camel.component.file.remote.RemoteFile.class)}))

...I needed:

 
.filter(simple(${mandatoryBodyAs(org.apache.camel.component.file.remote.RemoteFile)}))

(removed .class)


On Tue, Jun 11, 2013 at 10:12 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 I want to impose a filter such that only messages whose body is of
 type RemoteFile get through,
 So per the documentation:

 http://camel.apache.org/message-filter.html
 http://camel.apache.org/predicate.html
 http://camel.apache.org/simple.html

 I have:

 .filter(simple(${mandatoryBodyAs(RemoteFile.class)}))

 But I get:

 org.apache.camel.CamelExecutionException: Exception occurred during
 execution on the exchange: Exchange[Message: {}]
 at 
 org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1332)
 at 
 org.apache.camel.builder.ExpressionBuilder$33.evaluate(ExpressionBuilder.java:781)
 at 
 org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
 at 
 org.apache.camel.support.ExpressionSupport.matches(ExpressionSupport.java:32)
 at 
 org.apache.camel.util.ExpressionToPredicateAdapter.matches(ExpressionToPredicateAdapter.java:32)
 at 
 org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:75)
 at 
 org.apache.camel.processor.FilterProcessor.process(FilterProcessor.java:47)
 []
 Caused by: java.lang.ClassNotFoundException: RemoteFile.class
 at 
 org.apache.camel.impl.DefaultClassResolver.resolveMandatoryClass(DefaultClassResolver.java:52)
 at 
 org.apache.camel.builder.ExpressionBuilder$33.evaluate(ExpressionBuilder.java:779)
 ... 67 more

 ...even though I imported RemoteFile.  So then I tried:

 .filter(simple(${mandatoryBodyAs(org.apache.camel.component.file.remote.RemoteFile.class)}))

 and I get the same ClassNotFoundException, but with the full classname.

 How can I filter messages, such that only messages whose in-body is
 non-null and of a certain type get through?

 Thanks,

 Chris


Re: Cannot get SFTP component to stop polling

2013-06-10 Thread Chris Wolf
Thanks for the suggestions.  So far, I have not done anything
programmatically - just tried suspending the route via JMX (jconsole)
and when that didn't work, tried stopping the route - that didn't work
either.  I can't remove the route since it is declarative from
Spring-DSL, however, I guess I could resort to changing it to dynamic
with yet another custom Processor to add/remove the route.

Regards,

Chris

On Fri, Jun 7, 2013 at 5:15 PM, swwyatt steven.wy...@sungard.com wrote:
 We are doing something similar. How are you stopping the route?

 I ended up doing this:

 camelContext.stopRoute(routeId);
 camelContext.removeRoute(routeId);

 We are having several dynamic consumer routes in the same context, so we
 additionally call camelContext.stop(), hopefully this would just stop the
 single route.



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Cannot-get-SFTP-component-to-stop-polling-tp5734021p5734023.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


How to get JMX-wrapped Component, Endpoint and Consumer?

2013-06-10 Thread Chris Wolf
I notice the standard, out-of-the-box components automatically get
the Component, Endpoint and Consumer/Producer wrapped in JMX-managed
wrappers - all without the JMX annotations.   Poking around in the
code, I see:

DefaultManagementLifecycleStrategy.onRoutesAdd(...)

..but I don't know how this ties into normal RouteBuilder usages..

I see also:

ManagedCamelContext.createEndpoint(...)

...but, again,  I don't know how this ties into normal RouteBuilder usage.

So how would I do that?

Thanks,

Chris


Re: Camel Mustache Handlebars components

2013-06-10 Thread Chris Wolf
I'm just curious - how is this any better/different that
camel-freemarker?  What are the advantages?  I ask because am using
camel-freemarker and am having the following issue with Freemarker:

POJOs correspond to records in a document, normally you pass a
collection of POJOs into Freemarker to get the output document.

The issue I face is the size of the document could be
gigantic/undetermined, so in my route, everything is streamed
record-by-record - reading in the whole document into memory is not an
option, therefore I was not able to use the freemarker:// component
and had to write yet another custom processor which opens (with
append=true) writes and closes the output file on every record, since
the number of records is unknown - this works except it's probably not
efficient and I get spurious blank lines.

Would your Handlerbar and/or Mustache template solution handle
this record-streaming scenario, or does the whole input have to be
read into memory also?

Thanks,

Chris

On Sat, Jun 8, 2013 at 4:21 PM, gquintana gerald.quint...@gmail.com wrote:
 Hi all,

 Just for the fun, I wrote Camel components using Mustache or Handlebars
 templating engines:
 https://github.com/gquintana/camel-stuff

 Cheers,
 Gérald



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-Mustache-Handlebars-components-tp5734043.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Communication between Camel and JBoss AS7

2013-06-10 Thread Chris Wolf
We use JBoss-6 and HornetQ MDBs.  (i.e. JMS)

On Mon, Jun 10, 2013 at 11:55 AM, ak-dak ku...@dakosy.de wrote:
 Hi all,

 I want to develop a camel route which processes a xml message. Below a
 simple route to demonstrate my use case.

 route id=processMessage
 from uri=activemq:queue:startMessageProcessing/
 bean ref=messageService method=convertMessage/
 bean ref=jbossService method=validateMessage/
 bean ref=jbossService method=persistMessage/
 to uri=activemq:queue:forwardMessage/
 /route

 I want to do all business JPA persist logic by EJB's within a JBoss AS 7.
 See the methods of jbossService within my example.

 And now my question. What's the best solution to communicate with a JBoss
 AS 7 to invoke EJB's synchronously? Wrapping of the EJB calls within
 Soap-Webservices could be a solution but I'am concerned about the
 performance. When the system goes into production we have to process 1
 and more messages as fast as possible.

 Maybe someone has a more faster solution?

 Best regards



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Communication-between-Camel-and-JBoss-AS7-tp5734069.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Mustache Handlebars components

2013-06-10 Thread Chris Wolf
Oh, I see, ok.  Actually, upon further thinking, instead of wrapping
the in-memory
object graph in SimpleHash - there's an interface called
TemplateModelIterator,
where, I think I could implement it such that the iterator returned would be an
iterator whose next() could return a TemplateModel representing the
current record and have a special end-of-group record that signals next()
to return null, thus closing the file.I haven't tried that, but hopefully it
will work.

I see what you're saying about having a single client-side and
server-side template
language.


Thanks,

Chris

On Mon, Jun 10, 2013 at 11:52 AM, gquintana gerald.quint...@gmail.com wrote:
 No these components won't help you, they work exactly like FreeMarker. On
 Mustache Java, I think you can customize the way your object graph is walked
 when rendering the template (see BaseObjectHandler). But the whole message
 must fit in memory.

 I produced theses components because I am using Handlebars on the client
 side (in JavaScript) and I didn't want to introduce another templating
 language.





 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-Mustache-Handlebars-components-tp5734043p5734068.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Cannot get SFTP component to stop polling

2013-06-07 Thread Chris Wolf
I am using Camel 2.10.4 and need to use SFTP to fetch files.  Since
the sftp consumer does not support dynamic properties (connecting to
different host/directory/user/pass, etc.) I implemented a custom
processor which sets up the SftpComponent, SftpEndpoint and
SftpConsumer, in what I believe to be very similar to the sftp://;
component, but instead of parsing the URI for the settings, it gets
the settings from the inbound body of type MapString, Object.

It all works, except after a certain time period, I need it to stop
polling.  I tried to suspend the route it's in, but it is still
polling - I tried to
stop the route - it's still polling!  How can I get it to stop??
Though JMX, I can see that the route is definitely stopped, so how can
the SftpConsumer
be still polling???


Thanks,


Chris


Here's roughly what my custom Processor looks like (logging, error
handling stripped out)

public class  SftpDownloader implements Processor {
protected SftpComponent sftpComponent;
protected SftpEndpoint  sftpEndpoint;
protected SftpConsumer  sftpConsumer;
protected org.apache.camel.ProducerTemplate producer;
protected String toEndpointURI;

public void process(Exchange exchange) throws Exception {
MapString, Object ftpProps = exchange.getIn().getBody(Map.class);
CamelContext context = exchange.getContext();

if (this.producer == null) {
this.producer = context.createProducerTemplate();
this.producer.setDefaultEndpointUri(this.toEndpointURI);
}

configure(context, ftpProps, endpointURIQueryString);
}

void configure(CamelContext context, MapString, Object
parameters, String queryStr) throws Exception {
String initialURI = String.format(sftp://%s/%s;,
parameters.get(host), parameters.get(directory));
sftpEndpoint = context.getEndpoint(initialURI, SftpEndpoint.class);
sftpComponent = (SftpComponent) sftpEndpoint.getComponent();

SftpConfiguration conf = sftpEndpoint.getConfiguration();

// set reference properties first as they use # syntax that
fools the regular properties setter
EndpointHelper.setReferenceProperties(context, conf, parameters);
EndpointHelper.setProperties(context, conf, parameters);
EndpointHelper.setReferenceProperties(context, sftpEndpoint,
parameters);
EndpointHelper.setProperties(context, sftpEndpoint, parameters);

sftpConsumer = (SftpConsumer)
sftpEndpoint.createConsumer(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
producer.send(exchange);
}
});

((ScheduledPollConsumer) sftpConsumer).setStartScheduler(true);
sftpConsumer.start();
}


Re: idempotentConsumer is not idempotent?

2013-06-06 Thread Chris Wolf
Although you may be wishing for a strict interpretation of
idempotent, there are also practical interpretations, e.g.
the idempotent option for the file:// component - the whole
purpose of this option is to read the file only once, even if it
remains in the directory.

On Thu, Jun 6, 2013 at 10:07 AM, jannecamel jann...@iki.fi wrote:
 At first look I was getting excited about idempotentConsumer - this would
 help me nicely in creating idempotent services.

 But looking closer, it does not seem to do what it says?

 Looks like it takes first request and processes it. Then if duplicate
 messages come, it just discards those.

 A true idempotent consumer would discard the duplicate messages AND return
 the same (cached) response as the first one got. For example if I have
 service add(x,y) and I call add(2,5) multiple times, each call should return
 7. Now first returns 7 and duplicate ones return nothing. Or did I
 understand it wrong?

 http://www.enterpriseintegrationpatterns.com/IdempotentReceiver.html
 The term idempotent is used in mathematics to describe a function that
 produces the same result if it is applied to itself, i.e. f(x) = f(f(x)). In
 Messaging this concepts translates into the a message that has the same
 effect whether it is received once or multiple times. This means that a
 message can safely be resent without causing any problems even if the
 receiver receives duplicates of the same message.



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/idempotentConsumer-is-not-idempotent-tp5733945.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Quartz and JobStore

2013-05-22 Thread Chris Wolf
Don't forget that JBoss runs it's own instance of Quartz as a service.
I'm not sure
how you're configuring the JobStore implementation, but if it's via
the quartz.properties
and the JBoss instance of quartz reads the same properties, then maybe
there's a conflict?

On Mon, May 20, 2013 at 5:41 PM, mpaivafontes mpaivafon...@gmail.com wrote:
 Hello,

 I'm trying to use the misfire property from Camel-Quartz persisting the data
 at the database ( SQL server ) with JobStore from Quartz but i'm facing a
 strange problem after the restart of the application.

 For some reason after the restart, all data disappear for some reason and
 the misfire is not getting triggered.

 When i setted the xx.isClustered=true the all data is kept what does make
 sense, but it's not my case.

 I would like to know if is there any way to keep the data intact after the
 app restart so i can see the misfire working properly.

 The class used to control the transaction is
 org.quartz.impl.jdbcjobstore.JobStoreTX

 Regards !



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-Quartz-and-JobStore-tp5732853.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: I want to call CamelContext.addRouteDefinition, but it's deprecated - how do I get ModelCamelContext?

2013-05-18 Thread Chris Wolf
So was (is) the root package supposed to be internal and model the
ideal external API?

I'm still not certain of the purpose of the model package

Thanks,


Chris

On Sat, May 18, 2013 at 3:33 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 Yeah its IMHO a bit unfortunate with the @deprecated on the
 CamelContext. But the point was to use ModelCamelContext as this
 interface is from the model package. Where as CamelContext is from the
 root.
 So with the ModelCamelContext you dont have root - model in the
 dependency triage.




 On Fri, May 17, 2013 at 10:08 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 In a custom Processor, I am calling CamelContext.addRouteDefinition -
 but the javadoc says it's deprecated and
 to use org.apache.camel.model.ModelCamelContex.addRouteDefinition(..) 
 instead.

 I see that DefaultCamelContext implements ModelCamelContext, so I just
 cast it like:

 ModelCamelContext context = (ModelCamelContext)exchange.getContext();

 That seems to work too.  What is the difference between these two
 interfaces and the model
 sub-package, in general?  (I searched the FAQ and CiA book, but didn't
 find anything)

 Thanks,


 Chris



 --
 Claus Ibsen
 -
 www.camelone.org: The open source integration conference.

 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: How can I dynamically add or modify endpoints in a route?

2013-05-18 Thread Chris Wolf
Actually, after further experimenting, my reconfgure worked, but
only after the
CamelContext was started.  So the implementation was to just have an initial
route consuming from a direct:, then, when an message comes in, I dynamically
create and add new routes, each headed by a unique instance of
quartz://, who's
name corresponds to the customer-id, so each customer has their own crontab.

Thanks,


Chris

On Sat, May 18, 2013 at 3:42 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 The RouteBuilder is just java code, so I suggest to add getter/setter
 to a MyCronRouteBuilder class which extends RouteBuilder. Then you can
 create a new instance of that, and then use the setter to set your
 options.

 And in the configure method you can use the getter to get your
 options, which you can use in the DSL to set the options you want.

 On Fri, May 17, 2013 at 6:53 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 I need to schedule multiple cron jobs in a route.  The number and
 schedules are not known at compile-time,
 so I need to programatically configure the route at run-time.  An
 abbreviated version of my non-working
 attempt is shown below.  I created an anonymous RouteBuilder, in which
 I created a route.

 After, calling context.addRoutes(...), but before starting the
 context, I want to programmatically
 tweak the route definition, as shown by the reconfigure(...)
 function, unfortunately any attempt
 to lookup the route I just created fails - no routes found.  Why?  I
 suspect that the route may actually
 need to be started for it's initialization to complete, so should I
 start it, then stop or suspend, then
 programmatically modify?


 BTW, I already checked my copy of Camel In Action and
 http://camel.apache.org/faq.html but
 no answers for me there

 context.addRoutes(new RouteBuilder() {
   public void configure() {
 from(quartz://demo-1/{{custId}}?cron=* * * * * ? 2036).routeId(sched)
 .process(new Processor() {
   @Override
   public void process(Exchange exchange) throws Exception {
 // Do something at cron trigger time
   }
 }).id(sched.pipline)
 .to(log:demo-1?showAll=truemultiline=truelevel=INFO);
   }
 });

 reconfigure(sched.pipline, context);

 void reconfigure(String downstreamNodeId, CamelContext context) {
 for (Route route : context.getRoutes()) { // getRoutes()
 returns zero-length list - why
 String id = route.getId();  // null - why???
 ListService svcs = route.getServices();
 Consumer c = route.getConsumer();
 }
 Route sched = context.getRoute(sched);  // null



 --
 Claus Ibsen
 -
 www.camelone.org: The open source integration conference.

 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


How can I dynamically add or modify endpoints in a route?

2013-05-17 Thread Chris Wolf
I need to schedule multiple cron jobs in a route.  The number and
schedules are not known at compile-time,
so I need to programatically configure the route at run-time.  An
abbreviated version of my non-working
attempt is shown below.  I created an anonymous RouteBuilder, in which
I created a route.

After, calling context.addRoutes(...), but before starting the
context, I want to programmatically
tweak the route definition, as shown by the reconfigure(...)
function, unfortunately any attempt
to lookup the route I just created fails - no routes found.  Why?  I
suspect that the route may actually
need to be started for it's initialization to complete, so should I
start it, then stop or suspend, then
programmatically modify?


BTW, I already checked my copy of Camel In Action and
http://camel.apache.org/faq.html but
no answers for me there

context.addRoutes(new RouteBuilder() {
  public void configure() {
from(quartz://demo-1/{{custId}}?cron=* * * * * ? 2036).routeId(sched)
.process(new Processor() {
  @Override
  public void process(Exchange exchange) throws Exception {
// Do something at cron trigger time
  }
}).id(sched.pipline)
.to(log:demo-1?showAll=truemultiline=truelevel=INFO);
  }
});

reconfigure(sched.pipline, context);

void reconfigure(String downstreamNodeId, CamelContext context) {
for (Route route : context.getRoutes()) { // getRoutes()
returns zero-length list - why
String id = route.getId();  // null - why???
ListService svcs = route.getServices();
Consumer c = route.getConsumer();
}
Route sched = context.getRoute(sched);  // null


I want to call CamelContext.addRouteDefinition, but it's deprecated - how do I get ModelCamelContext?

2013-05-17 Thread Chris Wolf
In a custom Processor, I am calling CamelContext.addRouteDefinition -
but the javadoc says it's deprecated and
to use org.apache.camel.model.ModelCamelContex.addRouteDefinition(..) instead.

I see that DefaultCamelContext implements ModelCamelContext, so I just
cast it like:

ModelCamelContext context = (ModelCamelContext)exchange.getContext();

That seems to work too.  What is the difference between these two
interfaces and the model
sub-package, in general?  (I searched the FAQ and CiA book, but didn't
find anything)

Thanks,


Chris


Re: what's wrong with oracle configuration

2013-05-16 Thread Chris Wolf
First, I see that you're using Oracle-XE.  If you're on Windows, be
advised that Oracle-XE
is only supported on 32bit versions of Windows.   I learned the hard
way - strange
erratic behavior, etc.  I advise that if you have 64bit Windows, that
you uninstall Oracle-XE
and install the standard release:

http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html


What is your deployment environment?  Servlet container/webapp?  Standalone?

Generally it's a good idea to mention the Operating System type and version,
Camel version, etc.

I am developing our app on 64bit Windows-7 and standard Oracle release 11.2g
works find in all deployment modes: standalone app, servlet container
and application server. Since I'm using OpenJPA, I am using DBCP
connection pooling for standalone and non-managed servlet container
(e.g. Jetty) for JBoss, the pooling is managed by JBoss.

You should also use the JDBC driver jar that comes with 11.2g:

$ORACLE_HOME/jdbc/lib
i.e.  C:/oraclexe/app/oracle/product/11.2.0/server/jdbc/lib

ojdbc6_g.jar or ojdbc6.jar

Chris

On Thu, May 16, 2013 at 6:42 AM, takidean takide...@hotmail.fr wrote:
 should id add something here




  bean id=orsmon
 class=org.springframework.jdbc.datasource.DriverManagerDataSource
 property name=driverClassName value=oracle.jdbc.OracleDriver/
 property name=url value=jdbc:oracle:thin:@localhost:1521:xe/
 property name=username value=smon/
 property name=password value=smon/
 /bean

 i add the jar file to the classphath , it works fine for mysql but bugs for
 oracle

 the error that i got

  Property 'driverClassName' threw exception; nested exception is
 java.lang.IllegalStateException: Could not load JDBC driver class
 [oracle.jdbc.OracleDriver]



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/what-s-wrong-with-oracle-configuration-tp5732673.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Can I deploy multiple instances of the same RoutePolicy on the same route?

2013-05-16 Thread Chris Wolf
I implemented a custom route policy that is similar to the
CronScheduledRoutePolicy, except instead
of start/resume suspend crontabs, it only has a start/resume crontab
and a duration.

Well, now I need to support multiple customers,each having different
schedules.  I was thinking of just
adding multiple instances via the bean factory option
singleton=false because I notice that you
can have multiple RoutePolicies on a route, but can you have multiple
instances of the same RoutePolicy,
where each has a different crontab?


Or maybe, I should probably implement a custom processor to call on
the quartz component in a loop
to create the per-customer crontabs?  Any thoughts?

Thanks,


Chris


Re: What is the best approach to do an asynchronous rendezvous?

2013-05-15 Thread Chris Wolf
Raúl,

Thanks for your ideas.  Now it's 3 events without guaranteed order to
arrive before triggering the fourth event.  As for correlation key, I
guess it would be customer-id plus a timestamp
that shows the event happened in the last several hours.

The more I look into it, the more it seems like the Camel resequencer
process may apply
here:  http://camel.apache.org/resequencer.html

The thing is, I'm not sure about setting batch size and/or timeout.
The documentation
states:

...messages are collected into a batch, either by a maximum number of
messages per batch or using a timeout...

So it seems I would set batch size to 3 in my case, but our process is
supporting
multiple customers, so really, it's 3 predecessor events *per customer*.  Also,
I think I would need persistent state in the even of a crash.
Although I'd like to
avoid it, I can't help thinking I may have to implement yet another custom
Processor to support this use case.  (I already had to implement a custom
SFTP Processor to handle dynamic endpoint settings based on the customer-id).

I know that Camel is intended for ETL-ish sorts of problems, but I
think the Camel
approach is also appropriate for interactive, online processing, but
in that case,
it would be really helpful if endpoint configurations had the
additional dimension
of settings/configs indexed by id (such as customer-id, user-id,
account-id, etc.)

I could be wrong, but it seems that the static URI way of configuring endpoints
doesn't scale to process-flow/per-identity.  Those endpoints that do take
expressions help in this regard, but not all of them work with
expression-language
configuration, e.g. SFTP Consumer.

Thanks,

Chris

On Wed, May 15, 2013 at 3:46 PM, Raul Kripalani r...@evosent.com wrote:
 Hi Chris,

 I like this kind of problems ;-) Do these two messages share a correlation
 key?

 If yes, you can create a bean which acts like a Repository, accumulating
 message bodies or Exchanges under the correlation key. Could be implemented
 using Guava's MultiMap, or a DB if you need durable persistence, or a
 distributed cache if you require clustering without persistence.

 When a message arrives, you query the Repository for a previous message
 with the same correlation key. If it exists, you pick it up, do whatever
 manipulation is needed, and release the 3rd event. Kind of like a
 CyclicBarrier that stores the messages for later usage.

 P.S.: You could consider using the Aggregator EIP, but it'll block a thread
 until the 2nd event comes through.

 Regards,

 *Raúl Kripalani*
 Enterprise Architect, Open Source Integration specialist, Program
 Manager | Apache
 Camel Committer
 http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
 http://blog.raulkr.net | twitter: @raulvk

 On Wed, May 15, 2013 at 6:56 PM, Chris Wolf cwolf.a...@gmail.com wrote:

 In my process, I have two events that must be completed before the
 third can proceed.
 One event is the arrival of a certain JMS message and the other is the
 arrival of
 a certain file type.  The problem is, I cannot represent this in a
 route pipeline because
 one event may occur before the other and it's totally random from one
 run to another.

 In the abstract, I'm thinking one of the EIP patterns, either
 resequencer or scatter-gather
 applies, but I'm not certain how to do this in a concrete way with
 Camel.  If anyone has
 ideas, that would be great...

 Thanks,


 Chris



Re: What is the best approach to do an asynchronous rendezvous?

2013-05-15 Thread Chris Wolf
Hello Raúl,

The more I analyze the requirements, the more complicated it seems to get - it's
looking like I need to have a per-customer state machine to manage the flow.

To answer your questions:
- How many batches per day will you receive per customer?
one per day per customer - 3 predecessor events in, 1 result event out.

- Can the event batches interleave?
Yes, for sure, which raises another issue - now I'm thinking I need
per-customer, dynamically added route/route-policy

- What identifies a concrete batch of events?
  * a per-customer arrival of config info from external system via JMS
  * a per-customer arrival of message indicating certain external
processing is ready for next step from Camel-based process
  * a per-customer indication of a set of files have arrived via SFTP

- Do you have a finite list of customers? (and customer ids?)
   * I don't see how that factors in - assume the less restrictive case

- What is the payload of the fourth event?
  * an advisory JMS message that SFTP-processed files has completed
and that the
 external system can proceed base on these results.

Thanks,

Chris

On Wed, May 15, 2013 at 4:42 PM, Raul Kripalani r...@evosent.com wrote:
 Let me try and understand the timeline of these events. I will call a
 logical grouping of events event batch.
 If you don't mind answering the following questions, I can assist better:

- How many batches per day will you receive per customer?
- Can the event batches interleave?
- What identifies a concrete batch of events?
- Do you have a finite list of customers? (and customer ids?)
- What is the payload of the fourth event? Am I right asserting that you
receive 3 raw events, and you build some sort of composite or merged
message and release it as the 4th event?

 Regards,

 *Raúl Kripalani*
 Enterprise Architect, Open Source Integration specialist, Program
 Manager | Apache
 Camel Committer
 http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
 http://blog.raulkr.net | twitter: @raulvk

 On Wed, May 15, 2013 at 9:30 PM, Chris Wolf cwolf.a...@gmail.com wrote:

 Raúl,

 Thanks for your ideas.  Now it's 3 events without guaranteed order to
 arrive before triggering the fourth event.  As for correlation key, I
 guess it would be customer-id plus a timestamp
 that shows the event happened in the last several hours.

 The more I look into it, the more it seems like the Camel resequencer
 process may apply
 here:  http://camel.apache.org/resequencer.html

 The thing is, I'm not sure about setting batch size and/or timeout.
 The documentation
 states:

 ...messages are collected into a batch, either by a maximum number of
 messages per batch or using a timeout...

 So it seems I would set batch size to 3 in my case, but our process is
 supporting
 multiple customers, so really, it's 3 predecessor events *per customer*.
  Also,
 I think I would need persistent state in the even of a crash.
 Although I'd like to
 avoid it, I can't help thinking I may have to implement yet another custom
 Processor to support this use case.  (I already had to implement a custom
 SFTP Processor to handle dynamic endpoint settings based on the
 customer-id).

 I know that Camel is intended for ETL-ish sorts of problems, but I
 think the Camel
 approach is also appropriate for interactive, online processing, but
 in that case,
 it would be really helpful if endpoint configurations had the
 additional dimension
 of settings/configs indexed by id (such as customer-id, user-id,
 account-id, etc.)

 I could be wrong, but it seems that the static URI way of configuring
 endpoints
 doesn't scale to process-flow/per-identity.  Those endpoints that do take
 expressions help in this regard, but not all of them work with
 expression-language
 configuration, e.g. SFTP Consumer.

 Thanks,

 Chris

 On Wed, May 15, 2013 at 3:46 PM, Raul Kripalani r...@evosent.com wrote:
  Hi Chris,
 
  I like this kind of problems ;-) Do these two messages share a
 correlation
  key?
 
  If yes, you can create a bean which acts like a Repository, accumulating
  message bodies or Exchanges under the correlation key. Could be
 implemented
  using Guava's MultiMap, or a DB if you need durable persistence, or a
  distributed cache if you require clustering without persistence.
 
  When a message arrives, you query the Repository for a previous message
  with the same correlation key. If it exists, you pick it up, do whatever
  manipulation is needed, and release the 3rd event. Kind of like a
  CyclicBarrier that stores the messages for later usage.
 
  P.S.: You could consider using the Aggregator EIP, but it'll block a
 thread
  until the 2nd event comes through.
 
  Regards,
 
  *Raúl Kripalani*
  Enterprise Architect, Open Source Integration specialist, Program
  Manager | Apache
  Camel Committer
  http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
  http://blog.raulkr.net | twitter

Why is Camel silently dropping exceptions?

2013-05-14 Thread Chris Wolf
I implemented a custom route policy, which never appeared to be
starting.  I finally traced with a debugger
and found that it's throwing an exception, which appears to be discarded.

In the DefaultCamelContext.addRoutes(...) is this code:

if (routePolicyList != null  !routePolicyList.isEmpty()) {
  for (RoutePolicy policy : routePolicyList) {
// add policy as service if we have not already done that (eg
possible if two routes have the same service)
// this ensures Camel can control the lifecycle of the policy
if (!camelContext.hasService(policy)) {
  try {
camelContext.addService(policy);
} catch (Exception e) {
  throw ObjectHelper.wrapRuntimeCamelException(e); === Never seen
in log or console-  where is it?
}
  }
}

Obviously, I am not understanding how exceptions are handled in Camel
- can someone help me?

Thanks,

Chris


Re: Why is Camel silently dropping exceptions? *** DISREGARD ***

2013-05-14 Thread Chris Wolf
After RTFM, I see what's happening  - sorry for the noise...

On Tue, May 14, 2013 at 11:49 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 I implemented a custom route policy, which never appeared to be
 starting.  I finally traced with a debugger
 and found that it's throwing an exception, which appears to be discarded.

 In the DefaultCamelContext.addRoutes(...) is this code:

 if (routePolicyList != null  !routePolicyList.isEmpty()) {
   for (RoutePolicy policy : routePolicyList) {
 // add policy as service if we have not already done that (eg
 possible if two routes have the same service)
 // this ensures Camel can control the lifecycle of the policy
 if (!camelContext.hasService(policy)) {
   try {
 camelContext.addService(policy);
 } catch (Exception e) {
   throw ObjectHelper.wrapRuntimeCamelException(e); === Never seen
 in log or console-  where is it?
 }
   }
 }

 Obviously, I am not understanding how exceptions are handled in Camel
 - can someone help me?

 Thanks,

 Chris


How do we have the log: component log to a file?

2013-05-07 Thread Chris Wolf
I notice all kinds of options for the log compenent, except for how to
log to a file, as opposed to stdout:
http://camel.apache.org/log.html

I'm sure I'm some obvious piece of documentation on that, but I just
can't find it...
Any help?

Thanks,

Chris


Re: Will camel-websocket work in producer mode from a web app?

2013-05-04 Thread Chris Wolf
Thanks, ok.

On Sat, May 4, 2013 at 4:28 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 No the current camel-websocket is Jetty based.
 There is a ticket to create a new component using the Atmosphere
 framework which is container agnostic.

 On Sat, May 4, 2013 at 4:27 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 I see that it uses Jetty to launch a web server for camel-websocket in
 producer mode.  I'm seeing some
 dependency clashes with JBoss - before I sort that out - let me ask,
 will it even work?

 It seems a bit unconventional to launch an embedded servlet container
 from within a web application.


 Thanks,


 Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: CamelHttpUri and Enricher

2013-05-03 Thread Chris Wolf
You didn't paste any of your code

In any case, here's what I'm doing and it works:

from(direct:readSFTPConfig).routeId(sftp.config)
 .setHeader(Exchange.HTTP_URI, simple(http://
{{ds.host}}:{{ds.port}}/web/rest/client))
 .setHeader(Exchange.HTTP_QUERY, simple(clientId=${in.header.clientId}))
 .setHeader(Exchange.HTTP_METHOD, constant(GET))
  .enrich(http://ignored-set-by-header?throwExceptionOnFailure=false;)
[...]

On Fri, May 3, 2013 at 9:35 AM, Al Ferguson alfer...@hotmail.com wrote:

 Hi,

 It seems I cannot enrich, what am I doing wrong?

 Why is the originalExchange is null?


 Thanks,
 Al. F



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/CamelHttpUri-and-Enricher-tp5731924p5731975.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Issue in JSON marshalling

2013-05-03 Thread Chris Wolf
I an answer the first part:

xmlJsonFormat.setForceTopLevelObject(true);

See:

http://camel.apache.org/xmljson.html

You might need to instantiate the XmlJsonDataFormat using Spring bean rather
then Camel dataFormatsjson/

Currently I'm using Java-DSL, but I think it would look like:

bean id=jack class=org.apache.camel.model.dataformat.XmlJsonDataFormat
  property name=setForceTopLevelObject value=true/
/bean

or, if you include the 'p' namespace:

xmlns:p=http://www.springframework.org/schema/p;


bean id=jack class=org.apache.camel.model.dataformat.XmlJsonDataFormat
  p:setForceTopLevelObject=true/


On Fri, May 3, 2013 at 9:03 AM, sarfaraj sarfarajsay...@gmail.com wrote:

 I have camel route which exposes web service. I want to accept a data from
 web client and convert to JSON object.
 Curently i am using SOAP UI to send input to above web service.

 # Here is my input...
 soapenv:Body
   aaa:myData
arg0
 id1/id
  nameabc/name
  /arg0
   /aaa:myData
/soapenv:Body

   # My camel route is

 dataFormats
 json id=jack library=Jackson /
 /dataFormats

 route id=tcaRoute
 from uri=cxf:bean:soapEndpoint /
 marshal ref=jack /
 to uri=file:src/main/resources/out.txt /
 /route

 After running this, I get following Output i.e JSON data
 [{id:1,name:abc}]

 So instead of [{id:1,name:abc}] , I need
 {*myData*:{id:1,name:abc}}   because id and name are member of 
 myData
 class.
 Here it only return class member not the class.
 Addition to above i also want to remove [] from JSON output.

 *Could some one tell me what changes i need to do on JSON data format to
 achive this?*

 /Note: i referred http://camel.apache.org/json.html/

 /Sarfaraj



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Issue-in-JSON-marshalling-tp5731970.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Issue in JSON marshalling

2013-05-03 Thread Chris Wolf
Disregard my remark about using Spring to configure - I should have
read further down
on that page I referenced.  You can do this:

dataFormats
xmljson id=xmljsonWithOptions forceTopLevelObject=true
trimSpaces=true
 removeNamespacePrefixes=true expandableProperties=d e/
/dataFormats

On Fri, May 3, 2013 at 2:55 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 I an answer the first part:

 xmlJsonFormat.setForceTopLevelObject(true);

 See:

 http://camel.apache.org/xmljson.html

 You might need to instantiate the XmlJsonDataFormat using Spring bean rather
 then Camel dataFormatsjson/

 Currently I'm using Java-DSL, but I think it would look like:

 bean id=jack class=org.apache.camel.model.dataformat.XmlJsonDataFormat
   property name=setForceTopLevelObject value=true/
 /bean

 or, if you include the 'p' namespace:

 xmlns:p=http://www.springframework.org/schema/p;


 bean id=jack class=org.apache.camel.model.dataformat.XmlJsonDataFormat
   p:setForceTopLevelObject=true/


 On Fri, May 3, 2013 at 9:03 AM, sarfaraj sarfarajsay...@gmail.com wrote:

 I have camel route which exposes web service. I want to accept a data from
 web client and convert to JSON object.
 Curently i am using SOAP UI to send input to above web service.

 # Here is my input...
 soapenv:Body
   aaa:myData
arg0
 id1/id
  nameabc/name
  /arg0
   /aaa:myData
/soapenv:Body

   # My camel route is

 dataFormats
 json id=jack library=Jackson /
 /dataFormats

 route id=tcaRoute
 from uri=cxf:bean:soapEndpoint /
 marshal ref=jack /
 to uri=file:src/main/resources/out.txt /
 /route

 After running this, I get following Output i.e JSON data
 [{id:1,name:abc}]

 So instead of [{id:1,name:abc}] , I need
 {*myData*:{id:1,name:abc}}   because id and name are member of 
 myData
 class.
 Here it only return class member not the class.
 Addition to above i also want to remove [] from JSON output.

 *Could some one tell me what changes i need to do on JSON data format to
 achive this?*

 /Note: i referred http://camel.apache.org/json.html/

 /Sarfaraj



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Issue-in-JSON-marshalling-tp5731970.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Class Cast error upon deploying Camel web app

2013-05-03 Thread Chris Wolf
Has anyone seen this error?  I'm trying to deploy on JBoss6.  I was
able to deploy before without issues.  I guess
it's some kind of classloader-Hell issue due to JEE weirdness.

Caused by: java.lang.ClassCastException:
org.apache.xerces.dom.DeferredElementNSImpl cannot be cast to
org.w3c.dom.Element
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:100) 
[:2.2]
at 
com.sun.xml.bind.v2.runtime.BinderImpl.associativeUnmarshal(BinderImpl.java:156)
[:2.2]
at 
com.sun.xml.bind.v2.runtime.BinderImpl.unmarshal(BinderImpl.java:127) [:2.2]
at 
org.apache.camel.spring.handler.CamelNamespaceHandler.parseUsingJaxb(CamelNamespaceHandler.java:166)
[:2.10.4]
at 
org.apache.camel.spring.handler.CamelNamespaceHandler$CamelContextBeanDefinitionParser.doParse(CamelNamespaceHandler.java:306)
[:2.10.4]
at 
org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1419)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
[:


Re: Class Cast error upon deploying Camel web app

2013-05-03 Thread Chris Wolf
Thanks, I tried that and now the error as shown below.

Note that jboss6 was built with jdk-1.5, so it comes with it's own
xerces/xalan, so I'm
thinking there's a class with the JRE baked-in xerces/xalan (I'm running with
jre-1.6).  On the other hand, I have been able to deploy successfully
before and I did
even without the special camel-jboss classloader.  So do I need that?


20:18:03,218 INFO
org.springframework.beans.factory.BeanDefinitionStoreException:
Unexpected exception parsing XML document from ServletContext resource
[/WEB-INF/applicationContext.xml]; nested exception is
java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
 [STDOUT]
[...]
Caused by: java.lang.ClassCastException:
org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
javax.xml.parsers.DocumentBuilderFactory
at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown
Source) [:1.6.0_29]
at 
org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
[:3.1.0.RELEASE]
at 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
[:3.1.0.RELEASE]

On Fri, May 3, 2013 at 5:15 PM, Babak Vahdat
babak.vah...@swissonline.ch wrote:
 Hi

 I assume the JAXB version being provided by JBoss 6 is pretty outdated and
 not really compliant with Camel 2.10.4 as JBoss 6 is from end 2010.

 Do you have any jaxb-impl inside your WAR/EAR being included? If not maybe
 try to add the following dependency inside the POM of your Web-App so that
 jaxb-impl-2.1.13.jar gets included into your WEB-INF/lib folder of your WAR
 getting precedence to the one from JBoss AS.

 dependency
   groupIdcom.sun.xml.bind/groupId
   artifactIdjaxb-impl/artifactId
   version2.1.13/version
 /dependency

 Babak


 Chris Wolf wrote
 Has anyone seen this error?  I'm trying to deploy on JBoss6.  I was
 able to deploy before without issues.  I guess
 it's some kind of classloader-Hell issue due to JEE weirdness.

 Caused by: java.lang.ClassCastException:
 org.apache.xerces.dom.DeferredElementNSImpl cannot be cast to
 org.w3c.dom.Element
   at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:100)
 [:2.2]
   at
 com.sun.xml.bind.v2.runtime.BinderImpl.associativeUnmarshal(BinderImpl.java:156)
 [:2.2]
   at 
 com.sun.xml.bind.v2.runtime.BinderImpl.unmarshal(BinderImpl.java:127)
 [:2.2]
   at
 org.apache.camel.spring.handler.CamelNamespaceHandler.parseUsingJaxb(CamelNamespaceHandler.java:166)
 [:2.10.4]
   at
 org.apache.camel.spring.handler.CamelNamespaceHandler$CamelContextBeanDefinitionParser.doParse(CamelNamespaceHandler.java:306)
 [:2.10.4]
   at
 org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1419)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
 [:





 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Class-Cast-error-upon-deploying-Camel-web-app-tp5732000p5732001.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Class Cast error upon deploying Camel web app

2013-05-03 Thread Chris Wolf
Actually, I forgot the baked-in xerces/xalan are in namespace javax.xml, but
the standalone xerces/xalan are in org.apache.

In any case, I added some other components which caused Maven to
pull in xalan-2.7.0 and there was already xalan-2.7.1 proved by JBoss,
so I added exclusions in the pom.xml

Thanks,


Chris

On Fri, May 3, 2013 at 8:28 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Thanks, I tried that and now the error as shown below.

 Note that jboss6 was built with jdk-1.5, so it comes with it's own
 xerces/xalan, so I'm
 thinking there's a class with the JRE baked-in xerces/xalan (I'm running with
 jre-1.6).  On the other hand, I have been able to deploy successfully
 before and I did
 even without the special camel-jboss classloader.  So do I need that?


 20:18:03,218 INFO
 org.springframework.beans.factory.BeanDefinitionStoreException:
 Unexpected exception parsing XML document from ServletContext resource
 [/WEB-INF/applicationContext.xml]; nested exception is
 java.lang.ClassCastException:
 org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
 javax.xml.parsers.DocumentBuilderFactory
  [STDOUT]
 [...]
 Caused by: java.lang.ClassCastException:
 org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to
 javax.xml.parsers.DocumentBuilderFactory
 at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown
 Source) [:1.6.0_29]
 at 
 org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89)
 [:3.1.0.RELEASE]
 at 
 org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
 [:3.1.0.RELEASE]
 at 
 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
 [:3.1.0.RELEASE]

 On Fri, May 3, 2013 at 5:15 PM, Babak Vahdat
 babak.vah...@swissonline.ch wrote:
 Hi

 I assume the JAXB version being provided by JBoss 6 is pretty outdated and
 not really compliant with Camel 2.10.4 as JBoss 6 is from end 2010.

 Do you have any jaxb-impl inside your WAR/EAR being included? If not maybe
 try to add the following dependency inside the POM of your Web-App so that
 jaxb-impl-2.1.13.jar gets included into your WEB-INF/lib folder of your WAR
 getting precedence to the one from JBoss AS.

 dependency
   groupIdcom.sun.xml.bind/groupId
   artifactIdjaxb-impl/artifactId
   version2.1.13/version
 /dependency

 Babak


 Chris Wolf wrote
 Has anyone seen this error?  I'm trying to deploy on JBoss6.  I was
 able to deploy before without issues.  I guess
 it's some kind of classloader-Hell issue due to JEE weirdness.

 Caused by: java.lang.ClassCastException:
 org.apache.xerces.dom.DeferredElementNSImpl cannot be cast to
 org.w3c.dom.Element
   at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:100)
 [:2.2]
   at
 com.sun.xml.bind.v2.runtime.BinderImpl.associativeUnmarshal(BinderImpl.java:156)
 [:2.2]
   at 
 com.sun.xml.bind.v2.runtime.BinderImpl.unmarshal(BinderImpl.java:127)
 [:2.2]
   at
 org.apache.camel.spring.handler.CamelNamespaceHandler.parseUsingJaxb(CamelNamespaceHandler.java:166)
 [:2.10.4]
   at
 org.apache.camel.spring.handler.CamelNamespaceHandler$CamelContextBeanDefinitionParser.doParse(CamelNamespaceHandler.java:306)
 [:2.10.4]
   at
 org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1419)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
 [:3.1.0.RELEASE]
   at
 org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
 [:





 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Class-Cast-error-upon-deploying-Camel

Re: Problems with sftp in Camel 2.11.0

2013-04-23 Thread Chris Wolf
What happens if you specify the username as query parameter?

 sftp://myServer/subdir?username=myUserpassword=myPasswordstepwise=false

(I didn't upgrade, so I can't try it)

On Tue, Apr 23, 2013 at 8:33 AM, Bengt Rodehav be...@rodehav.com wrote:
 I just upgraded from Camel 2.10.3 to 2.11.0 and I now cannot get my sftp
 routes to work.

 I used to specify the sftp endpont as follows:

 sftp://myUser@myServer//subdir?password=myPasswordstepwise=false

 This worked fine in Camel 2.10.3. Note that I had to use double / to get
 it to work. Using Camel 2.11.0 I get the following error:

 org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
 change directory to: //

 I tried removing the double /, changing stepwise back and forth and also
 tried changin the separator to UNIX/Windows. Nothing helps. I can't find
 any combination that works.

 Does anyone have an idea what is happening and what has changed regarding
 this in Camel 2.11.0.

 /Bengt


Getting a JMS RA-managed ConnectionFactory on JBoss-6.1.0

2013-04-23 Thread Chris Wolf
I am using the jms:// component in a Spring DSL route in JBoss6.  I
want to publish and subscribe to a topic.  If I package my Camel in a
web app, it cannot do a JNDI lookup on java:JmsXA, which is the JMS
connection factory managed by a resource adapter.  If I package the
same code as just a plain Spring app and deploy via JBoss snowdrop
(kind of like CDI, but with Spring) - then the code successfully looks
up java:JmsXA.  Does anyone have any experience with accessing JMS
on a JEE server?

I also posted a more detailed JBoss-specific question in this regard at:
https://community.jboss.org/message/809836#809836

Thanks,

Chris


Re: JPA Component Behavior

2013-04-23 Thread Chris Wolf
If you look back at the entire thread:

http://camel.465427.n5.nabble.com/JPA-Component-Behavior-td5725781.html#a5731377

You can see that I solved this requirement by implementing a custom
PollingConsumerPollStrategy
called you use that plus configure the JPA consumer with startScheduler=false

Then, from your actionPerformed button code, or whatever code needs to trigger
the JPA poll, call a function with this code:

JpaConsumer jpaConsumer = null;

Route route = ctx.getRoute(routeId);
if (route == null) {
log.error(No route found with id \{}\, routeId);
return;
}

if ( ! (route.getConsumer() instanceof JpaConsumer)) {
log.error(Consumer must be of type JpaConsumer, the
configured consumer is of type {},
route.getConsumer().getClass().getName());
return;
}

try {
if (jpaConsumer.isSuspended() || jpaConsumer.isSuspending()) {
jpaConsumer.resume();
} else {
// first time here - need to start scheduler
// why is startScheduler() protected - can't it be public?
Class? superClass = jpaConsumer.getClass().getSuperclass();
superClass = superClass.getSuperclass();
Method m = superClass.getDeclaredMethod(startScheduler,
(Class?[]) null);
m.setAccessible(true);
m.invoke(jpaConsumer, (Object[]) null);
}
} catch (Exception e1) {
e1.printStackTrace();
}


This is working fine for my use-case which is the same as yours...

Regards,

Chris

On Tue, Apr 23, 2013 at 5:10 PM, Christian Jacob cjaco...@aol.com wrote:
 Hi Claus,I'm very eager to get that feature, too. My requirements for a new
 project are:
 run on every 1st of a month (or some other Quartz clause) and then select
 all objects with status = 0
 have a user interface for an administrator in which he/she can customize
 some search arguments such as a time range in which a JPA object was
 created, different values for the status field, and so on. I'm surely fit
 enough to deliver such a UI, e.g. as JEE2. From that UI, I can produce a
 route with customized query criteria. But the point is: how do I make the
 JPA consumer run on a button click?
 In my opinion, scheduled poll consuming is not the only sceanrio in which
 database or JPA retrieval is required. Do you see a way with which I can
 achieve that? Or do I have to wait?



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/JPA-Component-Behavior-tp5725781p5731377.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Is the result of this builder reusable? XQueryBuilder.xquery(//foo);

2013-04-19 Thread Chris Wolf
Thanks Willem - that worked.

On Tue, Apr 2, 2013 at 10:33 PM, Willem jiang willem.ji...@gmail.com wrote:
 I think you can use the XQueryBuilder in the Processor just like you showed.
 If you want to call the evaluateAsString multiple times, you need to make 
 sure the message body is reread able.
 You can convert the message body into String before you process it in your 
 processor.


 --
 Willem Jiang

 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Web: http://www.fusesource.com | http://www.redhat.com
 Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
 (English)
   http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
 Twitter: willemjiang
 Weibo: 姜宁willem




 On Tuesday, April 2, 2013 at 11:01 PM, Chris Wolf wrote:

 I want to perform an XQuery outside of DSL (in a Processor). Something like:

 XQueryBuilder hostXQ = XQueryBuilder
 .xquery(//remote[remoteId/@value='CBOE34']/server/@value);
 String host = hostXQ.evaluateAsString(exchange);

 Second question is can I parameterize the XQuery like so:

 XQueryBuilder hostXQ = XQueryBuilder
 .xquery(//remote[remoteId/@value=$accountId]/server/@value);

 hostXQ.setParameters(new HashMapString, Object() {{
 put(accountId, CBOE34);}});
 String host1 = hostXQ.evaluateAsString(exchange);

 hostXQ.setParameters(new HashMapString, Object() {{
 put(accountId, CBOE78);}});
 String host2 = hostXQ.evaluateAsString(exchange);


 Thanks,


 Chris




Why doesn't SFTP move option work??

2013-04-17 Thread Chris Wolf
Trying to use Sftp component.   I am using localWorkDirectory because
I don't want the whole files loaded into memory.
Seems like the files *are* being downloaded but they are NOT being
moved, on the remote side to the directory indicated by the move
option.


Here, on a poll, it gets a file, while downloading to
localWorkDirectory, the file's name is appended with .inprogress,
then it's
renamed to the base file name without .inprogress - so far, so good,
except on the server-side, it's not moved to the move directory.

[#4 - sftp://localhost/download] SftpOperations DEBUG Retrieve file to
local work file result: true
[#4 - sftp://localhost/download] SftpOperations TRACE Renaming local
in progress file from:
\tmp\local\ftpwork\ADPT5_MKT_20120319_VOIR_DAILY.csv.inprogress to:
\tmp\local\ftpwork\ADPT5_MKT_20120319_VOIR_DAILY.csv
[#4 - sftp://localhost/download] SftpConsumer  TRACE Retrieved file:
download/ADPT5_MKT_20120319_VOIR_DAILY.csv from:
Endpoint[sftp://localhost/download]

...then, at poll n+1, I see:

[#4 - sftp://localhost/download] SftpConsumer TRACE
SftpFile[fileName=ADPT5_MKT_20120319_VOIR_DAILY.csv,
longName=-rwxrwxrwx   1 adpt5adpt5  298313 Apr 17 09:42
ADPT5_MKT_20120319_VOIR_DAILY.csv, dir=false]
[#4 - sftp://localhost/download] SftpConsumer TRACE Skipping as file
is already in progress: ADPT5_MKT_20120319_VOIR_DAILY.csv

I guess that's the idempotent mechanism, but that file should have
been moved out of that directory.


SftpConfiguration:

chmod = null,
ciphers = null,
compression = 0,
connectTimeout = 1,
directory = download,
host = localhost,
knownHostsFile = null,
password = adpt5,
port = 22,
privateKeyFile = null,
privateKeyFilePassphrase = null,
protocol = sftp,
separator = UNIX,
serverAliveCountMax = 1,
serverAliveInterval = 0,
siteCommand = null,
soTimeout = 0,
strictHostKeyChecking = no,
timeout = 3,
username = adpt5,
binary = true,
passiveMode = false,
stepwise = true,
throwExceptionOnConnectFailed = false

[1) thread #0 - timer://kickoff] INFO  SftpEndpoint:
antFilter = null,
bufferSize = 131072,
camelContext = CamelContext(camel-1),
charset = null,
component = org.apache.camel.component.file.remote.SftpComponent@1e34f445,
configuration = download,
consumerProperties = null,
doneFileName = null,
endpointConfiguration =
org.apache.camel.impl.MappedEndpointConfiguration@8292f75a,
endpointKey = sftp://localhost/download,
endpointUri = sftp://localhost/download,
exchangePattern = InOnly,
exchanges = [Exchange[ADPT5_MKT_20090211_MICF.csv],
Exchange[ADPT5_MKT_20090211_MINOCF.csv],
Exchange[ADPT5_MKT_20090305_VOE.csv],
Exchange[ADPT5_MKT_20090305_VOIR.csv],
Exchange[ADPT5_MKT_20120319_DAILY.csv],
Exchange[ADPT5_MKT_20120319_FX.csv],
Exchange[ADPT5_MKT_20120319_MTX_DAILY.csv],
Exchange[ADPT5_MKT_20120319_VOIR_DAILY.csv],
Exchange[ADPT5_MKT_20121121_HISTORY_EUR_IRBank-FZ-D.csv],
Exchange[ADPT5_MKT_20121121_HISTORY_EUR_IRBank-FZ-M.csv],
Exchange[ADPT5_MKT_20121121_HISTORY_EUR_IRBank-FZ-Y.csv]],
exclude = null,
exclusiveReadLockStrategy = null,
fileExist = Override,
fileName = null,
fileSeparator = /,
filter = ms.algo.adapt.camel.cpmd.CPMDFileFilter@54aa2db,
genericFileProcessStrategy =
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@67b14530,
id = endpoint13,
idempotentRepository = null,
include = null,
inProgressRepository =
org.apache.camel.processor.idempotent.MemoryIdempotentRepository@563b100c,
localWorkDirectory = /tmp/local/ftpwork,
maxDepth = 2147483647,
maximumReconnectAttempts = 3,
maxMessagesPerPoll = 0,
minDepth = 0,
move = ${file:parent}/../archive/${file:onlyname},,
moveExisting = null,
moveFailed = null,
preMove = null,
processStrategy =
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@67b14530,
readLock = none,
readLockCheckInterval = 5000,
readLockMinLength = 1,
readLockTimeout = 2,
reconnectDelay = 1000,
scheme = sftp,
sortBy = null,
sorter = null,
status = Started,
tempFileName = null,
tempPrefix = null,
version = 2.10.4,
allowNullBody = false,
autoCreate = true,
delete = false,
directoryMustExist = false,
disconnect = false,
eagerDeleteTargetFile = true,
eagerMaxMessagesPerPoll = true,
fastExistsCheck = false,
flatten = false,
keepLastModified = false,
lenientProperties = false,
noop = false,
recursive = false,
runAllowed = true,
singleton = true,
started = true,
starting = false,
startingDirectoryMustExist = false,
stopped = false,
stopping = false,
suspended = false,
suspending = false,
synchronous = false


Re: Why doesn't SFTP move option work??

2013-04-17 Thread Chris Wolf
I notice there's a unit test, FromFtpMoveFileTest, for plain FTP, but
not for SFTP - should I file a bug, or am I doing something
wrong?

On Wed, Apr 17, 2013 at 11:39 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 Trying to use Sftp component.   I am using localWorkDirectory because
 I don't want the whole files loaded into memory.
 Seems like the files *are* being downloaded but they are NOT being
 moved, on the remote side to the directory indicated by the move
 option.


 Here, on a poll, it gets a file, while downloading to
 localWorkDirectory, the file's name is appended with .inprogress,
 then it's
 renamed to the base file name without .inprogress - so far, so good,
 except on the server-side, it's not moved to the move directory.

 [#4 - sftp://localhost/download] SftpOperations DEBUG Retrieve file to
 local work file result: true
 [#4 - sftp://localhost/download] SftpOperations TRACE Renaming local
 in progress file from:
 \tmp\local\ftpwork\ADPT5_MKT_20120319_VOIR_DAILY.csv.inprogress to:
 \tmp\local\ftpwork\ADPT5_MKT_20120319_VOIR_DAILY.csv
 [#4 - sftp://localhost/download] SftpConsumer  TRACE Retrieved file:
 download/ADPT5_MKT_20120319_VOIR_DAILY.csv from:
 Endpoint[sftp://localhost/download]

 ...then, at poll n+1, I see:

 [#4 - sftp://localhost/download] SftpConsumer TRACE
 SftpFile[fileName=ADPT5_MKT_20120319_VOIR_DAILY.csv,
 longName=-rwxrwxrwx   1 adpt5adpt5  298313 Apr 17 09:42
 ADPT5_MKT_20120319_VOIR_DAILY.csv, dir=false]
 [#4 - sftp://localhost/download] SftpConsumer TRACE Skipping as file
 is already in progress: ADPT5_MKT_20120319_VOIR_DAILY.csv

 I guess that's the idempotent mechanism, but that file should have
 been moved out of that directory.


 SftpConfiguration:

 chmod = null,
 ciphers = null,
 compression = 0,
 connectTimeout = 1,
 directory = download,
 host = localhost,
 knownHostsFile = null,
 password = adpt5,
 port = 22,
 privateKeyFile = null,
 privateKeyFilePassphrase = null,
 protocol = sftp,
 separator = UNIX,
 serverAliveCountMax = 1,
 serverAliveInterval = 0,
 siteCommand = null,
 soTimeout = 0,
 strictHostKeyChecking = no,
 timeout = 3,
 username = adpt5,
 binary = true,
 passiveMode = false,
 stepwise = true,
 throwExceptionOnConnectFailed = false

 [1) thread #0 - timer://kickoff] INFO  SftpEndpoint:
 antFilter = null,
 bufferSize = 131072,
 camelContext = CamelContext(camel-1),
 charset = null,
 component = org.apache.camel.component.file.remote.SftpComponent@1e34f445,
 configuration = download,
 consumerProperties = null,
 doneFileName = null,
 endpointConfiguration =
 org.apache.camel.impl.MappedEndpointConfiguration@8292f75a,
 endpointKey = sftp://localhost/download,
 endpointUri = sftp://localhost/download,
 exchangePattern = InOnly,
 exchanges = [Exchange[ADPT5_MKT_20090211_MICF.csv],
 Exchange[ADPT5_MKT_20090211_MINOCF.csv],
 Exchange[ADPT5_MKT_20090305_VOE.csv],
 Exchange[ADPT5_MKT_20090305_VOIR.csv],
 Exchange[ADPT5_MKT_20120319_DAILY.csv],
 Exchange[ADPT5_MKT_20120319_FX.csv],
 Exchange[ADPT5_MKT_20120319_MTX_DAILY.csv],
 Exchange[ADPT5_MKT_20120319_VOIR_DAILY.csv],
 Exchange[ADPT5_MKT_20121121_HISTORY_EUR_IRBank-FZ-D.csv],
 Exchange[ADPT5_MKT_20121121_HISTORY_EUR_IRBank-FZ-M.csv],
 Exchange[ADPT5_MKT_20121121_HISTORY_EUR_IRBank-FZ-Y.csv]],
 exclude = null,
 exclusiveReadLockStrategy = null,
 fileExist = Override,
 fileName = null,
 fileSeparator = /,
 filter = ms.algo.adapt.camel.cpmd.CPMDFileFilter@54aa2db,
 genericFileProcessStrategy =
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@67b14530,
 id = endpoint13,
 idempotentRepository = null,
 include = null,
 inProgressRepository =
 org.apache.camel.processor.idempotent.MemoryIdempotentRepository@563b100c,
 localWorkDirectory = /tmp/local/ftpwork,
 maxDepth = 2147483647,
 maximumReconnectAttempts = 3,
 maxMessagesPerPoll = 0,
 minDepth = 0,
 move = ${file:parent}/../archive/${file:onlyname},,
 moveExisting = null,
 moveFailed = null,
 preMove = null,
 processStrategy =
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@67b14530,
 readLock = none,
 readLockCheckInterval = 5000,
 readLockMinLength = 1,
 readLockTimeout = 2,
 reconnectDelay = 1000,
 scheme = sftp,
 sortBy = null,
 sorter = null,
 status = Started,
 tempFileName = null,
 tempPrefix = null,
 version = 2.10.4,
 allowNullBody = false,
 autoCreate = true,
 delete = false,
 directoryMustExist = false,
 disconnect = false,
 eagerDeleteTargetFile = true,
 eagerMaxMessagesPerPoll = true,
 fastExistsCheck = false,
 flatten = false,
 keepLastModified = false,
 lenientProperties = false,
 noop = false,
 recursive = false,
 runAllowed = true,
 singleton = true,
 started = true,
 starting = false,
 startingDirectoryMustExist = false,
 stopped = false,
 stopping = false,
 suspended = false,
 suspending = false,
 synchronous = false


Re: Why doesn't SFTP move option work??

2013-04-17 Thread Chris Wolf
I took the FromFtpMoveFileTest and modified it for SFTP - that works,
so move works
for SFTP.  My problem is that because the current release requires
hard-coding the
URI for (s)ftp(s) consumer - I implemented a custom processor that
instantiates the SFTP component,
SFTP endpoint and SFTP consumer, all programatically.  Obviously, I'm
missing something.
Unfortunately, it's pretty much a show-stopper for us to not be able
to SFTP *from* (consume)
dynamically (runtime-calculated) URIs.

On Wed, Apr 17, 2013 at 4:54 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 I notice there's a unit test, FromFtpMoveFileTest, for plain FTP, but
 not for SFTP - should I file a bug, or am I doing something
 wrong?

 On Wed, Apr 17, 2013 at 11:39 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 Trying to use Sftp component.   I am using localWorkDirectory because
 I don't want the whole files loaded into memory.
 Seems like the files *are* being downloaded but they are NOT being
 moved, on the remote side to the directory indicated by the move
 option.


 Here, on a poll, it gets a file, while downloading to
 localWorkDirectory, the file's name is appended with .inprogress,
 then it's
 renamed to the base file name without .inprogress - so far, so good,
 except on the server-side, it's not moved to the move directory.

 [#4 - sftp://localhost/download] SftpOperations DEBUG Retrieve file to
 local work file result: true
 [#4 - sftp://localhost/download] SftpOperations TRACE Renaming local
 in progress file from:
 \tmp\local\ftpwork\ADPT5_MKT_20120319_VOIR_DAILY.csv.inprogress to:
 \tmp\local\ftpwork\ADPT5_MKT_20120319_VOIR_DAILY.csv
 [#4 - sftp://localhost/download] SftpConsumer  TRACE Retrieved file:
 download/ADPT5_MKT_20120319_VOIR_DAILY.csv from:
 Endpoint[sftp://localhost/download]

 ...then, at poll n+1, I see:

 [#4 - sftp://localhost/download] SftpConsumer TRACE
 SftpFile[fileName=ADPT5_MKT_20120319_VOIR_DAILY.csv,
 longName=-rwxrwxrwx   1 adpt5adpt5  298313 Apr 17 09:42
 ADPT5_MKT_20120319_VOIR_DAILY.csv, dir=false]
 [#4 - sftp://localhost/download] SftpConsumer TRACE Skipping as file
 is already in progress: ADPT5_MKT_20120319_VOIR_DAILY.csv

 I guess that's the idempotent mechanism, but that file should have
 been moved out of that directory.


 SftpConfiguration:

 chmod = null,
 ciphers = null,
 compression = 0,
 connectTimeout = 1,
 directory = download,
 host = localhost,
 knownHostsFile = null,
 password = adpt5,
 port = 22,
 privateKeyFile = null,
 privateKeyFilePassphrase = null,
 protocol = sftp,
 separator = UNIX,
 serverAliveCountMax = 1,
 serverAliveInterval = 0,
 siteCommand = null,
 soTimeout = 0,
 strictHostKeyChecking = no,
 timeout = 3,
 username = adpt5,
 binary = true,
 passiveMode = false,
 stepwise = true,
 throwExceptionOnConnectFailed = false

 [1) thread #0 - timer://kickoff] INFO  SftpEndpoint:
 antFilter = null,
 bufferSize = 131072,
 camelContext = CamelContext(camel-1),
 charset = null,
 component = org.apache.camel.component.file.remote.SftpComponent@1e34f445,
 configuration = download,
 consumerProperties = null,
 doneFileName = null,
 endpointConfiguration =
 org.apache.camel.impl.MappedEndpointConfiguration@8292f75a,
 endpointKey = sftp://localhost/download,
 endpointUri = sftp://localhost/download,
 exchangePattern = InOnly,
 exchanges = [Exchange[ADPT5_MKT_20090211_MICF.csv],
 Exchange[ADPT5_MKT_20090211_MINOCF.csv],
 Exchange[ADPT5_MKT_20090305_VOE.csv],
 Exchange[ADPT5_MKT_20090305_VOIR.csv],
 Exchange[ADPT5_MKT_20120319_DAILY.csv],
 Exchange[ADPT5_MKT_20120319_FX.csv],
 Exchange[ADPT5_MKT_20120319_MTX_DAILY.csv],
 Exchange[ADPT5_MKT_20120319_VOIR_DAILY.csv],
 Exchange[ADPT5_MKT_20121121_HISTORY_EUR_IRBank-FZ-D.csv],
 Exchange[ADPT5_MKT_20121121_HISTORY_EUR_IRBank-FZ-M.csv],
 Exchange[ADPT5_MKT_20121121_HISTORY_EUR_IRBank-FZ-Y.csv]],
 exclude = null,
 exclusiveReadLockStrategy = null,
 fileExist = Override,
 fileName = null,
 fileSeparator = /,
 filter = ms.algo.adapt.camel.cpmd.CPMDFileFilter@54aa2db,
 genericFileProcessStrategy =
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@67b14530,
 id = endpoint13,
 idempotentRepository = null,
 include = null,
 inProgressRepository =
 org.apache.camel.processor.idempotent.MemoryIdempotentRepository@563b100c,
 localWorkDirectory = /tmp/local/ftpwork,
 maxDepth = 2147483647,
 maximumReconnectAttempts = 3,
 maxMessagesPerPoll = 0,
 minDepth = 0,
 move = ${file:parent}/../archive/${file:onlyname},,
 moveExisting = null,
 moveFailed = null,
 preMove = null,
 processStrategy =
 org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@67b14530,
 readLock = none,
 readLockCheckInterval = 5000,
 readLockMinLength = 1,
 readLockTimeout = 2,
 reconnectDelay = 1000,
 scheme = sftp,
 sortBy = null,
 sorter = null,
 status = Started,
 tempFileName = null,
 tempPrefix = null,
 version = 2.10.4,
 allowNullBody = false,
 autoCreate = true,
 delete = false,
 directoryMustExist = false,
 disconnect

Re: Is there a way to programmatically get the the downstream endpoint from a custom Processor?

2013-04-12 Thread Chris Wolf
The reason I asked is because now I have to set default Endpoint or URI in
the producer template - it would be nice if the default setting would be
the next down-stream endpoint.


On Thu, Apr 11, 2013 at 8:53 PM, Willem jiang willem.ji...@gmail.comwrote:

 ProducerTemplate can send the exchange to any other endpoints.
 Processor is decoupled with the camel route, I don't think you can get the
 downstream endpoint from the custom Processor itself.


 --
 Willem Jiang

 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Web: http://www.fusesource.com | http://www.redhat.com
 Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
 (English)
   http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
 Twitter: willemjiang
 Weibo: 姜宁willem





 On Friday, April 12, 2013 at 8:08 AM, Chris Wolf wrote:

  Hello,
 
  I'm implementing a custom Processor - it will have a ProducerTemplate,
  which will always
  send to the next Endpoint, downstream - why do I have to set the
  defaultEndpoint
  or defaultEndpointURI? That guarantees hardcoding. Isn't there someway to
  indicate,
  upon CamelContext.createProducerTemplate() to imply next downstream
  Endpoint?
 
  It's not a show-stopper, I can explicitly configure the Producer
  defaultEndpoint, but I don't
  know why it can't default to the next down-stream consuming endpoint...
 
  Thanks,
 
  Chris





Re: Is there a standard, DSL way to put message body in registry?

2013-04-12 Thread Chris Wolf
Right - ok, that sounds good.  I forgot that a property value can be an
object not just a String.


On Thu, Apr 11, 2013 at 9:46 PM, Willem jiang willem.ji...@gmail.comwrote:

 If you put a object into the exchange properties, you can lookup it later
 in other processor.


 --
 Willem Jiang

 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Web: http://www.fusesource.com | http://www.redhat.com
 Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
 (English)
   http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
 Twitter: willemjiang
 Weibo: 姜宁willem





 On Thursday, April 11, 2013 at 10:41 PM, Chris Wolf wrote:

  I know I could implement a custom Processor, but I was wondering if there
  was a Java and Spring DSL way to put objects in the registry and lookup
  them up later.
 
  Thanks,
 
 
  Chris





I'm confused about FTP option localWorkDirectory

2013-04-12 Thread Chris Wolf
I read the documentation:
http://camel.apache.org/ftp.html

and want to FTP large files, as such, I don't want the entire file
loaded into memory - I thought the localWorkDirectory option would
allow this.  That web page says,
It will download the remote file directly to a local file stream. The
java.io.File handle is then used as the Exchange body.

Well, that's not what I'm seeing - what I see is that the body is of type

, BodyType:org.apache.camel.component.file.remote.RemoteFile
, Body:[Body is file based: RemoteFile[giant_dataset.csv]]

...but I expected it to be of type java.io.File, like the local
file:// component and like the ftp documentation says.

When stepping through the code, I see that the file *is* being
downloaded to the work dir.
If I look at the various fields of RemoteFile in the debugger, I don't
see anything indicating a file path which includes the local work
directory.

So how, exactly, does the localWorkDirectory mechanism work and is it
true that it won't load the whole file into memory?  Why isn't the
exchange body of type java.io.File or java.io.InputStream? - I'm
confused - please help...

-Chris


Re: Is there a way to programmatically get the the downstream endpoint from a custom Processor?

2013-04-12 Thread Chris Wolf
I can see how that would work, but if I'm going to register the
down-stream endpoint,
I may as well just set the ProducerTemplate, but it's an interesting idea..

On Fri, Apr 12, 2013 at 12:35 PM, Raul Kripalani r...@evosent.com wrote:
 One solution is to parametrize the downstream endpoint in the Registry.

 from(...).process(new MyProcessor()).to(myDownstreamEndpoint);

 where myDownstreamEndpoint is a bean property of type String that gets
 injected via Spring or Blueprint during the route initialization.

 It should always have the same bean name in all contexts, e.g.
 (myDownstreamEndpoint), so then from MyProcessor you can do the following
 lookup:

 String uri = exchange.getRegistry().lookup(myDownstreamEndpoint,
 String.class);

 The condition is, of course, that all Camel Contexts using this processor
 must have this property in their Application/Blueprint Contexts.

 Hope that helps,

 *Raúl Kripalani*
 Enterprise Architect, Open Source Integration specialist, Program
 Manager | Apache
 Camel Committer
 http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
 http://blog.raulkr.net | twitter: @raulvk

 On Fri, Apr 12, 2013 at 4:36 PM, Chris Wolf cwolf.a...@gmail.com wrote:

 The reason I asked is because now I have to set default Endpoint or URI in
 the producer template - it would be nice if the default setting would be
 the next down-stream endpoint.


 On Thu, Apr 11, 2013 at 8:53 PM, Willem jiang willem.ji...@gmail.com
 wrote:

  ProducerTemplate can send the exchange to any other endpoints.
  Processor is decoupled with the camel route, I don't think you can get
 the
  downstream endpoint from the custom Processor itself.
 
 
  --
  Willem Jiang
 
  Red Hat, Inc.
  FuseSource is now part of Red Hat
  Web: http://www.fusesource.com | http://www.redhat.com
  Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
  (English)
http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
  Twitter: willemjiang
  Weibo: 姜宁willem
 
 
 
 
 
  On Friday, April 12, 2013 at 8:08 AM, Chris Wolf wrote:
 
   Hello,
  
   I'm implementing a custom Processor - it will have a ProducerTemplate,
   which will always
   send to the next Endpoint, downstream - why do I have to set the
   defaultEndpoint
   or defaultEndpointURI? That guarantees hardcoding. Isn't there someway
 to
   indicate,
   upon CamelContext.createProducerTemplate() to imply next downstream
   Endpoint?
  
   It's not a show-stopper, I can explicitly configure the Producer
   defaultEndpoint, but I don't
   know why it can't default to the next down-stream consuming endpoint...
  
   Thanks,
  
   Chris
 
 
 



Re: I'm confused about FTP option localWorkDirectory

2013-04-12 Thread Chris Wolf
Ok, I forgot about implicit type conversion.  I can see that if
RemoteFile gets routed to,
for example, a bean method with signature public void
processFile(InputStream input),
that Camel will convert RemoteFile to BufferedInputStream.  I also was
able to get
a valid java.io.File instance by calling .convertBodyTo(File.class);

Ok, I'm good to go...

Thanks,

Chris

On Fri, Apr 12, 2013 at 12:25 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 I read the documentation:
 http://camel.apache.org/ftp.html

 and want to FTP large files, as such, I don't want the entire file
 loaded into memory - I thought the localWorkDirectory option would
 allow this.  That web page says,
 It will download the remote file directly to a local file stream. The
 java.io.File handle is then used as the Exchange body.

 Well, that's not what I'm seeing - what I see is that the body is of type

 , BodyType:org.apache.camel.component.file.remote.RemoteFile
 , Body:[Body is file based: RemoteFile[giant_dataset.csv]]

 ...but I expected it to be of type java.io.File, like the local
 file:// component and like the ftp documentation says.

 When stepping through the code, I see that the file *is* being
 downloaded to the work dir.
 If I look at the various fields of RemoteFile in the debugger, I don't
 see anything indicating a file path which includes the local work
 directory.

 So how, exactly, does the localWorkDirectory mechanism work and is it
 true that it won't load the whole file into memory?  Why isn't the
 exchange body of type java.io.File or java.io.InputStream? - I'm
 confused - please help...

 -Chris


Is there a standard, DSL way to put message body in registry?

2013-04-11 Thread Chris Wolf
I know I could implement a custom Processor, but I was wondering if there
was a Java and Spring DSL way to put objects in the registry and lookup
them up later.

Thanks,


Chris


Is there a way to programmatically get the the downstream endpoint from a custom Processor?

2013-04-11 Thread Chris Wolf
Hello,

I'm implementing a custom Processor - it will have a ProducerTemplate,
which will always
send to the next Endpoint, downstream - why do I have to set the
defaultEndpoint
or defaultEndpointURI?  That guarantees hardcoding.  Isn't there someway to
indicate,
upon CamelContext.createProducerTemplate() to imply next downstream
Endpoint?

It's not a show-stopper, I can explicitly configure the Producer
defaultEndpoint, but I don't
know why it can't default to the next down-stream consuming endpoint...

Thanks,

Chris


Re: Camel routing issue

2013-04-10 Thread Chris Wolf
You're asking about a problem with CARD_EVENT_PREDICATE without including
the definition of that?


On Tue, Apr 9, 2013 at 8:31 AM, prabumc...@gmail.com
prabumc...@gmail.comwrote:

 Hi Chris,

 from(CARD_TYPE_SPECIFIC_QNAME).choice()
 .when(SCHEDULE_PREDICATE).multicast().to(CARD_QNAME,SCHEDULE_QNAME);
 .when(CARD_EVENT_PREDICATE).to(CARD_EVENT_CARE_HANDLER_QNAME)
 .otherwise()
 .setHeader(PROPERTY_ORIGINAL_DESTINATION,
 constant(PROPERTY_ORIGINAL_DESTINATION_VALUE))
 .to(ERQ_QNAME)
 .end();

 When i compile above code i am getting followin

 lder.java:115: illegal start of expression
 .when(CARD_EVENT_PREDICATE).to(CARD_EVENT_CARE_HANDLER_QNAME)
   ^

 Please kindly help me,i am doing any syntax mistake here

 *Regards*
 Prabu.N





 On Fri, Apr 5, 2013 at 3:58 PM, Prabu prabumc...@gmail.com wrote:

  Thanks Chris/Claus it worked,
 
 
  Hi Chris/Claus,
 
  When running active-mq 5.8 i am getting following issue,do you have any
  idea.
 
  2013-04-05 05:26:16,312 | WARN  | Async error occurred:
  java.lang.IllegalStateException: Cannot add a consumer to a connection
 that
  had not been registered:
 
 
  *Regards*
  Prabu.N
 
 
 
 
  On Thu, Apr 4, 2013 at 6:55 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 
  1.) You're NOT using my code - it's still the same as you had before
  2.) You're still calling setHeader(java.lang.String, java.lang.String)
   even though I tried to tell you that it has to be
   setHeader(java.lang.String, org.apache.camel.Expression)
 
  On Wed, Apr 3, 2013 at 2:51 PM, Prabu prabumc...@gmail.com wrote:
   Please kindly help me...
  
   On Apr 3, 2013 8:54 PM, Prabu prabumc...@gmail.com wrote:
  
   Hi Chris,
  
   I used your code.But i am getting following compilation error
  
   lder.java:92: cannot find symbol
   symbol  : method setHeader(java.lang.String,java.lang.String)
   location: class org.apache.camel.model.ChoiceDefinition
 .otherwise().setHeader(MyHeader,sdfsdf)
  
  
   Note: I am using camel 2.10 version
  
  
  
   On Wed, Apr 3, 2013 at 8:22 PM, Chris Wolf cwolf.a...@gmail.com
  wrote:
  
   Hi Prabu,
  
   I don't mind helping, but could you continue to use the
   users@camel.apache.org rather then my private email?  That way, if
   other people have similar issues, they can benefit.
  
  
   from(GMD_TEST_TYPE_SPECIFIC_QNAME).choice(
  .when(TEST_EVENT_PREDICATE).to(LOGGING_HANDLER_QNAME)
  .otherwise()
  .setHeader(MyHeader, constant(some-value))  // ===
 Set
   Header
  .to(ERQ_QNAME)
  .end();
  
   This technique will use the simple language function constant to
   set a string constant value.
   If the value you need to set is dynamic, then you could use a
   property placeholder.
  
   from(GMD_TEST_TYPE_SPECIFIC_QNAME).choice(
  .when(TEST_EVENT_PREDICATE).to(LOGGING_HANDLER_QNAME)
  .otherwise()
  .setHeader(MyHeader, constant({{some-prop}}))  //
 ===
  Set
   Header
  .to(ERQ_QNAME)
  .end();
  
   There are even more sophisticated ways to acquire dynamic values:
  
   http://camel.apache.org/python.html
  
   Regards,
  
   Chris
  
   On Wed, Apr 3, 2013 at 9:52 AM, Prabu prabumc...@gmail.com wrote:
I have code like this,
   
from(GMD_TEST_TYPE_SPECIFIC_QNAME).choice()
  .when(TEST_EVENT_PREDICATE).to(LOGGING_HANDLER_QNAME)
  .otherwise().to(ERQ_QNAME)
   .end();
   
from(DEACTIVATIN_TYPE_SPECIFIC_QNAME).choice()
   
.when(ALERT_FAILURE_HANDLER_PREDICATE).to(ALERT_FAILURE_QNAME)
  .otherwise().to(ERQ_QNAME)
.end();
   
I want to set some values to header inside otherwise that is
 before
message
move to ERQ_QNAME.
   
please kindly help me how to do that.
   
Regards
Prabu.N
   
   
On Tue, Apr 2, 2013 at 10:52 PM, Prabu prabumc...@gmail.com
  wrote:
   
No,i didn't received ...
   
Regards
Prabu.N
   
   
On Tue, Apr 2, 2013 at 7:31 PM, Chris Wolf cwolf.a...@gmail.com
 
wrote:
   
Hi Prabu,
   
Just out of curiosity - I am wondering if saw my email I sent
yesterday in response to your question?
I sent it to users@camel.apache.org with the subject,
Content-based routing with Expressions and Predicates...
   
Regards,
   
Chris
   
On Tue, Apr 2, 2013 at 4:17 AM, prabumc...@gmail.com
prabumc...@gmail.com wrote:
 I have found solution in internet using Predicate  we can
  achieve
 this,

 But,one doubt in the link
 http://camel.apache.org/predicate.html,Theymentioned that we
  can
 use
 AND and OR in Predicate

 I have added below code in project,But i am getting
 compilation
 error.Please kindly help

 *Predicate god = and(admin, or(body().contains(Camel Rider),
 header(type).isEqualTo(god)));*

 *Thanks*
 Prabu.N


 On Mon, Apr 1, 2013 at 9:05 PM, Prabu prabumc

Re: Callback after startup from org.apache.camel.main.Main afterStart()

2013-04-10 Thread Chris Wolf
What I did was extend Main, overriding:
protected AbstractApplicationContext createDefaultApplicationContext();

The overridden method looks like:

@Override
public AbstractApplicationContext createDefaultApplicationContext() {
AbstractApplicationContext appctx =
super.createDefaultApplicationContext();
appctx.addApplicationListener(new
ApplicationListenerContextStartedEvent() {
@Override
public void onApplicationEvent(ContextStartedEvent event) {
LOG.info(** CONTEXT STARTED...);
 }});

return appctx;
}

Works for me...

   -Chris



On Tue, Apr 9, 2013 at 9:49 AM, Claus Ibsen claus.ib...@gmail.com wrote:

 Hi

 Yeah we probably need some API on MainSupport so you can add a custom
 EventNotifier, which we then add to the CamelContext before its
 started.

 Though another option that may be easier is just to have a beforeStart
 | beforeStop method which you can implement and do your custom code
 there. A bit like what you did, but IMHO should have simpler api's
 than a Callable et all.

 On Mon, Apr 8, 2013 at 6:34 PM, Andrew Bailey andrew.bai...@apps4u.co
 wrote:
  Claus, thanks for the reply.
 
  Ok I tried that, however, if in the bootstrap code in main just before
  calling run() I place
 
   ListCamelContext contexts=getCamelContexts();
  System.out.println(contexts); // []
  CamelContext context=contexts.get(0);
  //IndexOutOfBoundsException: Index: 0, Size: 0
  context.getManagementStrategy().addEventNotifier(new
  MyLoggingSentEventNotifer()); //as in
 
 http://camel.apache.org/eventnotifier-to-log-details-about-all-sent-exchanges.html
  run();
 
  It produces
  []
  Exception in thread main java.lang.IndexOutOfBoundsException: Index: 0,
  Size: 0
 
  Is this a bug or am I doing something wrong?
 
 
 
  On Fri, Apr 5, 2013 at 9:24 AM, Claus Ibsen claus.ib...@gmail.com
 wrote:
 
  Hi
 
  Yeah we could add some methods to the Main class you can override to
  have callbacks after start | before stop etc.
  But you can also just use the event notifier api in Camel for that.
 
 
 
  On Wed, Apr 3, 2013 at 4:17 PM, Andrew Bailey andrew.bai...@apps4u.co
  wrote:
   I have a use case, where I require a fast startup time for camel and
 wish
   to avoid classpath scanning.
   I use the Main class however it appears that its not possible to
 obtain a
   ProducerTemplate template = getCamelTemplate();
   before calling the run method. (it produces an ArrayOutOfBounds
  exception -
   I could file a bug for that if you like)
  
   What I did was to extend Main (see code fragment below) and add a
  callback
   called from the afterStart() method, so that user code can access the
   context, and TypeConverterRegistry (as before that it is not
  initialized).
  
   Is there a better way to do it?
  
   If not and the developers think its a good idea, I would like to
  contribute
   the code for a future release.
  
  
   Thanks
  
   Andy
  
  
   import org.apache.camel.main.Main;
  
   public class ServiceManager extends Main {
  
  
   public static void main(String[] args) throws Exception {
   ServiceManager example = new ServiceManager();
   example.boot();
   }
  
   public void boot() throws Exception {
   //cut
  
setAfterStartCallback(new CallableVoid(){
   public Void call() throws Exception
   {
   ProducerTemplate template =
 getCamelTemplate();
  
   fileMonitor.setProducer(template);
  
  /*
  ListCamelContext contexts=getCamelContexts();
  System.out.println(contexts);
  CamelContext context=contexts.get(0);
  TypeConverterRegistry converterRegistry =
   context.getTypeConverterRegistry();
  TypeConverter converter =
   converterRegistry.lookup(String[].class, String.class);
  System.out.println(Converter +converter);
  
  TypeConverter converter2 =
   converterRegistry.lookup(List.class, String.class);
  System.out.println(Converter +converter2);
  
  */
  return null;
   }
   });
   //code cut
System.out.println(Starting Camel. Use ctrl + c to terminate the
   JVM.\n);
   run();
   }
  
   private CallableVoid afterStartCallback;
  
   @Override
   protected void afterStart() throws Exception {
  
   if (afterStartCallback!=null) afterStartCallback.call();
   }
  
   public CallableVoid getAfterStartCallback() {
   return afterStartCallback;
   }
  
   public void setAfterStartCallback(CallableVoid
   afterStartCallback) {
   this.afterStartCallback 

Re: How to use quartz to schedule a file transfer ?

2013-04-10 Thread Chris Wolf
You don't directly use the Quartz Component - you use a RoutePolicy, of
which two concrete implementations will setup
the Quartz Component and register it in the context for you.

Here's an example from:
http://camel.apache.org/simplescheduledroutepolicy.html

...which I changed a little to match your question.

See also:

http://camel.apache.org/routepolicy.html
http://camel.apache.org/scheduledroutepolicy.html
http://camel.apache.org/simplescheduledroutepolicy.html
http://camel.apache.org/cronscheduledroutepolicy.html

SimpleScheduledRoutePolicy policy = new
SimpleScheduledRoutePolicy();long startTime =
System.currentTimeMillis() + 3000L;
policy.setRouteStartDate(new Date(startTime));
policy.setRouteStartRepeatCount(1);
policy.setRouteStartRepeatInterval(3000);

from(file:/tmp/inputdir).routeId(file.test)
   .routePolicy(policy).noAutoStartup()
   .to(file:/tmp/destdir);


   -Chris



On Wed, Apr 10, 2013 at 6:27 PM, lleclerc llecl...@aim-rg.com wrote:

 Hi,

 How to use quartz to schedule a file transfer ?
 from(quartzUri).to(fileUri1).to(fileUri2); doesn't seems to work.

 Thanks,



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/How-to-use-quartz-to-schedule-a-file-transfer-tp5730696.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



When is an (S)FTP file no longer in progress?

2013-04-04 Thread Chris Wolf
Hi,

I created a custom Processor with producer template to perform SFTP
rather then using the sftp component normally,
due to the lack of dynamic URI capability for consumer.

onent.file.remote.SftpConsumer TRACE Skipping as file is already in
progress: CBOE34_MKT_20120319_DAILY.csv


The type of consumer created is ScheduledBatchPollingConsumer - how do
I indicate a batch is done?  Do I need to
suspend or stop this consumer?  Or does the down-stream endpoint, i.e.
to(...), have to indicate a response
(acknowledgement) on the exchange of file received?

Thanks for any assistance with this matter...

   -Chris



(Note, gmail text-plain will mangle the formatting of this code)

@Override
public void process(Exchange exchange) throws Exception {
@SuppressWarnings(unchecked)
MapString, Object ftpProp = exchange.getIn().getBody(Map.class);
if (ftpProp == null)
throw new RuntimeCamelException(No object of type
MapString, Object in input exchange message.);
else
log.info(FTP Properites: {}, ftpProp);

Integer port = exchange.getIn().getHeader(SFTP_PORT,
Integer.class);
ftpProp.put(port, port);

CamelContext context = exchange.getContext();
//String routeId = exchange.getFromRouteId();
configure(context, ftpProp, endpointURIQueryString);
}

void configure(CamelContext context, MapString, Object
parameters, String queryStr) throws Exception {
parameters.put(separator, RemoteFileConfiguration.PathSeparator.UNIX);
parameters.put(binary, Boolean.TRUE);
//parameters.put(disconnect, Boolean.TRUE);
//parameters.put(passive, Boolean.TRUE);
String initialURI = String.format(sftp://%s/%s?%s;,
parameters.get(host), parameters.get(directory), queryStr);
sftpEndpoint = context.getEndpoint(initialURI, SftpEndpoint.class);
sftpComponent = (SftpComponent) sftpEndpoint.getComponent();

SftpConfiguration conf = sftpEndpoint.getConfiguration();

// set reference properties first as they use # syntax that
fools the regular properties setter
EndpointHelper.setReferenceProperties(context, conf, parameters);
EndpointHelper.setProperties(context, conf, parameters);
EndpointHelper.setReferenceProperties(context, sftpEndpoint,
parameters);
EndpointHelper.setProperties(context, sftpEndpoint, parameters);

ServiceStatus status = sftpComponent.getStatus();
log.info(* Component: {}, status);

status = sftpEndpoint.getStatus();
log.info(* Endpoint: {}, status);
//EventDrivenPollingConsumer consumer = (EventDrivenPollingConsumer)
//sftpEndpoint.createPollingConsumer();

sftpConsumer = (SftpConsumer)
sftpEndpoint.createConsumer(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
producer.send(exchange); // send file down-stream...
}
});
MapString, Object cprop = sftpEndpoint.getConsumerProperties();
((ScheduledPollConsumer) sftpConsumer).setStartScheduler(true);
sftpConsumer.start();
status = sftpConsumer.getStatus();
log.info(* Consumer: {}, status);
}

public void setProducer(ProducerTemplate producer) {
this.producer = producer;
}

public String getEndpointURIQueryString() {
return endpointURIQueryString;
}

public void setEndpointURIQueryString(String endpointURIQueryString) {
this.endpointURIQueryString = endpointURIQueryString;
}


Re: It is possible with Camel to use dynamic consumer? **after context start**

2013-04-03 Thread Chris Wolf
I actually was basing my current attempts based on what I read on that
page.  I thought if you used
a ScheduledPollingConsumer, that it would loop for you and didn't need
a while-loop.

I will just try plain PollingConsumer in a while-loop.

BTW, I found the ticket for dynamic URIs for FTP consumers:  CAMEL-4596

Thanks,


Chris

On Wed, Apr 3, 2013 at 5:07 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 You may want to see a little about consumer template here
 http://camel.apache.org/polling-consumer.html

 Notice the the consumer template polls one message at a time.

 If you want to download all available files you would need to run
 the code in a while loop as the example on that link.

 Though you can also add a new route at runtime with the from uri
 computed. And then stop and remove the route if not longer needed.


 On Tue, Apr 2, 2013 at 9:36 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 May I have the ticket #?  (so I can watch/follow)

 When you say, use a java bean - what do you mean?

 Instantiate the FTP component like?

 FtpComponent comp = new FtpComponent(context);
 @SuppressWarnings(unchecked)
 FtpEndpointFTPFile endpt = (FtpEndpointFTPFile)

 comp.createEndpoint(ftp://localhost/download?localWorkDirectory=/tmp/local/datanoop=trueusername=fredpassword=secret;);
 final FtpConsumer cons = (FtpConsumer)
 endpt.createConsumer(new Processor() {
 @Override
 public void process(Exchange exchange)
 throws Exception {
 System.out.printf(%s\n,
 exchange.toString());
 }
 });
 cons.setStartScheduler(true);
 comp.start();
 endpt.start();
 cons.start();

 On Tue, Apr 2, 2013 at 11:03 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 There is a ticket scheduled for Camel 3.0 to allow enrich and
 pollEnrich to support dynamic uris like the recipient list can do.

 Though implementing this requires an API change and thus scheduled for 3.0.

 You can always use a java bean to consume from an dynamic computed
 endpoint. For example using consumer template etc.

 For ftp endpoints you may want to set disconnect=true, to avoid having
 the connection running for a longer period.




 On Sun, Mar 31, 2013 at 10:08 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Claus,

 You addressed the issue of dynamic URIs for Consumers back in July-2009:

 http://camel.465427.n5.nabble.com/Dynamic-consumers-with-Camel-td476433.html

 However, all those use-cases, except for maybe #4, web console, which
 I can't run all are about
 calculating the URI *before* the context is started.  What I'm looking
 for is a way to create and insert
 or update a polling consumer's URI - at runtime - *after* the context
 is started.

 For example:

  from(direct:start)
 .beanRef(config)
 .convertBodyTo(Document.class)
 .setHeader(Ftp_URI).xquery(
 concat('ftp://' +...some more xpaths into the
 inbound config doc...), String.class)
  .pollEnrich(/* whoops! this is referenced at route
 setup time, not route runtime... - it won't work */)
  .to(log:...);

 So the question, more generally, is is it possible to alter the route
 definition - at runtime? i.e. after the route/context are started?

 You sorted of hinted at this in that July-2009 posting when you said:

 2) You can always stop, modify and start a route in Camel at runtime.

 I don't see how that would work since I would likely be attempting to
 modify the route at runtime
 from a bean method in the route - or are you suggesting one route
 stops/modifies another route?

 So the way I see it is - I would create the ftp route with a bogus URI
 and option startScheduler=false,
 on the ftp endpoint, or autoStart=false on the route.  Then in
 *another* route - the configurer route,
 I guess, access the ftp route and reconfigure the endpoint with the
 real settings, then start it's poll scheduler (or start it's route).

 Something like that?  Any easier, more direct way?

 Thanks,


 Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: It is possible with Camel to use dynamic consumer? **after context start**

2013-04-03 Thread Chris Wolf
Sorry, but I'm still a little confused...

Can you compare and contrast EventDrivenPollingConsumer vs.
ScheduledBatchPollingConsumer?

They both seem to support reading multiple times in an exchange...

Thanks,

Chris

On Wed, Apr 3, 2013 at 5:07 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 You may want to see a little about consumer template here
 http://camel.apache.org/polling-consumer.html

 Notice the the consumer template polls one message at a time.

 If you want to download all available files you would need to run
 the code in a while loop as the example on that link.

 Though you can also add a new route at runtime with the from uri
 computed. And then stop and remove the route if not longer needed.


 On Tue, Apr 2, 2013 at 9:36 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 May I have the ticket #?  (so I can watch/follow)

 When you say, use a java bean - what do you mean?

 Instantiate the FTP component like?

 FtpComponent comp = new FtpComponent(context);
 @SuppressWarnings(unchecked)
 FtpEndpointFTPFile endpt = (FtpEndpointFTPFile)

 comp.createEndpoint(ftp://localhost/download?localWorkDirectory=/tmp/local/datanoop=trueusername=fredpassword=secret;);
 final FtpConsumer cons = (FtpConsumer)
 endpt.createConsumer(new Processor() {
 @Override
 public void process(Exchange exchange)
 throws Exception {
 System.out.printf(%s\n,
 exchange.toString());
 }
 });
 cons.setStartScheduler(true);
 comp.start();
 endpt.start();
 cons.start();

 On Tue, Apr 2, 2013 at 11:03 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 There is a ticket scheduled for Camel 3.0 to allow enrich and
 pollEnrich to support dynamic uris like the recipient list can do.

 Though implementing this requires an API change and thus scheduled for 3.0.

 You can always use a java bean to consume from an dynamic computed
 endpoint. For example using consumer template etc.

 For ftp endpoints you may want to set disconnect=true, to avoid having
 the connection running for a longer period.




 On Sun, Mar 31, 2013 at 10:08 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Claus,

 You addressed the issue of dynamic URIs for Consumers back in July-2009:

 http://camel.465427.n5.nabble.com/Dynamic-consumers-with-Camel-td476433.html

 However, all those use-cases, except for maybe #4, web console, which
 I can't run all are about
 calculating the URI *before* the context is started.  What I'm looking
 for is a way to create and insert
 or update a polling consumer's URI - at runtime - *after* the context
 is started.

 For example:

  from(direct:start)
 .beanRef(config)
 .convertBodyTo(Document.class)
 .setHeader(Ftp_URI).xquery(
 concat('ftp://' +...some more xpaths into the
 inbound config doc...), String.class)
  .pollEnrich(/* whoops! this is referenced at route
 setup time, not route runtime... - it won't work */)
  .to(log:...);

 So the question, more generally, is is it possible to alter the route
 definition - at runtime? i.e. after the route/context are started?

 You sorted of hinted at this in that July-2009 posting when you said:

 2) You can always stop, modify and start a route in Camel at runtime.

 I don't see how that would work since I would likely be attempting to
 modify the route at runtime
 from a bean method in the route - or are you suggesting one route
 stops/modifies another route?

 So the way I see it is - I would create the ftp route with a bogus URI
 and option startScheduler=false,
 on the ftp endpoint, or autoStart=false on the route.  Then in
 *another* route - the configurer route,
 I guess, access the ftp route and reconfigure the endpoint with the
 real settings, then start it's poll scheduler (or start it's route).

 Something like that?  Any easier, more direct way?

 Thanks,


 Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Is the result of this builder reusable? XQueryBuilder.xquery(//foo);

2013-04-02 Thread Chris Wolf
I want to perform an XQuery outside of DSL (in a Processor).  Something like:

 XQueryBuilder hostXQ = XQueryBuilder
.xquery(//remote[remoteId/@value='CBOE34']/server/@value);
 String host = hostXQ.evaluateAsString(exchange);

Second question is can I parameterize the XQuery like so:

 XQueryBuilder hostXQ = XQueryBuilder
.xquery(//remote[remoteId/@value=$accountId]/server/@value);

hostXQ.setParameters(new HashMapString, Object() {{
put(accountId, CBOE34);}});
String host1 = hostXQ.evaluateAsString(exchange);

hostXQ.setParameters(new HashMapString, Object() {{
put(accountId, CBOE78);}});
String host2 = hostXQ.evaluateAsString(exchange);


Thanks,


Chris


Re: It is possible with Camel to use dynamic consumer? **after context start**

2013-04-02 Thread Chris Wolf
May I have the ticket #?  (so I can watch/follow)

When you say, use a java bean - what do you mean?

Instantiate the FTP component like?

FtpComponent comp = new FtpComponent(context);
@SuppressWarnings(unchecked)
FtpEndpointFTPFile endpt = (FtpEndpointFTPFile)

comp.createEndpoint(ftp://localhost/download?localWorkDirectory=/tmp/local/datanoop=trueusername=fredpassword=secret;);
final FtpConsumer cons = (FtpConsumer)
endpt.createConsumer(new Processor() {
@Override
public void process(Exchange exchange)
throws Exception {
System.out.printf(%s\n,
exchange.toString());
}
});
cons.setStartScheduler(true);
comp.start();
endpt.start();
cons.start();

On Tue, Apr 2, 2013 at 11:03 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 There is a ticket scheduled for Camel 3.0 to allow enrich and
 pollEnrich to support dynamic uris like the recipient list can do.

 Though implementing this requires an API change and thus scheduled for 3.0.

 You can always use a java bean to consume from an dynamic computed
 endpoint. For example using consumer template etc.

 For ftp endpoints you may want to set disconnect=true, to avoid having
 the connection running for a longer period.




 On Sun, Mar 31, 2013 at 10:08 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Claus,

 You addressed the issue of dynamic URIs for Consumers back in July-2009:

 http://camel.465427.n5.nabble.com/Dynamic-consumers-with-Camel-td476433.html

 However, all those use-cases, except for maybe #4, web console, which
 I can't run all are about
 calculating the URI *before* the context is started.  What I'm looking
 for is a way to create and insert
 or update a polling consumer's URI - at runtime - *after* the context
 is started.

 For example:

  from(direct:start)
 .beanRef(config)
 .convertBodyTo(Document.class)
 .setHeader(Ftp_URI).xquery(
 concat('ftp://' +...some more xpaths into the
 inbound config doc...), String.class)
  .pollEnrich(/* whoops! this is referenced at route
 setup time, not route runtime... - it won't work */)
  .to(log:...);

 So the question, more generally, is is it possible to alter the route
 definition - at runtime? i.e. after the route/context are started?

 You sorted of hinted at this in that July-2009 posting when you said:

 2) You can always stop, modify and start a route in Camel at runtime.

 I don't see how that would work since I would likely be attempting to
 modify the route at runtime
 from a bean method in the route - or are you suggesting one route
 stops/modifies another route?

 So the way I see it is - I would create the ftp route with a bogus URI
 and option startScheduler=false,
 on the ftp endpoint, or autoStart=false on the route.  Then in
 *another* route - the configurer route,
 I guess, access the ftp route and reconfigure the endpoint with the
 real settings, then start it's poll scheduler (or start it's route).

 Something like that?  Any easier, more direct way?

 Thanks,


 Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: Camel routing issue

2013-04-01 Thread Chris Wolf
Prabu,

There's a note on the Camel website about a potential compiler error
when using otherwise(), along with a workaround. Unfortunately, I
can't find it now.

On the other hand, I think this might work:

from(direct:start)
.choice().when(header(Type).isNotNull())
.recipientList(simple(activemq.Inbound.${header.Type}))
.end() // === added this to close when block
.otherwise()
.to(activemq:queue:Invalid.queue)
.endChoice();

N.B. this only solved compilation - I didn't actually do a runtime test.

-Chris

On Mon, Apr 1, 2013 at 7:18 AM, prabumc...@gmail.com
prabumc...@gmail.com wrote:
 Chris,The following code worked fine.

 .choice().when(header(Type).isNotNull())
  .recipientList(simple(activemq.Inbound.${header.Type}))
 .endChoice()

 but,one issue is that.I added *.otherwise()* , it giving error.

 .choice().when(header(Type).isNotNull())
  .recipientList(simple(activemq.Inbound.${header.Type}))
 *.otherwise()
 .to(activemq:queue:Invalid.queue)*
 .endChoice();

 please kindly help me.



 On Mon, Apr 1, 2013 at 2:32 PM, Prabu prabumc...@gmail.com wrote:

 Like Chris suggest i tried below way


  .when(header(TYPE).isNotNull())
.to(activemq:queue.Inbound.${header.Type})


 But queue created *${header.Type}* like this not *Inbound.test*

 Please kindly give me example.

 *Regards*
 Prabu.N



 On Mon, Apr 1, 2013 at 2:03 PM, Claus Ibsen-2 [via Camel] 
 ml-node+s465427n5730152...@n5.nabble.com wrote:

 Hi

 See this EIP
 http://camel.apache.org/content-enricher.html

 About pollEnrich.

 Though pollEnrich currently does support dynamic uris. Its on the
 roadmap,
 for Camel 3.0.
 It requires an API change and thus isn't so easy to implement currently
 on
 2.x.

 You can always use a java bean / camel processor, and consume the ftp
 file
 from java code.
 For example using consumer template.

 As you use FTP you may want to set disconnect=true so the connect is not
 remained open after usage.



 On Sun, Mar 31, 2013 at 7:51 PM, Chris Wolf [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5730152i=0
 wrote:

  Ok, I'm starting to get it - a little bit.  As for my concrete
  example, so far, I have:
 
  from(direct:start)
  .beanRef(config)
  .convertBodyTo(Document.class)
  .recipientList().xquery(
  concat('ftp://' +
  ,//remote[vendorId/@value='CBOE34']/server/@value
 +
 
 
 
 ,//remote[vendorId/@value='CBOE34']/param[name/@value='directory']/value/@value

  +
  ,'?noop=trueamp;username=' +
 
 ,//remote[vendorId/@value='CBOE34']/username/@value +
  ,'amp;password=' +
 
  ,//remote[vendorId/@value='CBOE34']/password/@value), String.class);
 
  Here's the problem - this will create an FTP Producer - that's not
  what I need.  I need a dynamically
  constructed URI for a polling FTP consumer.  I don't think
  recipientList will work...   Any ideas?
 
  Thanks,
 
  Chris
 
  On Sun, Mar 31, 2013 at 10:27 AM, Chris Wolf [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=5730152i=1
 wrote:
   Hi Claus,
  
   I hate to ask this - but I still don't get it.  I thought
   recipientList was for sending to multiple, runtime-defined
   recipients.  I don't see how this
   answers the question of sending to one, single recipient, whose URI
 is
   dynamically constructed - and in my use-case the dynamic settings
   are not in properties - so simple (property place-holders) won't
 help
  me.
  
   Let me give you a concrete example.  I need to do an ftp download and
   the connection information comes from up-stream in the route in the
   form of XML (DOM - a Document instance).  Currently, I am trying to
 do
   this with bean binding and method params decorated with @XPath
   pointing into the Document with the ftp settings and inside the
   this method doing:
  
   FtpComponent ftpComponent = context.getComponent(ftp,
  FtpComponent.class);
  
   ..and then attempt to get the endpoint and call createConsumer(...).
   I'm sure this is not the right way to do it, but I don't see how else
   - any ideas?
  
   Thanks,
  
  
   Chris
  
   On Sun, Mar 31, 2013 at 2:28 AM, Claus Ibsen [hidden 
   email]http://user/SendEmail.jtp?type=nodenode=5730152i=2

  wrote:
   Hi
  
   See this FAQ
   http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html
  
  
  
  
   On Sun, Mar 31, 2013 at 5:22 AM, [hidden 
   email]http://user/SendEmail.jtp?type=nodenode=5730152i=3
   [hidden 
   email]http://user/SendEmail.jtp?type=nodenode=5730152i=4wrote:

  
   Thanks Walzer..
   *
   *
   *Queston1:
  
   *
   *Example*
  
   .when(header(foo).isEqualTo(bar))
   .to(direct:b)
  
   In my case i have to add more than 80 condition and forwards to 80
   different queues.
  
   Above example i can only hard-code

Content-based routing with Expressions and Predicates

2013-04-01 Thread Chris Wolf
(I took the liberty to change the Subject since the message history has both my
 FTP issue and Prabu's routing issue - my fault, sorry)

Prabu, I strongly recommend getting and reading Claus's book Camel In Action,
like Thomas Walzer suggested upon your first post.  You also should be
familiar with the concepts on these pages:

http://camel.apache.org/content-based-router.html
http://camel.apache.org/predicate.html
http://camel.apache.org/expression.html
http://camel.apache.org/languages.html
(and this is the page I mentioned before, but couldn't find at the time...)
http://camel.apache.org/why-can-i-not-use-when-or-otherwise-in-a-java-camel-route.html


...but, really, everything you're asking for is answered on this one page:
http://camel.apache.org/predicate.html

...in any case, I think your example 1  2 would be
implemented something as follows:

(Be advised, Gmail forces lines wraps around column 72 or so,
 so the code formatting will be mangled)


Don't forget to statically import the predicates you will be using in
compound expressions..

import static org.apache.camel.builder.PredicateBuilder.and;
import static org.apache.camel.builder.PredicateBuilder.or;

Predicate cardEvent = PredicateBuilder.regex(header(Type), ^card\\.event.*);

from(jms:Inbound.Test.DDD).choice()
  // Your Example 1
.when(and(property(PAST_EVENT_INTERVAL).isEqualTo(0),
or(header(Type).isEqualTo(card.test),
header(Type).isEqualTo(card.expiry.test)
 ))).to(jms:SOUTHQueueName)
  // Your Example 2
.when(and(property(PAST_EVENT_INTERVAL).isEqualTo(0), cardEvent))
.to(jms:WESTQueueName)
.otherwise().to(jms:dead.letter.queue)
.end();

I also recommend that you not use a header named Type, since that's
easily confused with
data type or type parameter.  Maybe some like CARD_OP...

Regards,

Chris


On Mon, Apr 1, 2013 at 11:36 AM, prabumc...@gmail.com
prabumc...@gmail.com wrote:

 Hi *Chris / **Claus*,

 I have one *Inbound* queue,based on header and content type,I want forward
 to outbound queue.
 *
 Example 1:
 *
 *
 Inbound.queue name : **Inbound.Test.DDD
 Outbound.queue name : SOURHQueueName

 *
 *Criteria or Condition :
 *
 Message property *PAST_EVENT_INTERVAL type* is : *0*
   *AND*
 Message *Type* value is : *card.test *or* card.expiry.test*

 *Example 2:*

 *Inbound.queue name : **Inbound.Test.SSS
 Outbound.queue name : WESTQueueName
 *
 *Criteria or Condition :*
 Message property *PAST_EVENT_INTERVAL type* is : *0*
  *AND
 *
 Message *Type *value *start with* :*card.event*

 I want achieve this using camel routing java DSL.

 Please help me.How can i use AND,OR and regular expression in camel routing

 *Regards*
 Prabu.N

On Sun, Mar 31, 2013 at 5:22 AM, [hidden 
email]http://user/SendEmail.jtp?type=nodenode=5730166i=4
[hidden 
email]http://user/SendEmail.jtp?type=nodenode=5730166i=5wrote:
 
   
Thanks Walzer..
*
*
*Queston1:
   
*
*Example*
   
.when(header(foo).isEqualTo(bar))
.to(direct:b)
   
In my case i have to add more than 80 condition and forwards to 80
different queues.
   
Above example i can only hard-code queue name,But what i want is
  below.
   
* .when(header(Type).isNotNull())
.to(activemq.Inbound.+header(Type))
*
   
Example:If queue type is test,It should forward to *Inbound.test*
   queue.
   
Above example i tried,but it did not worked,created queue something
like this *Inbound.header(type)*
   
*Question2*:
   
from(direct:a)
.multicast().to(direct:b, direct:c, direct:d);
   
Based on messages header and content type i want forward to
  different
queue.
   
condition will be *OR *and *AND*.How can i do that like above
  example.*
*
   
Thanks in advance*
*
   
*Regards*
   
Prabu.N
   
   
   
   
   
   
   
   
   
   
   
   
   
On Sun, Mar 31, 2013 at 2:43 AM, Walzer, Thomas [via Camel] 
[hidden email]http://user/SendEmail.jtp?type=nodenode=5730166i=6
  wrote:
   
 Hi,

 you could start by reading Claus´ book (p. 44ff) which has a
  perfect
 example or http://camel.apache.org/content-based-router.html (just
 
 replace the direct: with your queues).
 If you need to fire your messages to multiple queues:
 http://camel.apache.org/publish-subscribe-channel.html shows you
  the
 various ways.
 When you get the concepts you can just lego them together.

 Regards, Thomas.

 Am 30.03.2013 um 19:05 schrieb [hidden email]
http://user/SendEmail.jtp?type=nodenode=5730116i=0
 [hidden email] 
   http://user/SendEmail.jtp?type=nodenode=5730116i=1:

  Hi Claus,
 
  Thanks so much Clus for help.It is working now.
 
  I need your guidance for the following requirement.
 
  1.I have one *inbound queue* it will receive message frequently
   from my
  application.
  2.From *inbound queue* i need camel 

Re: Camel routing issue

2013-03-31 Thread Chris Wolf
Hi Claus,

I hate to ask this - but I still don't get it.  I thought
recipientList was for sending to multiple, runtime-defined
recipients.  I don't see how this
answers the question of sending to one, single recipient, whose URI is
dynamically constructed - and in my use-case the dynamic settings
are not in properties - so simple (property place-holders) won't help me.

Let me give you a concrete example.  I need to do an ftp download and
the connection information comes from up-stream in the route in the
form of XML (DOM - a Document instance).  Currently, I am trying to do
this with bean binding and method params decorated with @XPath
pointing into the Document with the ftp settings and inside the
this method doing:

FtpComponent ftpComponent = context.getComponent(ftp, FtpComponent.class);

..and then attempt to get the endpoint and call createConsumer(...).
I'm sure this is not the right way to do it, but I don't see how else
- any ideas?

Thanks,


Chris

On Sun, Mar 31, 2013 at 2:28 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 See this FAQ
 http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html




 On Sun, Mar 31, 2013 at 5:22 AM, prabumc...@gmail.com
 prabumc...@gmail.comwrote:

 Thanks Walzer..
 *
 *
 *Queston1:

 *
 *Example*

 .when(header(foo).isEqualTo(bar))
 .to(direct:b)

 In my case i have to add more than 80 condition and forwards to 80
 different queues.

 Above example i can only hard-code queue name,But what i want is below.

 * .when(header(Type).isNotNull())
 .to(activemq.Inbound.+header(Type))
 *

 Example:If queue type is test,It should forward to *Inbound.test* queue.

 Above example i tried,but it did not worked,created queue something
 like this *Inbound.header(type)*

 *Question2*:

 from(direct:a)
 .multicast().to(direct:b, direct:c, direct:d);

 Based on messages header and content type i want forward to different
 queue.

 condition will be *OR *and *AND*.How can i do that like above example.*
 *

 Thanks in advance*
 *

 *Regards*

 Prabu.N













 On Sun, Mar 31, 2013 at 2:43 AM, Walzer, Thomas [via Camel] 
 ml-node+s465427n5730116...@n5.nabble.com wrote:

  Hi,
 
  you could start by reading Claus´ book (p. 44ff) which has a perfect
  example or http://camel.apache.org/content-based-router.html (just
  replace the direct: with your queues).
  If you need to fire your messages to multiple queues:
  http://camel.apache.org/publish-subscribe-channel.html shows you the
  various ways.
  When you get the concepts you can just lego them together.
 
  Regards, Thomas.
 
  Am 30.03.2013 um 19:05 schrieb [hidden email]
 http://user/SendEmail.jtp?type=nodenode=5730116i=0
  [hidden email] http://user/SendEmail.jtp?type=nodenode=5730116i=1:
 
   Hi Claus,
  
   Thanks so much Clus for help.It is working now.
  
   I need your guidance for the following requirement.
  
   1.I have one *inbound queue* it will receive message frequently from my
   application.
   2.From *inbound queue* i need camel routing to move message from
   another *message
   based inbound queue* based on message header value.
   3.From *message based inbound queue *i* *need camel routing to move
  message
   to *one or more outbound queue *based on message content*
   *
  
   I need *camel java DSL*sample code for above requirement.*
   *
   *
   *
   *Thanks in advance*
  
  
   On Sat, Mar 30, 2013 at 3:10 PM, Claus Ibsen-2 [via Camel] 
   [hidden email] http://user/SendEmail.jtp?type=nodenode=5730116i=2
  wrote:
  
   Hi
  
   Do as the exception tells you. Check route 2. You route from
   Inbound.SSS.TestEvent. And that is now know to Camel.
  
   Maybe you need to add activemq: as prefix so its
   activemq:Inbound.SSS.TestEvent.
  
  
   On Fri, Mar 29, 2013 at 7:01 PM, [hidden email]
  http://user/SendEmail.jtp?type=nodenode=5730109i=0
   [hidden email] http://user/SendEmail.jtp?type=nodenode=5730109i=1
 
 
   wrote:
  
  
   I have activemmq  Project in that i have following requirement
  
   1.Move message from Inbound queue to type based inbound queue.
   2.Move message from Message type inbound queue to outbound queue
  
   I have created two bean for to achieve this.
  
   1.one for move from inbound to message type  inbound queue
   2.one for move from inbound to outbound queue.
  
   I have following entry in camel.xml
  
 camelContext id=camel xmlns=
  http://camel.apache.org/schema/spring;
  
  
  routeBuilder ref=routeBuilder /
  routeBuilder ref=routeBuilder1 /
  
  /camelContext
  
  bean id=routeBuilder
   class=com.camel.routes.SinglecastRouteBuilder/
  bean id=recipientsGenerator
   class=com.camel.routes.TypeSpecificListBean/
  bean id=routeBuilder1
   class=com.camel.routes.MulticastRouteBuilder/
  bean id=recipientsGenerator1
   class=com.camel.routes.RecipientListBean/
  
   When i run application i am getting following error.
  
   * java.lang.Exception: 

Re: Camel routing issue

2013-03-31 Thread Chris Wolf
Ok, I'm starting to get it - a little bit.  As for my concrete
example, so far, I have:

from(direct:start)
.beanRef(config)
.convertBodyTo(Document.class)
.recipientList().xquery(
concat('ftp://' +
,//remote[vendorId/@value='CBOE34']/server/@value +

,//remote[vendorId/@value='CBOE34']/param[name/@value='directory']/value/@value
+
,'?noop=trueamp;username=' +
,//remote[vendorId/@value='CBOE34']/username/@value +
,'amp;password=' +

,//remote[vendorId/@value='CBOE34']/password/@value), String.class);

Here's the problem - this will create an FTP Producer - that's not
what I need.  I need a dynamically
constructed URI for a polling FTP consumer.  I don't think
recipientList will work...   Any ideas?

Thanks,

Chris

On Sun, Mar 31, 2013 at 10:27 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 Hi Claus,

 I hate to ask this - but I still don't get it.  I thought
 recipientList was for sending to multiple, runtime-defined
 recipients.  I don't see how this
 answers the question of sending to one, single recipient, whose URI is
 dynamically constructed - and in my use-case the dynamic settings
 are not in properties - so simple (property place-holders) won't help me.

 Let me give you a concrete example.  I need to do an ftp download and
 the connection information comes from up-stream in the route in the
 form of XML (DOM - a Document instance).  Currently, I am trying to do
 this with bean binding and method params decorated with @XPath
 pointing into the Document with the ftp settings and inside the
 this method doing:

 FtpComponent ftpComponent = context.getComponent(ftp, FtpComponent.class);

 ..and then attempt to get the endpoint and call createConsumer(...).
 I'm sure this is not the right way to do it, but I don't see how else
 - any ideas?

 Thanks,


 Chris

 On Sun, Mar 31, 2013 at 2:28 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 See this FAQ
 http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html




 On Sun, Mar 31, 2013 at 5:22 AM, prabumc...@gmail.com
 prabumc...@gmail.comwrote:

 Thanks Walzer..
 *
 *
 *Queston1:

 *
 *Example*

 .when(header(foo).isEqualTo(bar))
 .to(direct:b)

 In my case i have to add more than 80 condition and forwards to 80
 different queues.

 Above example i can only hard-code queue name,But what i want is below.

 * .when(header(Type).isNotNull())
 .to(activemq.Inbound.+header(Type))
 *

 Example:If queue type is test,It should forward to *Inbound.test* queue.

 Above example i tried,but it did not worked,created queue something
 like this *Inbound.header(type)*

 *Question2*:

 from(direct:a)
 .multicast().to(direct:b, direct:c, direct:d);

 Based on messages header and content type i want forward to different
 queue.

 condition will be *OR *and *AND*.How can i do that like above example.*
 *

 Thanks in advance*
 *

 *Regards*

 Prabu.N













 On Sun, Mar 31, 2013 at 2:43 AM, Walzer, Thomas [via Camel] 
 ml-node+s465427n5730116...@n5.nabble.com wrote:

  Hi,
 
  you could start by reading Claus´ book (p. 44ff) which has a perfect
  example or http://camel.apache.org/content-based-router.html (just
  replace the direct: with your queues).
  If you need to fire your messages to multiple queues:
  http://camel.apache.org/publish-subscribe-channel.html shows you the
  various ways.
  When you get the concepts you can just lego them together.
 
  Regards, Thomas.
 
  Am 30.03.2013 um 19:05 schrieb [hidden email]
 http://user/SendEmail.jtp?type=nodenode=5730116i=0
  [hidden email] http://user/SendEmail.jtp?type=nodenode=5730116i=1:
 
   Hi Claus,
  
   Thanks so much Clus for help.It is working now.
  
   I need your guidance for the following requirement.
  
   1.I have one *inbound queue* it will receive message frequently from my
   application.
   2.From *inbound queue* i need camel routing to move message from
   another *message
   based inbound queue* based on message header value.
   3.From *message based inbound queue *i* *need camel routing to move
  message
   to *one or more outbound queue *based on message content*
   *
  
   I need *camel java DSL*sample code for above requirement.*
   *
   *
   *
   *Thanks in advance*
  
  
   On Sat, Mar 30, 2013 at 3:10 PM, Claus Ibsen-2 [via Camel] 
   [hidden email] http://user/SendEmail.jtp?type=nodenode=5730116i=2
  wrote:
  
   Hi
  
   Do as the exception tells you. Check route 2. You route from
   Inbound.SSS.TestEvent. And that is now know to Camel.
  
   Maybe you need to add activemq: as prefix so its
   activemq:Inbound.SSS.TestEvent.
  
  
   On Fri, Mar 29, 2013 at 7:01 PM, [hidden email]
  http://user/SendEmail.jtp?type=nodenode=5730109i=0
   [hidden email] http://user/SendEmail.jtp?type=nodenode=5730109i=1
 
 
   wrote:
  
  
   I have activemmq  Project in that i have following requirement

Re: Camel routing issue

2013-03-31 Thread Chris Wolf
Here you go:


.choice().when(header(Type).isNotNull())
.recipientList(simple(activemq.Inbound.${header.Type}))
.endChoice()


Sorry for hijacking your thread, but I also was not getting
recipientList to implement dynamic destinations.  I get it now,
pretty much,
I just don't know how to specify a polling consumer with dynamic uri...

Regards,

Chris

On Sun, Mar 31, 2013 at 2:21 PM, prabumc...@gmail.com
prabumc...@gmail.com wrote:
 Thanks for your faq url,but I did not understand anything from that faq.

 as I told already

 .to(activemq.Inbound.+ header( Type)

 Please kindly provide with example.

 Thanks
 Prabu.n
 On Mar 31, 2013 11:22 PM, Chris Wolf [via Camel] 
 ml-node+s465427n5730134...@n5.nabble.com wrote:

 Ok, I'm starting to get it - a little bit.  As for my concrete
 example, so far, I have:

 from(direct:start)
 .beanRef(config)
 .convertBodyTo(Document.class)
 .recipientList().xquery(
 concat('ftp://' +
 ,//remote[vendorId/@value='CBOE34']/server/@value +

 ,//remote[vendorId/@value='CBOE34']/param[name/@value='directory']/value/@value

 +
 ,'?noop=trueamp;username=' +
 ,//remote[vendorId/@value='CBOE34']/username/@value
 +
 ,'amp;password=' +

 ,//remote[vendorId/@value='CBOE34']/password/@value), String.class);

 Here's the problem - this will create an FTP Producer - that's not
 what I need.  I need a dynamically
 constructed URI for a polling FTP consumer.  I don't think
 recipientList will work...   Any ideas?

 Thanks,

 Chris

 On Sun, Mar 31, 2013 at 10:27 AM, Chris Wolf [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5730134i=0
 wrote:

  Hi Claus,
 
  I hate to ask this - but I still don't get it.  I thought
  recipientList was for sending to multiple, runtime-defined
  recipients.  I don't see how this
  answers the question of sending to one, single recipient, whose URI is
  dynamically constructed - and in my use-case the dynamic settings
  are not in properties - so simple (property place-holders) won't help
 me.
 
  Let me give you a concrete example.  I need to do an ftp download and
  the connection information comes from up-stream in the route in the
  form of XML (DOM - a Document instance).  Currently, I am trying to do
  this with bean binding and method params decorated with @XPath
  pointing into the Document with the ftp settings and inside the
  this method doing:
 
  FtpComponent ftpComponent = context.getComponent(ftp,
 FtpComponent.class);
 
  ..and then attempt to get the endpoint and call createConsumer(...).
  I'm sure this is not the right way to do it, but I don't see how else
  - any ideas?
 
  Thanks,
 
 
  Chris
 
  On Sun, Mar 31, 2013 at 2:28 AM, Claus Ibsen [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=5730134i=1
 wrote:
  Hi
 
  See this FAQ
  http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html
 
 
 
 
  On Sun, Mar 31, 2013 at 5:22 AM, [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=5730134i=2
  [hidden email] 
  http://user/SendEmail.jtp?type=nodenode=5730134i=3wrote:

 
  Thanks Walzer..
  *
  *
  *Queston1:
 
  *
  *Example*
 
  .when(header(foo).isEqualTo(bar))
  .to(direct:b)
 
  In my case i have to add more than 80 condition and forwards to 80
  different queues.
 
  Above example i can only hard-code queue name,But what i want is
 below.
 
  * .when(header(Type).isNotNull())
  .to(activemq.Inbound.+header(Type))
  *
 
  Example:If queue type is test,It should forward to *Inbound.test*
 queue.
 
  Above example i tried,but it did not worked,created queue something
  like this *Inbound.header(type)*
 
  *Question2*:
 
  from(direct:a)
  .multicast().to(direct:b, direct:c, direct:d);
 
  Based on messages header and content type i want forward to different
  queue.
 
  condition will be *OR *and *AND*.How can i do that like above
 example.*
  *
 
  Thanks in advance*
  *
 
  *Regards*
 
  Prabu.N
 
 
 
 
 
 
 
 
 
 
 
 
 
  On Sun, Mar 31, 2013 at 2:43 AM, Walzer, Thomas [via Camel] 
  [hidden email] http://user/SendEmail.jtp?type=nodenode=5730134i=4
 wrote:
 
   Hi,
  
   you could start by reading Claus´ book (p. 44ff) which has a perfect
   example or http://camel.apache.org/content-based-router.html (just
   replace the direct: with your queues).
   If you need to fire your messages to multiple queues:
   http://camel.apache.org/publish-subscribe-channel.html shows you
 the
   various ways.
   When you get the concepts you can just lego them together.
  
   Regards, Thomas.
  
   Am 30.03.2013 um 19:05 schrieb [hidden email]
  http://user/SendEmail.jtp?type=nodenode=5730116i=0
   [hidden email] 
 http://user/SendEmail.jtp?type=nodenode=5730116i=1:
  
Hi Claus,
   
Thanks so much Clus for help.It is working now.
   
I need your guidance

It is possible with Camel to use dynamic consumer? **after context start**

2013-03-31 Thread Chris Wolf
Claus,

You addressed the issue of dynamic URIs for Consumers back in July-2009:

http://camel.465427.n5.nabble.com/Dynamic-consumers-with-Camel-td476433.html

However, all those use-cases, except for maybe #4, web console, which
I can't run all are about
calculating the URI *before* the context is started.  What I'm looking
for is a way to create and insert
or update a polling consumer's URI - at runtime - *after* the context
is started.

For example:

 from(direct:start)
.beanRef(config)
.convertBodyTo(Document.class)
.setHeader(Ftp_URI).xquery(
concat('ftp://' +...some more xpaths into the
inbound config doc...), String.class)
 .pollEnrich(/* whoops! this is referenced at route
setup time, not route runtime... - it won't work */)
 .to(log:...);

So the question, more generally, is is it possible to alter the route
definition - at runtime? i.e. after the route/context are started?

You sorted of hinted at this in that July-2009 posting when you said:

2) You can always stop, modify and start a route in Camel at runtime.

I don't see how that would work since I would likely be attempting to
modify the route at runtime
from a bean method in the route - or are you suggesting one route
stops/modifies another route?

So the way I see it is - I would create the ftp route with a bogus URI
and option startScheduler=false,
on the ftp endpoint, or autoStart=false on the route.  Then in
*another* route - the configurer route,
I guess, access the ftp route and reconfigure the endpoint with the
real settings, then start it's poll scheduler (or start it's route).

Something like that?  Any easier, more direct way?

Thanks,


Chris


Re: Is there a DataFormat to convert XML string to XML Document?

2013-03-30 Thread Chris Wolf
Thanks - that's exactly what I needed.  Although I'm wondering when
you would select   .convertBodyTo(Class?)  vs. a DataFormat?

Thanks again,


Chris



On Fri, Mar 29, 2013 at 8:38 PM, Raul Kripalani r...@evosent.com wrote:
 .convertBodyTo(Document.class)

 Leverages a feature of Camel called Type Conversion.

 Raúl.

 Sent while on the move
 On 29 Mar 2013 22:40, Chris Wolf cwolf.a...@gmail.com wrote:

 I don't see any listed here:

 http://camel.apache.org/data-format.html

 ...but I find it hard to believe there isn't a way to convert a string
 to XML without creating a custom processor to parse string data from a
 web service.

 Thanks,

 Chris



Re: Need help with cxfrs component, actually RESTful service consumption, in general

2013-03-29 Thread Chris Wolf
Willem,

Thanks for the link - I thought I had all the tests because I checked
out the code a while ago - then I realized I had only checked out
camel-core.   BTW, the link you provided is a little off, but I found
what I needed to at here:

https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java


Regards,

Chris

On Thu, Mar 28, 2013 at 9:47 PM, Willem jiang willem.ji...@gmail.com wrote:
 Hi,

 If you have used CXF before, you can reuse most of you knowledge about the 
 CXF in camel-cxfrs or camel-cxf component.
 If you just want to access the RESTful service from examples, you can take a 
 look at some unit tests[1] in the camel-cxfrs.

 [1]https://svn.apache.org/repos/asf/camel/trunk/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java

 --
 Willem Jiang

 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Web: http://www.fusesource.com | http://www.redhat.com
 Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
 (English)
   http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
 Twitter: willemjiang
 Weibo: 姜宁willem




 On Friday, March 29, 2013 at 6:35 AM, Chris Wolf wrote:

 So I have the book, Camel In Action, which is a very good and
 thorough treatment of camel-core. However, now my development efforts
 are starting to hit severe turbulence upon making the jump from
 camel-core to camel-cxf, in particular, how to consume a RESTful
 service?

 I read these:
 http://camel.apache.org/cxfrs.html
 http://camel.apache.org/cxf-bean-component.html

 ...but these pages seem to be reference pages for people who have
 already mastered camel-cxfrs - not newbies, like me. Can anyone point
 me to an end-to-end example? I don't need the server-side - this is
 legacy and produces XML.

 N.B. Outside of Camel, I have had much previous experience using CXF
 for JAX-WS style services, client and server (never JAX-RS, though)

 Thanks for any help,

 -Chris




Re: Need help with cxfrs component, actually RESTful service consumption, in general

2013-03-29 Thread Chris Wolf
Ok, before I go the CXF-RS route (no pun intended) I want to try
restlet.  To clarify - can I use restlet to consume any RESTful
service,
or does the service have to be a restlet service?

The example client-side code on the the page: http://camel.apache.org/restlet

Has:

from(direct:start-auth).to(restlet:http://localhost:; + port +
/securedOrders?restletMethod=post);
That is all we need. We are ready to send a request and try out the
restlet component:
final String id = 89531;

MapString, Object headers = new HashMapString, Object();
headers.put(RestletConstants.RESTLET_LOGIN, admin);
headers.put(RestletConstants.RESTLET_PASSWORD, foo);
headers.put(id, id);

String response =
(String)template.requestBodyAndHeaders(direct:start-auth, order
foo='1'/, headers);

I don't need to authenticate, and I only need to do a GET, but the URL
I'm consuming from
has a query string with a parameter whose value is an Xpath

http://localhost:4040/some/service?param1=/root/level2[id='xyz']

Do I need to URL-Encode the first '?' so I can append ?restletMethod=GET

?

Thanks,

Chris

On Fri, Mar 29, 2013 at 4:05 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 There is also camel-restlet
 http://camel.apache.org/restlet

 It may be easier to get hold of and use. But CXF may have more
 configuration options, but is also IMHO harder to get started with
 using - some of that is us to blame, for not having better
 documentation and samples. And the fact that IMHO camel-cxf has both
 WS and RS in the same big giant component, which IMHO is becoming a
 problem and hurts the lightweightness of Camel and CXF.

 You may also take a look at some of the articles about Camel. There
 should be some good ones about REST etc
 http://camel.apache.org/articles

 For example this article
 http://www.ofbizian.com/2012/02/apache-camel-rest-example.html

 But there is others as well.



 On Thu, Mar 28, 2013 at 11:35 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 So I have the book, Camel In Action, which is a very good and
 thorough treatment of camel-core. However, now my development efforts
 are starting to hit severe turbulence upon making the jump from
 camel-core to camel-cxf, in particular, how to consume a RESTful
 service?

 I read these:
 http://camel.apache.org/cxfrs.html
 http://camel.apache.org/cxf-bean-component.html

 ...but these pages seem to be reference pages for people who have
 already mastered camel-cxfrs - not newbies, like me.  Can anyone point
 me to an end-to-end example?  I don't need the server-side - this is
 legacy and produces XML.

 N.B. Outside of Camel, I have had much previous experience using CXF
 for JAX-WS style services, client and server  (never JAX-RS, though)

 Thanks for any help,

   -Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: Need help with cxfrs component, actually RESTful service consumption, in general

2013-03-29 Thread Chris Wolf
I see that the default method is GET, but I urlendcoded the '?' that
is part of the service URL, rather then restlet URL.

However, it's getting a no consumer error.  My route is:

from(direct:readsvc)
.to(restlet:http://localhost:4040/some/service%3Fparam1=/root/level2[id='xyz'])
.to(log:readsvc?showAll=truemultiline=truelevel=INFO);

 Object response = xdsrdr.requestBody(direct:readsvc, );

The error is:

 org.apache.camel.CamelExchangeException: No consumers available on
endpoint: Endpoint[direct://readsvc]. Exchange[Message: ]

I thought I was following the client-side pattern show on the restlet
documentation web page,
but it's not working.

So my question is can restlet be use to perform an HTTP GET on a
RESTful service that returns a string (actually an xml document)?

If so, how?

Thanks,

Chris


On Fri, Mar 29, 2013 at 11:09 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 Ok, before I go the CXF-RS route (no pun intended) I want to try
 restlet.  To clarify - can I use restlet to consume any RESTful
 service,
 or does the service have to be a restlet service?

 The example client-side code on the the page: http://camel.apache.org/restlet

 Has:

 from(direct:start-auth).to(restlet:http://localhost:; + port +
 /securedOrders?restletMethod=post);
 That is all we need. We are ready to send a request and try out the
 restlet component:
 final String id = 89531;

 MapString, Object headers = new HashMapString, Object();
 headers.put(RestletConstants.RESTLET_LOGIN, admin);
 headers.put(RestletConstants.RESTLET_PASSWORD, foo);
 headers.put(id, id);

 String response =
 (String)template.requestBodyAndHeaders(direct:start-auth, order
 foo='1'/, headers);

 I don't need to authenticate, and I only need to do a GET, but the URL
 I'm consuming from
 has a query string with a parameter whose value is an Xpath

 http://localhost:4040/some/service?param1=/root/level2[id='xyz']

 Do I need to URL-Encode the first '?' so I can append ?restletMethod=GET

 ?

 Thanks,

 Chris

 On Fri, Mar 29, 2013 at 4:05 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 There is also camel-restlet
 http://camel.apache.org/restlet

 It may be easier to get hold of and use. But CXF may have more
 configuration options, but is also IMHO harder to get started with
 using - some of that is us to blame, for not having better
 documentation and samples. And the fact that IMHO camel-cxf has both
 WS and RS in the same big giant component, which IMHO is becoming a
 problem and hurts the lightweightness of Camel and CXF.

 You may also take a look at some of the articles about Camel. There
 should be some good ones about REST etc
 http://camel.apache.org/articles

 For example this article
 http://www.ofbizian.com/2012/02/apache-camel-rest-example.html

 But there is others as well.



 On Thu, Mar 28, 2013 at 11:35 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 So I have the book, Camel In Action, which is a very good and
 thorough treatment of camel-core. However, now my development efforts
 are starting to hit severe turbulence upon making the jump from
 camel-core to camel-cxf, in particular, how to consume a RESTful
 service?

 I read these:
 http://camel.apache.org/cxfrs.html
 http://camel.apache.org/cxf-bean-component.html

 ...but these pages seem to be reference pages for people who have
 already mastered camel-cxfrs - not newbies, like me.  Can anyone point
 me to an end-to-end example?  I don't need the server-side - this is
 legacy and produces XML.

 N.B. Outside of Camel, I have had much previous experience using CXF
 for JAX-WS style services, client and server  (never JAX-RS, though)

 Thanks for any help,

   -Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: Need help with cxfrs component, actually RESTful service consumption, in general

2013-03-29 Thread Chris Wolf
On Fri, Mar 29, 2013 at 9:23 AM, Sergey Beryozkin sberyoz...@gmail.com wrote:
 On 29/03/13 11:05, Claus Ibsen wrote:

 Hi

 There is also camel-restlet
 http://camel.apache.org/restlet

 It may be easier to get hold of and use. But CXF may have more
 configuration options, but is also IMHO harder to get started with
 using - some of that is us to blame, for not having better
 documentation and samples. And the fact that IMHO camel-cxf has both
 WS and RS in the same big giant component, which IMHO is becoming a
 problem and hurts the lightweightness of Camel and CXF.

 Really ? I agree that it is not the easiest component to use - that is fare
 and personally I'd have no problems with sharing part of the 'blame' for not
 contributing, but please don't do this hurts the Camel  thing, which is
 FUD IMHO - FYI, I'm perfectly fine with yourself having the preferences, no
 problems there at all !

 Chris: feel free to experiment with all the other HTTP-aware components,
 some of them indeed are simpler to use for a given task.
 FYI, I'm going to work on doing a better demo of using CXF JAX-RS endpoints
 directly within Camel, specifically, using the Camel transport to link
 directly to CXF jaxrs:endpoints, and will update the list.

 Thanks, Sergey

Even just a basic client making an HTTP GET and getting back some text
would be great. I still can't do that.
(See my recent reply to Claus)

Thanks,

Chris



 You may also take a look at some of the articles about Camel. There
 should be some good ones about REST etc
 http://camel.apache.org/articles

 For example this article
 http://www.ofbizian.com/2012/02/apache-camel-rest-example.html

 But there is others as well.



 On Thu, Mar 28, 2013 at 11:35 PM, Chris Wolfcwolf.a...@gmail.com  wrote:

 So I have the book, Camel In Action, which is a very good and
 thorough treatment of camel-core. However, now my development efforts
 are starting to hit severe turbulence upon making the jump from
 camel-core to camel-cxf, in particular, how to consume a RESTful
 service?

 I read these:
 http://camel.apache.org/cxfrs.html
 http://camel.apache.org/cxf-bean-component.html

 ...but these pages seem to be reference pages for people who have
 already mastered camel-cxfrs - not newbies, like me.  Can anyone point
 me to an end-to-end example?  I don't need the server-side - this is
 legacy and produces XML.

 N.B. Outside of Camel, I have had much previous experience using CXF
 for JAX-WS style services, client and server  (never JAX-RS, though)

 Thanks for any help,

-Chris








Re: Need help with cxfrs component, actually RESTful service consumption, in general

2013-03-29 Thread Chris Wolf
Hello - I just used camel-http to do my RESTful service invocation and
it's good enough for my basic purposes.

   -Chris

On Fri, Mar 29, 2013 at 11:30 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 On Fri, Mar 29, 2013 at 9:23 AM, Sergey Beryozkin sberyoz...@gmail.com 
 wrote:
 On 29/03/13 11:05, Claus Ibsen wrote:

 Hi

 There is also camel-restlet
 http://camel.apache.org/restlet

 It may be easier to get hold of and use. But CXF may have more
 configuration options, but is also IMHO harder to get started with
 using - some of that is us to blame, for not having better
 documentation and samples. And the fact that IMHO camel-cxf has both
 WS and RS in the same big giant component, which IMHO is becoming a
 problem and hurts the lightweightness of Camel and CXF.

 Really ? I agree that it is not the easiest component to use - that is fare
 and personally I'd have no problems with sharing part of the 'blame' for not
 contributing, but please don't do this hurts the Camel  thing, which is
 FUD IMHO - FYI, I'm perfectly fine with yourself having the preferences, no
 problems there at all !

 Chris: feel free to experiment with all the other HTTP-aware components,
 some of them indeed are simpler to use for a given task.
 FYI, I'm going to work on doing a better demo of using CXF JAX-RS endpoints
 directly within Camel, specifically, using the Camel transport to link
 directly to CXF jaxrs:endpoints, and will update the list.

 Thanks, Sergey

 Even just a basic client making an HTTP GET and getting back some text
 would be great. I still can't do that.
 (See my recent reply to Claus)

 Thanks,

 Chris



 You may also take a look at some of the articles about Camel. There
 should be some good ones about REST etc
 http://camel.apache.org/articles

 For example this article
 http://www.ofbizian.com/2012/02/apache-camel-rest-example.html

 But there is others as well.



 On Thu, Mar 28, 2013 at 11:35 PM, Chris Wolfcwolf.a...@gmail.com  wrote:

 So I have the book, Camel In Action, which is a very good and
 thorough treatment of camel-core. However, now my development efforts
 are starting to hit severe turbulence upon making the jump from
 camel-core to camel-cxf, in particular, how to consume a RESTful
 service?

 I read these:
 http://camel.apache.org/cxfrs.html
 http://camel.apache.org/cxf-bean-component.html

 ...but these pages seem to be reference pages for people who have
 already mastered camel-cxfrs - not newbies, like me.  Can anyone point
 me to an end-to-end example?  I don't need the server-side - this is
 legacy and produces XML.

 N.B. Outside of Camel, I have had much previous experience using CXF
 for JAX-WS style services, client and server  (never JAX-RS, though)

 Thanks for any help,

-Chris








Is there a DataFormat to convert XML string to XML Document?

2013-03-29 Thread Chris Wolf
I don't see any listed here:

http://camel.apache.org/data-format.html

...but I find it hard to believe there isn't a way to convert a string
to XML without creating a custom processor to parse string data from a
web service.

Thanks,

Chris


Re: How can I perform immediate shutdown of a context and all it's routes and services, etc.?

2013-03-28 Thread Chris Wolf
On Thu, Mar 28, 2013 at 3:36 AM, Claus Ibsen claus.ib...@gmail.com wrote:
[...]
 have expected.  Is there a way to restart
 the route from the top upon resuming?  Or do you recommend any other
 busy work kind of route to use
 for RoutePolicy testing?


 The route only runs if there is messages available on the seda queue.
 So send a message to the seda:foo queue to have it route that
 message.
[...]

I'm new to this, but by now, I should have known that - sorry and
thanks again for the help!


Need help with cxfrs component, actually RESTful service consumption, in general

2013-03-28 Thread Chris Wolf
So I have the book, Camel In Action, which is a very good and
thorough treatment of camel-core. However, now my development efforts
are starting to hit severe turbulence upon making the jump from
camel-core to camel-cxf, in particular, how to consume a RESTful
service?

I read these:
http://camel.apache.org/cxfrs.html
http://camel.apache.org/cxf-bean-component.html

...but these pages seem to be reference pages for people who have
already mastered camel-cxfrs - not newbies, like me.  Can anyone point
me to an end-to-end example?  I don't need the server-side - this is
legacy and produces XML.

N.B. Outside of Camel, I have had much previous experience using CXF
for JAX-WS style services, client and server  (never JAX-RS, though)

Thanks for any help,

  -Chris


Re: Clearing ThreadLocal when exchange completes

2013-03-26 Thread Chris Wolf
If you're willing to implement a custom policy, you could implement
onEchangeDone()

http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/spi/RoutePolicy.html#onExchangeDone%28org.apache.camel.Route,%20org.apache.camel.Exchange%29

You could subclass RoutePolicySupport and override onExchangeDone,
which is a no-op there.

The route would look like:

 from(jms:somequeue)
.routeId(my.route).routePolicyRef(cleanupPolicy)
.processRef(someRandomProcessor)
.processRef(someProcessorThatSetsThreadLocalValue)   
.to(jms:someotherqueue)

N.B. the route must have an explicit ID for the policy to find it.

On Tue, Mar 26, 2013 at 9:13 AM, davelund david.r.l...@gmail.com wrote:
 We are currently using ThreadLocal to store some information that gets
 included in a log4j converter (and is used in other projects that dont have
 camel in). Is there a callback I can use that for all routes in my context
 so that at the end of the route it will get called (without explicitly
 setting it) For example:
 from(jms:somequeue)
   .processRef(someRandomProcessor)
   .processRef(someProcessorThatSetsThreadLocalValue)
   
   .to(jms:someotherqueue)


 Ideally I'd like the threadlocal cleared when the exchange has been written
 to the queue, without adding a processor that explicitly clears it (as
 developers when adding new routes will forget to do it). I know the
 onCompletion runs in a seperate thread so isn't fit for my purpose. I've
 noticed  syncronisations and unitofworks, but cant seem to find any
 documentation on it. Would this be fit for purpose?



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Clearing-ThreadLocal-when-exchange-completes-tp5729849.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to schedule FTP with quartz?

2013-03-26 Thread Chris Wolf
Pontus,

I actually gave up on CronScheduledRoutePolicy because I don't want to
have to calculate an absolute suspend time based on the start/resume
time.  What I need is a cron-based policy that specifies the initial
start time, which there-after becomes the resume time - this is a cron
expression - then I just want a relative run duration, after which,
the route is suspended until the next cron-specified resume time.

So, after a few days, I finally have that and it works in the unit
test - even the initial one-off route start will transparently switch
to a resume schedule.  The only problem is that I really need this
policy to control a route with an FTP consumer.  What I'm seeing is
that
even though the route is suspended, the FTP consumer continues to poll
- this partially answers my question about the coding of
ScheduleRoutePolicy - which only suspends the consumer - not the
route, itself.   While my policy suspends the route.

I suspect that any route which has a component using
PollingConsumerPollStrategy will not behave as I though - which is -
you only need to suspend the route and all it's components will be
suspended.  My suspicion is that components whose Consumers are under
the influence of PollingConsumerPollStrategy may not suspend by only
suspended the route.

   -Chris


On Sat, Mar 23, 2013 at 3:15 AM, Pontus Ullgren ullg...@gmail.com wrote:
 This is probably because your route is autoStart=false. So you the first
 time you need to start it. In my example you see I set both the start and
 resume schedule to the same cron expression. So the policy will trigger
 both a start and a resume action.

 And you will get a WARN log since the first time it can not resume (but it
 will start) and after that it can not start but it will resume.

 Perhaps if you share some code it would be easier to help you.
 //Pontus
 On 22 Mar 2013 22:06, Chris Wolf cwolf.a...@gmail.com wrote:

 I found the issue with my custom CronScheduledRoutePolicy - initially
 the startTime/resumeTime are only scheduled in
 onInit() - so to re-resume (re-start), you need to call
 scheduleRoute(Action.RESUME, route); in onStart()

 ...but now I'm getting:

 quartz.ScheduledRoutePolicy WARN  Route is not in a started state and
 cannot be resumed. The current route state is Suspended

 What is the deal?  I thought resumeRoute was the inverse of
 suspenRoute, but this log message seems to indicate that
 calling CamelContext.suspendRoute(routeId) will put the route into a
 state that cannot be resumed.

 Thanks,


 Chris

 On Fri, Mar 22, 2013 at 4:04 PM, Chris Wolf cwolf.a...@gmail.com wrote:
  Pontus,
 
  Thanks for that.  Since I already has started implementing a class
  derived from CronScheduledRoutePolicy, I just finished it.
  It works by starting a Timer thread in onStart/onResume at the end of
  the time period, the route is suspended, but then upon
  the next schedule cron start time, I don't see it being resumed - I
  wonder if the RoutePolicy itself is being suspend too?
 
  Well, I try it your way also.
 
 
  Thanks,
 
 
  Chris
 
  On Wed, Mar 20, 2013 at 4:34 AM, Pontus Ullgren ullg...@gmail.com
 wrote:
  Hello,
 
  On Tue, Mar 19, 2013 at 11:22 PM, Chris Wolf cwolf.a...@gmail.com
 wrote:
  On Mon, Mar 18, 2013 at 4:57 PM, Pontus Ullgren ullg...@gmail.com
 wrote:
  Hello Chris,
 
  On Mon, Mar 18, 2013 at 8:54 PM, Chris Wolf cwolf.a...@gmail.com
 wrote:
  Claus,
 
  I have a few further questions about CronScheduledRoutePolicy.  I
  noticed that it has setters such as setRouteStartTime,
  setRouteStopTime, each which takes a cron expression string.  What
 I'm
  looking for is to be able to use a cron expression for the start, but
  a relative time length for stop.   Otherwise, I need to write code to
  parse the start time expression, then calculate a stop time cron
  expression.  Any ideas?
 
  Depending on your needs you could enable sendEmptyMessageWhenIdle on
  the endpoint and then suspend the route when you receive a empty
  message. Which means that there is no more files to poll at the
  moment.
  You can use the content based route EIP for this.
 
  That is interesting to know, thanks.  In my case, the files at the
  remote end are themselves deposited at an irregular rate, but within a
  defined time window, so during that time window, there will be
  intermittent idleness...
 
  Another solution would be to write your own RoutePolicy to take care
  of your needs.
 
  Yes, this sounds like the best approach...
 
 
 
  I just started to wonder if it might be possible to combine the
  CronScheduledRoutePolicy with a SimpleScheduledRoutePolicy.
  I have _not_ tested this so I'm not sure if it works. It might be that
  there is a collision in the way they work with Quartz.
 
  Also I see that CronScheduledRoutePolicy has setRouteResumeTime,
  setRouteSuspendTime such that for my FTP poll window, I could either
  do start/stop or resume/suspend - which is recommended?
 
  I would highly recommend resume

Re: How to schedule FTP with quartz?

2013-03-26 Thread Chris Wolf
Pontus,

Ok, I got rid of my RoutePolicy and put back the
CronScheduledRoutePolicy and provided both start and resume
cron schedules as you suggested, but CronScheduledRoutePolicy has the
same issue as my RoutePolicy - suspending
the FTPConsumer does NOT stop it from continuing to poll!

56:30,001 CronScheduledRoutePolicy   DEBUG Suspended consumer
FtpConsumer[ftp://localhost/download?filter=%23cpmdFileFilternoop=truepassword=**username=adpt5]
56:35,100 FtpConsumerWARN  Cannot connect/login
to: ftp://adpt5@localhost:21. Will skip this poll.
56:35,100 FtpConsumerDEBUG Skipping poll as pre
poll check returned false


   -Chris

On Tue, Mar 26, 2013 at 4:12 PM, Pontus Ullgren ullg...@gmail.com wrote:
 Chris,

 Is there no way for you to calculate a cron expression for when the
 suspend should occure ?

 Say that you want the route to start every 10 minutes (starting at 0)
 and run for 5 minutes then suspend.
 This would mean that you should be able to define the start/resume
 cron as 0 0,10,20,30,40,50 * * * * ?.
 And the suspend cron expression as 0 5,15,25,35,45,55 * * * * ?.

 The CronScheduledRoutePolicy will trigger a start/resum at 00:00:00
 and then a suspend at 00:05:00, then a new start/resume at 00:10:00
 and a new suspends at 00:15:00 and so on.

 // Pontus

 On Tue, Mar 26, 2013 at 7:39 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Pontus,

 I actually gave up on CronScheduledRoutePolicy because I don't want to
 have to calculate an absolute suspend time based on the start/resume
 time.  What I need is a cron-based policy that specifies the initial
 start time, which there-after becomes the resume time - this is a cron
 expression - then I just want a relative run duration, after which,
 the route is suspended until the next cron-specified resume time.

 So, after a few days, I finally have that and it works in the unit
 test - even the initial one-off route start will transparently switch
 to a resume schedule.  The only problem is that I really need this
 policy to control a route with an FTP consumer.  What I'm seeing is
 that
 even though the route is suspended, the FTP consumer continues to poll
 - this partially answers my question about the coding of
 ScheduleRoutePolicy - which only suspends the consumer - not the
 route, itself.   While my policy suspends the route.

 I suspect that any route which has a component using
 PollingConsumerPollStrategy will not behave as I though - which is -
 you only need to suspend the route and all it's components will be
 suspended.  My suspicion is that components whose Consumers are under
 the influence of PollingConsumerPollStrategy may not suspend by only
 suspended the route.

-Chris


 On Sat, Mar 23, 2013 at 3:15 AM, Pontus Ullgren ullg...@gmail.com wrote:
 This is probably because your route is autoStart=false. So you the first
 time you need to start it. In my example you see I set both the start and
 resume schedule to the same cron expression. So the policy will trigger
 both a start and a resume action.

 And you will get a WARN log since the first time it can not resume (but it
 will start) and after that it can not start but it will resume.

 Perhaps if you share some code it would be easier to help you.
 //Pontus
 On 22 Mar 2013 22:06, Chris Wolf cwolf.a...@gmail.com wrote:

 I found the issue with my custom CronScheduledRoutePolicy - initially
 the startTime/resumeTime are only scheduled in
 onInit() - so to re-resume (re-start), you need to call
 scheduleRoute(Action.RESUME, route); in onStart()

 ...but now I'm getting:

 quartz.ScheduledRoutePolicy WARN  Route is not in a started state and
 cannot be resumed. The current route state is Suspended

 What is the deal?  I thought resumeRoute was the inverse of
 suspenRoute, but this log message seems to indicate that
 calling CamelContext.suspendRoute(routeId) will put the route into a
 state that cannot be resumed.

 Thanks,


 Chris

 On Fri, Mar 22, 2013 at 4:04 PM, Chris Wolf cwolf.a...@gmail.com wrote:
  Pontus,
 
  Thanks for that.  Since I already has started implementing a class
  derived from CronScheduledRoutePolicy, I just finished it.
  It works by starting a Timer thread in onStart/onResume at the end of
  the time period, the route is suspended, but then upon
  the next schedule cron start time, I don't see it being resumed - I
  wonder if the RoutePolicy itself is being suspend too?
 
  Well, I try it your way also.
 
 
  Thanks,
 
 
  Chris
 
  On Wed, Mar 20, 2013 at 4:34 AM, Pontus Ullgren ullg...@gmail.com
 wrote:
  Hello,
 
  On Tue, Mar 19, 2013 at 11:22 PM, Chris Wolf cwolf.a...@gmail.com
 wrote:
  On Mon, Mar 18, 2013 at 4:57 PM, Pontus Ullgren ullg...@gmail.com
 wrote:
  Hello Chris,
 
  On Mon, Mar 18, 2013 at 8:54 PM, Chris Wolf cwolf.a...@gmail.com
 wrote:
  Claus,
 
  I have a few further questions about CronScheduledRoutePolicy.  I
  noticed that it has setters such as setRouteStartTime,
  setRouteStopTime

Re: Question about the implementation of routepolicy.quartz.ScheduledRoutePolicy

2013-03-26 Thread Chris Wolf
Thanks for the clarification on that.  The only problem is that, when
using CronScheduledRoutePolicy
on a route with an FTP endpoint configured as a consumer, it does NOT
seem to prevent the FTP
consumer to stop polling even after it has supposedly been suspended.


56:30,001 CronScheduledRoutePolicy   DEBUG Suspended consumer
FtpConsumer[ftp://localhost/download?filter=%23cpmdFileFilternoop=truepassword=**username=adpt5]
56:35,100 FtpConsumerWARN  Cannot connect/login
to: ftp://adpt5@localhost:21. Will skip this poll.
56:35,100 FtpConsumerDEBUG Skipping poll as pre
poll check returned false


Any ideas?

Thanks,

Chris

On Tue, Mar 26, 2013 at 9:11 PM, Raul Kripalani r...@evosent.com wrote:
 You don't want to stop all endpoints in the route because there may be
 inflight Exchanges. Instead, you want to stop the inflow of new messages
 whilst you keep processing any inflight exchanges.

 That said, it's safe to stop the entire route (including endpoints) once
 all inflight exchanges are completed (or immediately if none are alive) –
 as keeping endpoints started unnecessarily could be a waste of resources.
 Please feel free to log a JIRA.

 On the other hand, all routes start with a consumer of some kind. Mind you,
 it doesn't have to listen on an external protocol. Take for example the
 direct, seda or timer components, which are virtual endpoints.

 Regards,

 *Raúl Kripalani*
 Enterprise Architect, Open Source Integration specialist, Program
 Manager | Apache
 Camel Committer
 http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
 http://blog.raulkr.net | twitter: @raulvk

 On Mon, Mar 25, 2013 at 8:08 PM, Chris Wolf cwolf.a...@gmail.com wrote:

 I am looking at code in
 org.apache.camel.routepolicy.quartz.ScheduledRoutePolicy -
 the code that starts/stops/resumes/suspends the route it is a policy for.

 The question is why is it separately acting on the Consumer? I thought
 if you call
 CamelContext.suspendRoute(route)  and/or CamelContext.resumeRoute(route),
 that all the components in the route are suspended/resumed as well?

 Secondly, why does this code assume there is a Consumer?  What if the
 route has
 a Producer?

 I am not being critical - I just want to understand, generally how
 route suspend/resume works
 since I am implementing a similar RoutePolicy.

 Thanks,


-Chris


  protected void onJobExecute(Action action, Route route) throws Exception {
 [...]
 } else if (action == Action.SUSPEND) {
 if (routeStatus == ServiceStatus.Started) {
 stopConsumer(route.getConsumer());
 } else {
 LOG.warn(Route is not in a started state and cannot
 be suspended. The current route state is {}, routeStatus);
 }
 } else if (action == Action.RESUME) {
 if (routeStatus == ServiceStatus.Started) {
 if (ServiceHelper.isSuspended(route.getConsumer())) {
 startConsumer(route.getConsumer());
 } else {
 LOG.warn(The Consumer {} is not suspended and
 cannot be resumed., route.getConsumer());
 }

 [...]



Re: How to schedule FTP with quartz?

2013-03-26 Thread Chris Wolf
Yes, and after Raul's clarification in his response this evening
(GMT-4), I changed my RoutePolicy implementation
and now it works!

For example, to kick off a cron job at 0615 daily, with a run duration
of 30 minutes, you would do:

CronRoutePolicy ftpPolicy = new CronRoutePolicy(TimeUnit.MINUTES);
ftpPolicy.setRouteStartTime(0 15 6 * * ?);
ftpPolicy.setPollWindowTime(30);

This implementation uses the same Quartz scheduler instance as
ScheduledRoutePolicy, but with
a different job/trigger naming convention, so there's no duplication
and (hopefully) no conflicts.

I appreciate your empty message solution, however, in my case, the
remote files will intermittently appear
during the 30 minute window time, so we have to keep trying, even
after getting some files.

On Tue, Mar 26, 2013 at 4:43 PM, Pontus Ullgren ullg...@gmail.com wrote:
 Sorry read your message a bit to quick.

 If you do not want to calculate the suspend cron expression I guess
 you need to mimic the behaviour of
 org.apache.camel.routepolicy.quartz.ScheduledRoutePolicy where (as you
 point out in another email) the consumer is suspended and not the
 route.

 I'm sorry can not explain why it's implemented this way, I just know
 that in the case of the existing scheduled route policies it seem to
 work as expected. :-)
 Hopefully somebody with more knowledge of the in and outs of Camel can
 explain this to us both.

 // Pontus



 On Tue, Mar 26, 2013 at 9:12 PM, Pontus Ullgren ullg...@gmail.com wrote:
 Chris,

 Is there no way for you to calculate a cron expression for when the
 suspend should occure ?

 Say that you want the route to start every 10 minutes (starting at 0)
 and run for 5 minutes then suspend.
 This would mean that you should be able to define the start/resume
 cron as 0 0,10,20,30,40,50 * * * * ?.
 And the suspend cron expression as 0 5,15,25,35,45,55 * * * * ?.

 The CronScheduledRoutePolicy will trigger a start/resum at 00:00:00
 and then a suspend at 00:05:00, then a new start/resume at 00:10:00
 and a new suspends at 00:15:00 and so on.

 // Pontus

 On Tue, Mar 26, 2013 at 7:39 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Pontus,

 I actually gave up on CronScheduledRoutePolicy because I don't want to
 have to calculate an absolute suspend time based on the start/resume
 time.  What I need is a cron-based policy that specifies the initial
 start time, which there-after becomes the resume time - this is a cron
 expression - then I just want a relative run duration, after which,
 the route is suspended until the next cron-specified resume time.

 So, after a few days, I finally have that and it works in the unit
 test - even the initial one-off route start will transparently switch
 to a resume schedule.  The only problem is that I really need this
 policy to control a route with an FTP consumer.  What I'm seeing is
 that
 even though the route is suspended, the FTP consumer continues to poll
 - this partially answers my question about the coding of
 ScheduleRoutePolicy - which only suspends the consumer - not the
 route, itself.   While my policy suspends the route.

 I suspect that any route which has a component using
 PollingConsumerPollStrategy will not behave as I though - which is -
 you only need to suspend the route and all it's components will be
 suspended.  My suspicion is that components whose Consumers are under
 the influence of PollingConsumerPollStrategy may not suspend by only
 suspended the route.

-Chris


 On Sat, Mar 23, 2013 at 3:15 AM, Pontus Ullgren ullg...@gmail.com wrote:
 This is probably because your route is autoStart=false. So you the first
 time you need to start it. In my example you see I set both the start and
 resume schedule to the same cron expression. So the policy will trigger
 both a start and a resume action.

 And you will get a WARN log since the first time it can not resume (but it
 will start) and after that it can not start but it will resume.

 Perhaps if you share some code it would be easier to help you.
 //Pontus
 On 22 Mar 2013 22:06, Chris Wolf cwolf.a...@gmail.com wrote:

 I found the issue with my custom CronScheduledRoutePolicy - initially
 the startTime/resumeTime are only scheduled in
 onInit() - so to re-resume (re-start), you need to call
 scheduleRoute(Action.RESUME, route); in onStart()

 ...but now I'm getting:

 quartz.ScheduledRoutePolicy WARN  Route is not in a started state and
 cannot be resumed. The current route state is Suspended

 What is the deal?  I thought resumeRoute was the inverse of
 suspenRoute, but this log message seems to indicate that
 calling CamelContext.suspendRoute(routeId) will put the route into a
 state that cannot be resumed.

 Thanks,


 Chris

 On Fri, Mar 22, 2013 at 4:04 PM, Chris Wolf cwolf.a...@gmail.com wrote:
  Pontus,
 
  Thanks for that.  Since I already has started implementing a class
  derived from CronScheduledRoutePolicy, I just finished it.
  It works by starting a Timer thread in onStart

Re: Question about the implementation of routepolicy.quartz.ScheduledRoutePolicy

2013-03-26 Thread Chris Wolf
As for the issue with the consumer appearing to continue to poll - I
think my cron resume/suspend expressions were overlapping.

Thanks,

Chris

On Tue, Mar 26, 2013 at 10:06 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Thanks for the clarification on that.  The only problem is that, when
 using CronScheduledRoutePolicy
 on a route with an FTP endpoint configured as a consumer, it does NOT
 seem to prevent the FTP
 consumer to stop polling even after it has supposedly been suspended.


 56:30,001 CronScheduledRoutePolicy   DEBUG Suspended consumer
 FtpConsumer[ftp://localhost/download?filter=%23cpmdFileFilternoop=truepassword=**username=adpt5]
 56:35,100 FtpConsumerWARN  Cannot connect/login
 to: ftp://adpt5@localhost:21. Will skip this poll.
 56:35,100 FtpConsumerDEBUG Skipping poll as pre
 poll check returned false


 Any ideas?

 Thanks,

 Chris

 On Tue, Mar 26, 2013 at 9:11 PM, Raul Kripalani r...@evosent.com wrote:
 You don't want to stop all endpoints in the route because there may be
 inflight Exchanges. Instead, you want to stop the inflow of new messages
 whilst you keep processing any inflight exchanges.

 That said, it's safe to stop the entire route (including endpoints) once
 all inflight exchanges are completed (or immediately if none are alive) –
 as keeping endpoints started unnecessarily could be a waste of resources.
 Please feel free to log a JIRA.

 On the other hand, all routes start with a consumer of some kind. Mind you,
 it doesn't have to listen on an external protocol. Take for example the
 direct, seda or timer components, which are virtual endpoints.

 Regards,

 *Raúl Kripalani*
 Enterprise Architect, Open Source Integration specialist, Program
 Manager | Apache
 Camel Committer
 http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
 http://blog.raulkr.net | twitter: @raulvk

 On Mon, Mar 25, 2013 at 8:08 PM, Chris Wolf cwolf.a...@gmail.com wrote:

 I am looking at code in
 org.apache.camel.routepolicy.quartz.ScheduledRoutePolicy -
 the code that starts/stops/resumes/suspends the route it is a policy for.

 The question is why is it separately acting on the Consumer? I thought
 if you call
 CamelContext.suspendRoute(route)  and/or CamelContext.resumeRoute(route),
 that all the components in the route are suspended/resumed as well?

 Secondly, why does this code assume there is a Consumer?  What if the
 route has
 a Producer?

 I am not being critical - I just want to understand, generally how
 route suspend/resume works
 since I am implementing a similar RoutePolicy.

 Thanks,


-Chris


  protected void onJobExecute(Action action, Route route) throws Exception {
 [...]
 } else if (action == Action.SUSPEND) {
 if (routeStatus == ServiceStatus.Started) {
 stopConsumer(route.getConsumer());
 } else {
 LOG.warn(Route is not in a started state and cannot
 be suspended. The current route state is {}, routeStatus);
 }
 } else if (action == Action.RESUME) {
 if (routeStatus == ServiceStatus.Started) {
 if (ServiceHelper.isSuspended(route.getConsumer())) {
 startConsumer(route.getConsumer());
 } else {
 LOG.warn(The Consumer {} is not suspended and
 cannot be resumed., route.getConsumer());
 }

 [...]



Re: How can I perform immediate shutdown of a context and all it's routes and services, etc.?

2013-03-25 Thread Chris Wolf
Claus,

Ok, that worked - thanks a lot.

BTW, the unit test is for testing custom RoutePolicy.  The route in
the test looks like:

from(seda:foo).routeId(foo).noAutoStartup().routePolicy(policy)
.loop(10).copy().delay(1000)
.log(*** loop ${property.CamelLoopIndex})
.to(mock:foo);


The RoutePolicy suspends the route, then resume it after a period of
time - it performs this suspend/resume
cycle in a loop.  I notice that this route, using the loop() method
only does the 10 iterations and does not
start from the top again after being resumed, which I guess I should
have expected.  Is there a way to restart
the route from the top upon resuming?  Or do you recommend any other
busy work kind of route to use
for RoutePolicy testing?

Thanks,


Chris

On Sat, Mar 23, 2013 at 4:02 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 Just set the shutdown timeout to 1 milli second (or 1 sec) etc. And
 just call stop on CamelContext.

 And if you extend the CamelTestSupport classes for your unit tests.
 There may be a method you can override and return 1 to indiciate 1 sec
 timeout.



 On Fri, Mar 22, 2013 at 5:23 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 I am implementing some unit tests and if things go wrong I just want
 to shutdown ASAP without regard for inconsistent
 states, etc.  There's no easy hook in DefaultShutDownStrategy to do
 that because you need to know the route
 startup order, so I ended up with this convoluted code (that I kick
 off in a separate thread). It doesn't work, BTW.

 DefaultRouteStartupOrder rsuo = null;
 int startOrder = 0;
 ListRouteStartupOrder suo = new
 ArrayListRouteStartupOrder();
 ListRoute routes = context.getRoutes();
 for (Route route : routes) {
 ListService services = route.getServices();
 for (Service service : services) {
 if (service instanceof RouteService) {
 rsuo = new
 DefaultRouteStartupOrder(startOrder, route, (RouteService) service);
 suo.add(rsuo);
 }
 }
 startOrder++;
 }
 ShutdownStrategy sds = context.getShutdownStrategy();
 sds.shutdownForced(context, suo);

 I know there must be an easier way, but I haven't found such.  Any ideas?

 Thanks,

 Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: SMPP stop route problem

2013-03-25 Thread Chris Wolf
I don't know what your overall route looks like, but I think you will
need to tell an upstream messaging component to stop accepting new
messages, first, before calling context.stopRoute(rid) and also
configure the shutdown strategy to allow sufficient time
to process what was already in the queue:

ShutdownStrategy sds = context.getShutdownStrategy();
sds.setTimeout(120); //== 2 minutes

On Mon, Mar 25, 2013 at 11:14 AM, fclose f...@closebase.com wrote:
 Hello,


 like I explained in a previous post I'm looking for recommendations about
 how to stop a route listening for sms messages.

 Currently I'm stopping the route using the camel context

 camelContext.stopRoute(routeId);

 But doing so I'm losing some messages :
 Here is the description of the problem from the guys at smsc side :

 My application returns an error code FF (Hex) or 255 (Dec) before unbinding.
 Then SMSc will mark the message as an “invalid” and all next messages which
 will be sent  towards the same destination MSISDN will be put automatically
 to “undeliverable” and no delivery attempt will be made until the
 application connects again and starts accepting messages again for this
 destination MSISDN.

 As error code FF or 255 is not according the SMPP specifications, the SMSc
 will consider it as a permanent error (241).






 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/SMPP-stop-route-problem-tp5729769.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Question about the implementation of routepolicy.quartz.ScheduledRoutePolicy

2013-03-25 Thread Chris Wolf
I am looking at code in
org.apache.camel.routepolicy.quartz.ScheduledRoutePolicy -
the code that starts/stops/resumes/suspends the route it is a policy for.

The question is why is it separately acting on the Consumer? I thought
if you call
CamelContext.suspendRoute(route)  and/or CamelContext.resumeRoute(route),
that all the components in the route are suspended/resumed as well?

Secondly, why does this code assume there is a Consumer?  What if the route has
a Producer?

I am not being critical - I just want to understand, generally how
route suspend/resume works
since I am implementing a similar RoutePolicy.

Thanks,


   -Chris


 protected void onJobExecute(Action action, Route route) throws Exception {
[...]
} else if (action == Action.SUSPEND) {
if (routeStatus == ServiceStatus.Started) {
stopConsumer(route.getConsumer());
} else {
LOG.warn(Route is not in a started state and cannot
be suspended. The current route state is {}, routeStatus);
}
} else if (action == Action.RESUME) {
if (routeStatus == ServiceStatus.Started) {
if (ServiceHelper.isSuspended(route.getConsumer())) {
startConsumer(route.getConsumer());
} else {
LOG.warn(The Consumer {} is not suspended and
cannot be resumed., route.getConsumer());
}

[...]


How can I perform immediate shutdown of a context and all it's routes and services, etc.?

2013-03-22 Thread Chris Wolf
I am implementing some unit tests and if things go wrong I just want
to shutdown ASAP without regard for inconsistent
states, etc.  There's no easy hook in DefaultShutDownStrategy to do
that because you need to know the route
startup order, so I ended up with this convoluted code (that I kick
off in a separate thread). It doesn't work, BTW.

DefaultRouteStartupOrder rsuo = null;
int startOrder = 0;
ListRouteStartupOrder suo = new
ArrayListRouteStartupOrder();
ListRoute routes = context.getRoutes();
for (Route route : routes) {
ListService services = route.getServices();
for (Service service : services) {
if (service instanceof RouteService) {
rsuo = new
DefaultRouteStartupOrder(startOrder, route, (RouteService) service);
suo.add(rsuo);
}
}
startOrder++;
}
ShutdownStrategy sds = context.getShutdownStrategy();
sds.shutdownForced(context, suo);

I know there must be an easier way, but I haven't found such.  Any ideas?

Thanks,

Chris


Re: How to schedule FTP with quartz?

2013-03-22 Thread Chris Wolf
Pontus,

Thanks for that.  Since I already has started implementing a class
derived from CronScheduledRoutePolicy, I just finished it.
It works by starting a Timer thread in onStart/onResume at the end of
the time period, the route is suspended, but then upon
the next schedule cron start time, I don't see it being resumed - I
wonder if the RoutePolicy itself is being suspend too?

Well, I try it your way also.


Thanks,


Chris

On Wed, Mar 20, 2013 at 4:34 AM, Pontus Ullgren ullg...@gmail.com wrote:
 Hello,

 On Tue, Mar 19, 2013 at 11:22 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 On Mon, Mar 18, 2013 at 4:57 PM, Pontus Ullgren ullg...@gmail.com wrote:
 Hello Chris,

 On Mon, Mar 18, 2013 at 8:54 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Claus,

 I have a few further questions about CronScheduledRoutePolicy.  I
 noticed that it has setters such as setRouteStartTime,
 setRouteStopTime, each which takes a cron expression string.  What I'm
 looking for is to be able to use a cron expression for the start, but
 a relative time length for stop.   Otherwise, I need to write code to
 parse the start time expression, then calculate a stop time cron
 expression.  Any ideas?

 Depending on your needs you could enable sendEmptyMessageWhenIdle on
 the endpoint and then suspend the route when you receive a empty
 message. Which means that there is no more files to poll at the
 moment.
 You can use the content based route EIP for this.

 That is interesting to know, thanks.  In my case, the files at the
 remote end are themselves deposited at an irregular rate, but within a
 defined time window, so during that time window, there will be
 intermittent idleness...

 Another solution would be to write your own RoutePolicy to take care
 of your needs.

 Yes, this sounds like the best approach...



 I just started to wonder if it might be possible to combine the
 CronScheduledRoutePolicy with a SimpleScheduledRoutePolicy.
 I have _not_ tested this so I'm not sure if it works. It might be that
 there is a collision in the way they work with Quartz.

 Also I see that CronScheduledRoutePolicy has setRouteResumeTime,
 setRouteSuspendTime such that for my FTP poll window, I could either
 do start/stop or resume/suspend - which is recommended?

 I would highly recommend resume/suspend.
 I've had some thread leak problem with the file component when it was
 repetitively started/stopped.

 Ok, but I guess the first policy callback with be onStart since the
 route will be
 configured with noAutoStartup(), so upon that first onStart, I'll
 suspend then toggle
 between onSuspend/onResume...

 Yes this is what I do. We have a route that should start 06:30 each
 day and then poll all files that are in the folder at that time.
 After that it should suspend.

 Here is some pseudo code.
 SuspendRouteProcessor is a processor that suspends the route based on route 
 id.
 ---
 String cronStr = * 30 6 * * * ?;
 String input = 
 ftp://user@remotehost/inbox?sendEmptyMessageWhenIdle=truepassword=secret;;
 CronScheduledRoutePolicy scheduledRP = new CronScheduledRoutePolicy();
 scheduledRoutePolicy.setRouteStartTime(cronStr);
 scheduledRoutePolicy.setRouteResumeTime(cronStr);

 from(input)
 .routeId(input1)
 .routePolicy(versionPolicy, scheduledRoutePolicy)
 .noAutoStartup()
  .choice()
 .when(body().isNotNull())
.to(direct:processFiles)
 .end()
 .log(LoggingLevel.DEBUG, All files processed, suspend route)
 .process(new SuspendRouteProcessor(input1))
 ;
 --

 The only downside with this is that after the initial start we get a
 WARN log message that the route can not be started since it is in
 suspend state.
 But as long as you can live with the WARN log it works.


 // Pontus

 Thanks,

 Chris

 On Sat, Mar 2, 2013 at 1:43 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 See about route policy
 http://camel.apache.org/routepolicy

 And the scheduled route policy
 http://camel.apache.org/scheduledroutepolicy.html

 On Sat, Mar 2, 2013 at 12:15 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 I have a requirement to download files via FTP during a certain time
 window and according to a schedule. e.g. Only on trading days between
 6:30AM and 7:00AM.  The FTP component, alone, seems to just do
 indefinite polling according to delay/initialDelay.

 From the Camel In Action book, chapter 7, I see some examples of
 sending a text message with the Timer and Quartz components, but I
 can't quite see how to put that together to implement kicking off
 routes at specified intervals, mentioned in the best practices list
 at the end of that chapter.  How would I use quartz to stop/start the
 FTP component, or the route that it's in?

 Thanks,

 Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com

Re: How to schedule FTP with quartz?

2013-03-22 Thread Chris Wolf
I found the issue with my custom CronScheduledRoutePolicy - initially
the startTime/resumeTime are only scheduled in
onInit() - so to re-resume (re-start), you need to call
scheduleRoute(Action.RESUME, route); in onStart()

...but now I'm getting:

quartz.ScheduledRoutePolicy WARN  Route is not in a started state and
cannot be resumed. The current route state is Suspended

What is the deal?  I thought resumeRoute was the inverse of
suspenRoute, but this log message seems to indicate that
calling CamelContext.suspendRoute(routeId) will put the route into a
state that cannot be resumed.

Thanks,


Chris

On Fri, Mar 22, 2013 at 4:04 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Pontus,

 Thanks for that.  Since I already has started implementing a class
 derived from CronScheduledRoutePolicy, I just finished it.
 It works by starting a Timer thread in onStart/onResume at the end of
 the time period, the route is suspended, but then upon
 the next schedule cron start time, I don't see it being resumed - I
 wonder if the RoutePolicy itself is being suspend too?

 Well, I try it your way also.


 Thanks,


 Chris

 On Wed, Mar 20, 2013 at 4:34 AM, Pontus Ullgren ullg...@gmail.com wrote:
 Hello,

 On Tue, Mar 19, 2013 at 11:22 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 On Mon, Mar 18, 2013 at 4:57 PM, Pontus Ullgren ullg...@gmail.com wrote:
 Hello Chris,

 On Mon, Mar 18, 2013 at 8:54 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Claus,

 I have a few further questions about CronScheduledRoutePolicy.  I
 noticed that it has setters such as setRouteStartTime,
 setRouteStopTime, each which takes a cron expression string.  What I'm
 looking for is to be able to use a cron expression for the start, but
 a relative time length for stop.   Otherwise, I need to write code to
 parse the start time expression, then calculate a stop time cron
 expression.  Any ideas?

 Depending on your needs you could enable sendEmptyMessageWhenIdle on
 the endpoint and then suspend the route when you receive a empty
 message. Which means that there is no more files to poll at the
 moment.
 You can use the content based route EIP for this.

 That is interesting to know, thanks.  In my case, the files at the
 remote end are themselves deposited at an irregular rate, but within a
 defined time window, so during that time window, there will be
 intermittent idleness...

 Another solution would be to write your own RoutePolicy to take care
 of your needs.

 Yes, this sounds like the best approach...



 I just started to wonder if it might be possible to combine the
 CronScheduledRoutePolicy with a SimpleScheduledRoutePolicy.
 I have _not_ tested this so I'm not sure if it works. It might be that
 there is a collision in the way they work with Quartz.

 Also I see that CronScheduledRoutePolicy has setRouteResumeTime,
 setRouteSuspendTime such that for my FTP poll window, I could either
 do start/stop or resume/suspend - which is recommended?

 I would highly recommend resume/suspend.
 I've had some thread leak problem with the file component when it was
 repetitively started/stopped.

 Ok, but I guess the first policy callback with be onStart since the
 route will be
 configured with noAutoStartup(), so upon that first onStart, I'll
 suspend then toggle
 between onSuspend/onResume...

 Yes this is what I do. We have a route that should start 06:30 each
 day and then poll all files that are in the folder at that time.
 After that it should suspend.

 Here is some pseudo code.
 SuspendRouteProcessor is a processor that suspends the route based on route 
 id.
 ---
 String cronStr = * 30 6 * * * ?;
 String input = 
 ftp://user@remotehost/inbox?sendEmptyMessageWhenIdle=truepassword=secret;;
 CronScheduledRoutePolicy scheduledRP = new CronScheduledRoutePolicy();
 scheduledRoutePolicy.setRouteStartTime(cronStr);
 scheduledRoutePolicy.setRouteResumeTime(cronStr);

 from(input)
 .routeId(input1)
 .routePolicy(versionPolicy, scheduledRoutePolicy)
 .noAutoStartup()
  .choice()
 .when(body().isNotNull())
.to(direct:processFiles)
 .end()
 .log(LoggingLevel.DEBUG, All files processed, suspend 
 route)
 .process(new SuspendRouteProcessor(input1))
 ;
 --

 The only downside with this is that after the initial start we get a
 WARN log message that the route can not be started since it is in
 suspend state.
 But as long as you can live with the WARN log it works.


 // Pontus

 Thanks,

 Chris

 On Sat, Mar 2, 2013 at 1:43 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 See about route policy
 http://camel.apache.org/routepolicy

 And the scheduled route policy
 http://camel.apache.org/scheduledroutepolicy.html

 On Sat, Mar 2, 2013 at 12:15 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 I have a requirement to download files via FTP during a certain time
 window and according to a schedule. e.g. Only on trading days between
 6:30AM and 7:00AM

Re: How to schedule FTP with quartz?

2013-03-19 Thread Chris Wolf
On Mon, Mar 18, 2013 at 4:57 PM, Pontus Ullgren ullg...@gmail.com wrote:
 Hello Chris,

 On Mon, Mar 18, 2013 at 8:54 PM, Chris Wolf cwolf.a...@gmail.com wrote:
 Claus,

 I have a few further questions about CronScheduledRoutePolicy.  I
 noticed that it has setters such as setRouteStartTime,
 setRouteStopTime, each which takes a cron expression string.  What I'm
 looking for is to be able to use a cron expression for the start, but
 a relative time length for stop.   Otherwise, I need to write code to
 parse the start time expression, then calculate a stop time cron
 expression.  Any ideas?

 Depending on your needs you could enable sendEmptyMessageWhenIdle on
 the endpoint and then suspend the route when you receive a empty
 message. Which means that there is no more files to poll at the
 moment.
 You can use the content based route EIP for this.

That is interesting to know, thanks.  In my case, the files at the
remote end are themselves deposited at an irregular rate, but within a
defined time window, so during that time window, there will be
intermittent idleness...

 Another solution would be to write your own RoutePolicy to take care
 of your needs.

Yes, this sounds like the best approach...



 I just started to wonder if it might be possible to combine the
 CronScheduledRoutePolicy with a SimpleScheduledRoutePolicy.
 I have _not_ tested this so I'm not sure if it works. It might be that
 there is a collision in the way they work with Quartz.

 Also I see that CronScheduledRoutePolicy has setRouteResumeTime,
 setRouteSuspendTime such that for my FTP poll window, I could either
 do start/stop or resume/suspend - which is recommended?

 I would highly recommend resume/suspend.
 I've had some thread leak problem with the file component when it was
 repetitively started/stopped.

Ok, but I guess the first policy callback with be onStart since the
route will be
configured with noAutoStartup(), so upon that first onStart, I'll
suspend then toggle
between onSuspend/onResume...


 // Pontus

 Thanks,

 Chris

 On Sat, Mar 2, 2013 at 1:43 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 See about route policy
 http://camel.apache.org/routepolicy

 And the scheduled route policy
 http://camel.apache.org/scheduledroutepolicy.html

 On Sat, Mar 2, 2013 at 12:15 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 I have a requirement to download files via FTP during a certain time
 window and according to a schedule. e.g. Only on trading days between
 6:30AM and 7:00AM.  The FTP component, alone, seems to just do
 indefinite polling according to delay/initialDelay.

 From the Camel In Action book, chapter 7, I see some examples of
 sending a text message with the Timer and Quartz components, but I
 can't quite see how to put that together to implement kicking off
 routes at specified intervals, mentioned in the best practices list
 at the end of that chapter.  How would I use quartz to stop/start the
 FTP component, or the route that it's in?

 Thanks,

 Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


Re: Programatically adding beans to a registry in a RouteBuilder

2013-03-18 Thread Chris Wolf
It may, or may not be wrapped in PropertyPlaceholderDelegateRegistry,
in that case, I would try this:

Registry registry = context.getRegistry();
if (registry instanceof PropertyPlaceholderDelegateRegistry)
registry =
((PropertyPlaceholderDelegateRegistry)registry).getRegistry();


Then cast to implementation-specific Registry type to access bind()
(or put) method.

(Pretty much what Donald was saying...)

On Mon, Mar 18, 2013 at 2:14 PM, Donald Whytock dwhyt...@gmail.com wrote:
 On Mon, Mar 18, 2013 at 2:02 PM, Gert Villemos gville...@gmail.com wrote:
 Hmmm... tried that but doesnt work.

 getContext() returns a
 org.apache.camel.impl.PropertyPlaceholderDelegateRegistry object. Which cant
 be cast to JndiRegistry.

 My setup is the following; In a Spring based route I have bean A. Bean As
 @Handler will create an instance of bean B, which is a RouteBuilder, and add
 bean B's routes to the context. Bean A thus 'starts' bean B.

 Apologies...I was looking at the DefaultCamelContext source and seeing
 that by default it creates a JndiRegistry.

 I'm assuming you meant getRegistry() above instead of getContext()?
 Such that camelContext.getRegistry() returns the
 PropertyPlaceholderDelegateRegistry?

 According to the current javadoc, PropertyPlaceholderDelegateRegistry
 is A Registry which delegates to the real registry.  The object has
 its own getRegistry() method, which returns a Registry.

 So...I'm sorry to say this, but...have you tried

 JndiRegistry registry = (JndiRegistry) 
 camelContext.getRegistry().getRegistry();

 ?


Re: How to schedule FTP with quartz?

2013-03-04 Thread Chris Wolf
Ok, that's what I was looking for - specifically the Cron version:

http://camel.apache.org/cronscheduledroutepolicy.html

Thanks for the help,

Chris

On Sat, Mar 2, 2013 at 1:43 AM, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 See about route policy
 http://camel.apache.org/routepolicy

 And the scheduled route policy
 http://camel.apache.org/scheduledroutepolicy.html

 On Sat, Mar 2, 2013 at 12:15 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 I have a requirement to download files via FTP during a certain time
 window and according to a schedule. e.g. Only on trading days between
 6:30AM and 7:00AM.  The FTP component, alone, seems to just do
 indefinite polling according to delay/initialDelay.

 From the Camel In Action book, chapter 7, I see some examples of
 sending a text message with the Timer and Quartz components, but I
 can't quite see how to put that together to implement kicking off
 routes at specified intervals, mentioned in the best practices list
 at the end of that chapter.  How would I use quartz to stop/start the
 FTP component, or the route that it's in?

 Thanks,

 Chris



 --
 Claus Ibsen
 -
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 Email: cib...@redhat.com
 Web: http://fusesource.com
 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen


How to schedule FTP with quartz?

2013-03-01 Thread Chris Wolf
I have a requirement to download files via FTP during a certain time
window and according to a schedule. e.g. Only on trading days between
6:30AM and 7:00AM.  The FTP component, alone, seems to just do
indefinite polling according to delay/initialDelay.

From the Camel In Action book, chapter 7, I see some examples of
sending a text message with the Timer and Quartz components, but I
can't quite see how to put that together to implement kicking off
routes at specified intervals, mentioned in the best practices list
at the end of that chapter.  How would I use quartz to stop/start the
FTP component, or the route that it's in?

Thanks,

Chris


Re: Has anyone ever successfully deployed the Camel Web Console on JBoss-6?

2013-02-28 Thread Chris Wolf
I got past the issue of JBoss croaking on Scala by the workaround
mentioned here:
http://www.mastertheboss.com/infinispan/infinispan-restful-interface

Now, the error is:
11:56:19,087 SEVERE The ResourceConfig instance does not contain any
root resource classes.
[com.sun.jersey.server.impl.application.RootResourceUriRules]
11:56:19,087 SEVERE Exception occurred when intialization:
com.sun.jersey.api.container.ContainerException: The ResourceConfig
instance does not contain any root resource classes.
at 
com.sun.jersey.server.impl.application.RootResourceUriRules.init(RootResourceUriRules.java:99)
[:1.12]
at 
com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1308)
[:1.12]


If anyone has an idea.

Thanks,

Chris

On Thu, Feb 28, 2013 at 11:47 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 It's looking like JBoss doesn't like Scala because I'm getting this error:

 Caused by: java.lang.RuntimeException: Error visiting resource:
 VFSResourceContext
  
 @scala/tools/nsc/backend/icode/ICodeCheckers$ICodeChecker$$anonfun$ifAthenB$1$1.class
 / 
 BaseClassLoader@5c4766d2{vfs:///C:/opt/jboss6rdf/server/default/services/camel.war},
 visitor: 
 org.jboss.scanning.annotations.plugins.GenericAnnotationVisitor@1741be6c
 ...
 Caused by: java.lang.IllegalArgumentException: Null type
 at 
 org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.getTypeInfo(IntrospectionTypeInfoFactoryImpl.java:330)
 [jboss-reflect.jar:2.2.1.SP1]

 ...and searching on the web yields a bunch of hits regarding Scala on
 JBoss, but not this, exact issue.

 Thanks,

 Chris


Is there anyway to configure the JPA component to get it's query (or query parameters) from an inbound message?

2013-02-27 Thread Chris Wolf
I ask because I want the query to be parameterized be the results of
up-stream component executions.

Thanks,


Chris


Re: Is there anyway to configure the JPA component to get it's query (or query parameters) from an inbound message?

2013-02-27 Thread Chris Wolf
I figured out how to do it.  If anyone is interested, I can supply details.

On Wed, Feb 27, 2013 at 10:54 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 I ask because I want the query to be parameterized by the results of
 up-stream component executions.

 Thanks,


 Chris


Cannot get @Consumed to work for JpaConsumer endpoint

2013-02-25 Thread Chris Wolf
I have a route whose first endpoint is .from(jpa:...) - i.e. a
consumer.  I have consumeDelete=false and in my entities, I have a
method
marked with @Consumed - in this method, I invoke another setter to
set a nullable persistent field of type DATE.  Everything works,
but this date field is still null.  When I run in the debugger, the
method marked by @Consumed never gets invoked.

How/what detects this @Consumed annotation?

Thanks,

   -Chris


Re: Cannot get @Consumed to work for JpaConsumer endpoint

2013-02-25 Thread Chris Wolf
Problem solved.  The issue was that even though the documentation
states that JPA consumer must specify the entitytype, I found that it
worked without it and I never got an explanation *why* it was needed.
 Since I already had a big, giant URI, I left it out.  Apparently one
of the reasons the JPA consumer needs it, is support for the
@Consumed mechanism, which I found out by debugging.  Now that I put
it back, my @Consumed handler works...

On Mon, Feb 25, 2013 at 11:56 AM, Chris Wolf cwolf.a...@gmail.com wrote:
 I have a route whose first endpoint is .from(jpa:...) - i.e. a
 consumer.  I have consumeDelete=false and in my entities, I have a
 method
 marked with @Consumed - in this method, I invoke another setter to
 set a nullable persistent field of type DATE.  Everything works,
 but this date field is still null.  When I run in the debugger, the
 method marked by @Consumed never gets invoked.

 How/what detects this @Consumed annotation?

 Thanks,

-Chris


Re: Does Camel JPA component implement it's own connection pooling?

2013-02-01 Thread Chris Wolf
James,

This latest suggestion works, but I also configured connection
pooling, so I went back to your prior suggestion of using JpaTemplate
and the nested anonymous classes and that now works also.

I know what you're thinking - why didn't I use connection pooling to
begin with?   Well since I had multiple issues to deal with, I
considered pooling to be an optimization which could wait.

I assumed that since my test scaffold was just a
single-process/single-threaded, that it would just use a single
connection to synchronously perform each step of persistence, but
since I'm using sequence-based key generation, I think there is
something in the OpenJPA implementation that assumes pooling is in
use.

I will let the OpenJPA guys know.

Thanks again for your help.

-Chris

On Thu, Jan 31, 2013 at 9:14 PM, James Carman
jcar...@carmanconsulting.com wrote:
 Try this:

JpaTransactionManager transactionManager = new 
 JpaTransactionManager(factory);

 TransactionTemplate template = new 
 TransactionTemplate(transactionManager);
 template.execute(new TransactionCallbackWithoutResult()
 {
 @Override
 protected void doInTransactionWithoutResult(TransactionStatus 
 status)
 {
 EntityManager em = 
 EntityManagerFactoryUtils.getTransactionalEntityManager(factory);
 MyEntity entity = new MyEntity();
 em.persist(entity);
 }
 });

 On Jan 31, 2013, at 5:49 PM, Chris Wolf cwolf.a...@gmail.com wrote:

 James,

 Ok, now using TransactionTemplate, but I'm back to where I was - the
 same apparent connection leak, only now
 the code is hideous with all those nested anonymous classes and whatnot... ;)


   -Chris

static void saveToDB(final ListMdBaseData data) throws Exception {
   EntityManagerFactory emf = Persistence
   .createEntityManagerFactory(marketdata);

   final JpaTemplate jpaTempl = new JpaTemplate(emf);
   jpaTempl.afterPropertiesSet();

   JpaTransactionManager jpaTxMgr = new 
 JpaTransactionManager(emf);
   jpaTxMgr.afterPropertiesSet();

   final TransactionTemplate txTmpl = new 
 TransactionTemplate(jpaTxMgr);
   txTmpl.afterPropertiesSet();

   TransactionStrategy txStrategy = new TransactionStrategy() {
   @SuppressWarnings(deprecation)
   public Object execute(final JpaCallback? callback) {
   return txTmpl.execute(new 
 TransactionCallbackObject() {
   public Object 
 doInTransaction(TransactionStatus status) {
   return jpaTempl.execute(new 
 JpaCallbackObject() {
   public Object 
 doInJpa(EntityManager entityManager)
   throws 
 PersistenceException {
   return 
 callback.doInJpa(entityManager);
   }
   });
   }
   });
   }
   };

   txStrategy.execute(new JpaCallbackObject() {
   @Override
   public Object doInJpa(EntityManager em) throws 
 PersistenceException {
   for (MdBaseData bd : data) {
   em.persist(bd);
   }
   return null; // writing to db, not reading...
   }
   });
}


 On Thu, Jan 31, 2013 at 4:42 PM, James Carman
 jcar...@carmanconsulting.com wrote:
 Try using TransactionTemplate.

 On Jan 31, 2013, at 4:19 PM, Chris Wolf cwolf.a...@gmail.com wrote:

 James,

 As per your suggestion, I let Spring manage the transactions and the
 apparent connection leak went away and I only see one connection
 being opened per session, as expected.

 Unfortunately, nothing got inserted into the database.

 Thanks,

  -Chris

 My modified code looks like:


   static void saveToDB(ListMdBaseData data) throws Exception {
  EntityManagerFactory emf = Persistence
  .createEntityManagerFactory(marketdata);
  JpaTransactionManager jpaTxMgr = new 
 JpaTransactionManager(emf);


  EntityManager em =
  
 jpaTxMgr.getEntityManagerFactory().createEntityManager();
  TransactionStatus txStatus =
  jpaTxMgr.getTransaction(new 
 DefaultTransactionDefinition());
  try {
  //em.getTransaction().begin();
  for (MdBaseData bd : data

  1   2   >