Re: How to get route information

2012-07-29 Thread magic.coder
Hi Ashwin,

I am also facing the same issue.
The solution that you have given works only if camel is configured as a
Spring bean.

However, in my case, it is not configured as a Spring bean.
In this scenario, how do I get hold of the existing camel context when 
I am using Java DSL and not Spring DSL?

Kindly help me with this.

Regards,
Magic.Coder.



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-get-route-information-tp3240512p5716600.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Not writing to Error queue

2012-07-29 Thread nishant.rupani
No, source MQ queue and error MQ queue are different.

First I tried with single JMS "wmq" only. It didn't work so I thought of 
creating two - one for regular consumer and another for error queue. However, 
that didn't work either.

Unfortunately due to restriction put here, I cannot send whole XML.

Snippet of my context is -


1) Using onException -

http://camel.apache.org/schema/spring"; trace="true">


java.sql.SQLException


true









recipients

























2) Using dead letter queue
http://camel.apache.org/schema/spring"; trace="true">





recipients











































Regards,
Nishant


From: Christian Mueller [via Camel] 
[mailto:ml-node+s465427n571656...@n5.nabble.com]
Sent: Friday, July 27, 2012 11:14 PM
To: Rupani, Nishant (ISGT)
Subject: Re: Not writing to Error queue

You use the same WebShere MQ queue manager for receiving the messages and
writing the failed messages, correct?

Could you please share the entire Spring XML configuration (including the
JMS component configuration). I'm a bit confused because you use 'wmq' and
'wmqError' as schema name. Did you also configured two JMS components? If
yes, why? If no, it cannot work...

Best,
Christian

On Fri, Jul 27, 2012 at 10:10 AM, nishant.rupani <
[hidden email]> wrote:

> Nope it doesn't. It just has print. I've removed it too but still same
> issues.
>
> Regards,
> Nishant
>
>
> From: Christian Mueller [via Camel] [mailto:
> [hidden email]]
> Sent: Friday, July 27, 2012 1:32 PM
> To: Rupani, Nishant (ISGT)
> Subject: Re: Not writing to Error queue
>
> May be the exceptionPrint method of exceptionHandler throws an exception?
>
> Christian
>
> On Fri, Jul 27, 2012 at 7:25 AM, nishant.rupani <
> [hidden email]> wrote:
>
> > Hi,
> >
> > Yes, I've setup JMS. I checked the setup by putting " > uri="wmqError:${error.queue}" />" directly into the router and it worked
> > well.
> >
> > Few more things I noticed,
> >
> > -   if I call a method directly from main route that throws test
> > exception then it gets written to error queue fine. But if any of the
> > recipient throws exception then it is not getting written to error queue.
> >
> > -   It is not that onException is not being executed at all.
> > exceptionPrint method of exceptionHandler is being called fine always.
> >
> > Regards,
> > Nishant
> >
> > From: Willem.Jiang [via Camel] [mailto:
> > [hidden email]]
> > Sent: Friday, July 27, 2012 10:48 AM
> > To: Rupani, Nishant (ISGT)
> > Subject: Re: Not writing to Error queue
> >
> > Hi,
> >
> > Why are you using the scheme of wmqError?
> > Did you setup up jms component with id of wmqError rightly?
> >
> >
> > On 7/25/12 5:50 PM, nishant.rupani wrote:
> >
> > > I don't see any reference of retry or error queue write in logs. Method
> > exceptionPrint is being called fine.
> > >
> > > Snippet of my context is -
> > >
> > > 1)
> > >  http://camel.apache.org/schema/spring"; trace="true">
> > >
> > >  
> > >
> >  java.sql.SQLException
> > >   > logRetryAttempted="

RE: Not writing to Error queue

2012-07-29 Thread nishant.rupani
Yes, onException is being called. As you see in the onException, exceptionPrint 
method is getting called fine. ""

It is just not writing to the error queue.

Regards,
Nishant

From: Willem.Jiang [via Camel] [mailto:ml-node+s465427n5716571...@n5.nabble.com]
Sent: Saturday, July 28, 2012 6:57 AM
To: Rupani, Nishant (ISGT)
Subject: Re: Not writing to Error queue

On 7/27/12 1:25 PM, nishant.rupani wrote:
> Hi,
>
> Yes, I've setup JMS. I checked the setup by putting " uri="wmqError:${error.queue}" />" directly into the router and it worked well.
>
> Few more things I noticed,
>
> -   if I call a method directly from main route that throws test 
> exception then it gets written to error queue fine. But if any of the 
> recipient throws exception then it is not getting written to error queue.
>

When the recipient throws exception, is your onException being executed?
If not, it could be easy for us to create a simple unit test to
reproduce the error.

> -   It is not that onException is not being executed at all. 
> exceptionPrint method of exceptionHandler is being called fine always.
>
> Regards,
> Nishant
>
> From: Willem.Jiang [via Camel] [mailto:[hidden 
> email]]
> Sent: Friday, July 27, 2012 10:48 AM
> To: Rupani, Nishant (ISGT)
> Subject: Re: Not writing to Error queue
>
> Hi,
>
> Why are you using the scheme of wmqError?
> Did you setup up jms component with id of wmqError rightly?
>
>
> On 7/25/12 5:50 PM, nishant.rupani wrote:
>
>> I don't see any reference of retry or error queue write in logs. Method 
>> exceptionPrint is being called fine.
>>
>> Snippet of my context is -
>>
>> 1)
>>   > xmlns="http://camel.apache.org/schema/spring"; trace="true">
>>
>>   
>>   
>> java.sql.SQLException
>>   > logRetryAttempted="true" logRetryStackTrace="true" maximumRedeliveries="3"
>>   
>> retryAttemptedLogLevel="DEBUG" retriesExhaustedLogLevel="ERROR" />
>>   
>>   true
>>   
>>   > method="exceptionPrint" />
>>   
>>   
>>
>>   
>>   
>>   
>>   
>>   recipients
>>   
>>
>>   
>>   
>>
>> 2)
>> > xmlns="http://camel.apache.org/schema/spring"; trace="true">
>>
>>   > errorHandlerRef="myDeadLetterErrorHandler">
>>   
>>   
>>   
>>   recipients
>>   
>>   
>>
>>   > class="org.apache.camel.builder.DeadLetterChannelBuilder">
>>   > value="wmq:${error.queue}" />
>>   > ref="myRedeliveryPolicyConfig" />
>>   
>>
>>   > class="org.apache.camel.processor.RedeliveryPolicy">
>>   
>>   
>>   
>>   
>>   
>>   
>>   
>>   
>>   
>>   .
>>   .
>>   .
>> 
>>
>> From: iocanel [via Camel] [mailto:[hidden 
>> email]]
>> Sent: Wednesday, July 25, 2012 2:46 PM
>> To: Rupani, Nishant (ISGT)
>> Subject: Re: Not writing to Error queue
>>
>> Can you please share your full camel context?
>> Also do you see anything in the logs?
>> --
>> *Ioannis Canellos*
>> *
>> FuseSource 
>>
>> **
>> Blog: http://iocanel.blogspot.com
>> **
>> Twitter: iocanel
>> *
>> Ioannis Canellos http://iocanel.blogspot.com
>>
>> 
>> If you reply to this email, your message will be added to the discussion 
>> below:
>>
>> NAML
>>
>> --
>> NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions 
>> or views contained herein are not intended to be, and do not constitute, 
>> advice within the meaning of Section 975 of the Dodd-Frank Wall Street 
>> Reform and Consumer Protecti

Re: Camel CouchDB Component

2012-07-29 Thread Christian Müller
If you want to donate this component to Apache Camel (and you have the
right to do this), please raise a JIRA [1] and attach a patch (make sure
you grant the rights to Apache). As you may know, we love contributions
[2]... ;-)

[1] https://issues.apache.org/jira/browse/CAMEL
[2] http://camel.apache.org/contributing.html

Best,
Christian

On Sun, Jul 29, 2012 at 8:13 PM, Sam (Stephen Samuel)
wrote:

> Hi All,
>
> We've been using Camel and CouchDB successfully for 6 months on one of
> our platforms at work. There was no CouchDB component that I could
> find at the time, so I wrote one. I still cannot find one, so I've
> open sourced mine.
>
> You can find it here:
> https://github.com/sksamuel/camel-couchdb
>
> Let's you monitor CouchDB for inserts / deletes and these are then
> published as events. It's very similar to the MongoDB / Redis
> components.
>
> Licensed under Apache 2.0
>


Re: Exception handling in consumer for a custom endpoint

2012-07-29 Thread Christian Müller
If your doStart() method throws an exception, the application will not
start [1].
If your poll() method throws an exception, Camel will retry until the retry
count is exceeded. Than the route will stop polling [2].

[1]
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/main/Main.java
[2]
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java

Best,
Christian

On Sun, Jul 29, 2012 at 6:49 PM, gilboy  wrote:

> Hi
>
> I have a custom endpoint/component. The consumer is a
> scheduledpollconsumer.
> I had a quick question on the behaviour of the *doStart() *and *poll()
> *methods which I implement in my consumer.
>
> Basically, the implementation of these 2 methods which I have provided in
> my
> consumer do quite a bit of processing. Hence, I was trying to confirm how
> camel will behave if an exception occurs in my doStart() or poll() methods
> which I do not handle.
>
> In other words, I am trying to understand how the core camel code will
> behave if an unhandled exception is passed back from either my doStart() or
> poll() method?
>
> Thanks
> Joe
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Exception-handling-in-consumer-for-a-custom-endpoint-tp5716588.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Options for creating dynamic filters

2012-07-29 Thread Pontus Ullgren
Hello,

The reason that camel does not stop the route directly is that there
are inflight messages in the route.
Setting the timeout to 1 will shorten the time camel wait for the
inflight messages to be processed so there is a risk that by doing
this messages will be lost.

Another approch could be that you create your own filter bean that can
be updated dynamicly with a new expression.

So if you change your route to something like this
 from("seda:sometag?multipleConsumers=true")

.routeId(RouteIdCreator.createRouteId(toIP, toPort, "sometag"))
.filter().bean("myFilter")
.unmarshal().jaxb("sometag")

.marshal().json().wireTap("mina:udp://client_ip_address:20001?sync=false");

Then register a bean called myFilter that implements predicter. That
does somthing like this...

public class MyFilter implements Predicate {
private Map routeFilterMap = new HashMap(); 

public void addFilter(String routeId, String expression) {
routeFilterMap.put(routeId, expression);
}

@Override
public boolean matches(Exchange exchange) {
String expression = 
routeFilterMap.get(exchange.getFromRouteId());
if ( expression != null ) {
// return the result of the evaluated expression
} else {
return false;
}
}
}

Then you can update the expression in runtime by calling the
addFilter() method from another route.

// Pontus

On Sun, Jul 29, 2012 at 2:14 PM, soumya_sd  wrote:
> I found a solution for this.
>
> I added the following and now the Camel forces the route to shutdown in 1
> seconds (timeout time) instead of the default 300 seconds.
>
>  class="org.apache.camel.impl.DefaultShutdownStrategy">
> 
> 
>
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Options-for-creating-dynamic-filters-tp5716584p5716585.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Camel CouchDB Component

2012-07-29 Thread Sam (Stephen Samuel)
Hi All,

We've been using Camel and CouchDB successfully for 6 months on one of
our platforms at work. There was no CouchDB component that I could
find at the time, so I wrote one. I still cannot find one, so I've
open sourced mine.

You can find it here:
https://github.com/sksamuel/camel-couchdb

Let's you monitor CouchDB for inserts / deletes and these are then
published as events. It's very similar to the MongoDB / Redis
components.

Licensed under Apache 2.0


Re: Options for creating dynamic filters

2012-07-29 Thread Christian Müller
Do you try to stop the route running the same thread? You should do it in a
different thread.

Best,
Christian

On Sun, Jul 29, 2012 at 2:14 PM, soumya_sd  wrote:

> I found a solution for this.
>
> I added the following and now the Camel forces the route to shutdown in 1
> seconds (timeout time) instead of the default 300 seconds.
>
>  class="org.apache.camel.impl.DefaultShutdownStrategy">
> 
> 
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Options-for-creating-dynamic-filters-tp5716584p5716585.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Dynamic generation of Camel routes

2012-07-29 Thread Pontus Ullgren
Hello Joe,

Provided that you do not have the routes set up to have
autoStartup(false) I do not believe you will have to call
camelContext.startRoute(..).

I agree that it is strange that the first route seem to shutdown
directly. Could you post some more information about your routes or
even a small test case that reproduces your problem. I think that will
help to us.

// Pontus


On Sun, Jul 29, 2012 at 6:36 PM, gilboy  wrote:
> Hi Folks
>
> Thanks for all the helpful responses on this item.
>
> Basically,  I followed an approach similar to what Pontus outlined above.
>
> However, I have noted some strange behavior. When my application has started
> up the routes get added as follows:
>
> *context.addRoutes(new RouteBuilder().*
>
> After this I get a reference to all the routes on the context and call (for
> all of my routes):
> *camelContext.startRoute("routeid") *
> ..to ensure all the routes get started.
>
> I am typically creating about 25 routes dynamically. However, I notice that
> the *first *route that gets started always seems to fail while the reset of
> them run fine:
>
> *20120727 18:51:38,598 IST INFO  impl.DefaultShutdownStrategy [Thread-4]
> Starting to graceful shutdown 1 routes (timeout 300 seconds)*
>
> I have tried debugging with no success. I have increased debug levels etc
> but am not getting any information that can help me determine why the first
> route always gets shut down
>
> Any help/suggestions greatly appreciated
> Thanks
> Joe
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Dynamic-generation-of-Camel-routes-tp5716223p5716587.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Exception handling in consumer for a custom endpoint

2012-07-29 Thread gilboy
Hi

I have a custom endpoint/component. The consumer is a scheduledpollconsumer.
I had a quick question on the behaviour of the *doStart() *and *poll()
*methods which I implement in my consumer.

Basically, the implementation of these 2 methods which I have provided in my
consumer do quite a bit of processing. Hence, I was trying to confirm how
camel will behave if an exception occurs in my doStart() or poll() methods
which I do not handle. 

In other words, I am trying to understand how the core camel code will
behave if an unhandled exception is passed back from either my doStart() or
poll() method?

Thanks
Joe 



--
View this message in context: 
http://camel.465427.n5.nabble.com/Exception-handling-in-consumer-for-a-custom-endpoint-tp5716588.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Dynamic generation of Camel routes

2012-07-29 Thread gilboy
Hi Folks

Thanks for all the helpful responses on this item.

Basically,  I followed an approach similar to what Pontus outlined above.

However, I have noted some strange behavior. When my application has started
up the routes get added as follows:

*context.addRoutes(new RouteBuilder().*

After this I get a reference to all the routes on the context and call (for
all of my routes):
*camelContext.startRoute("routeid") *
..to ensure all the routes get started.

I am typically creating about 25 routes dynamically. However, I notice that
the *first *route that gets started always seems to fail while the reset of
them run fine:

*20120727 18:51:38,598 IST INFO  impl.DefaultShutdownStrategy [Thread-4]
Starting to graceful shutdown 1 routes (timeout 300 seconds)*

I have tried debugging with no success. I have increased debug levels etc
but am not getting any information that can help me determine why the first
route always gets shut down

Any help/suggestions greatly appreciated
Thanks
Joe



--
View this message in context: 
http://camel.465427.n5.nabble.com/Dynamic-generation-of-Camel-routes-tp5716223p5716587.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: RouteDefinition vs Route

2012-07-29 Thread Sam (Stephen Samuel)
I can update camelwatch to add in extra properties, or you could
update the project and do a pull request.

On Sat, Jul 28, 2012 at 7:45 PM, Bob Jolliffe  wrote:
> Ah .. just realized that if I cast my CamelContext to a
> ModelCamelContext I can do all I need to do with RouteDefinitions
> (rather than Routes)
>
> On 28 July 2012 17:54, Bob Jolliffe  wrote:
>> Thanks Babak
>>
>> On 28 July 2012 11:42, Babak Vahdat  wrote:
>>> Hi
>>>
>>> the easiest is to check their javadoc:
>>>
>>> http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Route.html
>>> http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/model/RouteDefinition.html
>>
>> Have done that ...
>>
>>> Another way around, in the context of the MVC pattern one could claim that
>>> the RouteDefinition is 'M' (using JAXB for mapping between Java/XML) whereas
>>> the Route abstraction is both the 'V' as well as 'C'.
>>
>> I almost get what you are saying but it doesn't quite work for me.  If
>> the Route is a view (which I know is a bit of a stretch) then it has
>> to be a view of something.  I guess I would expect to see a
>> getRouteDefinition() method on the Route in that case.
>>
>> So my question is that starting from the Context you can get a list of
>> Routes and a list of RouteDefinitions.  How do these relate to one
>> another?  I can see that if the Route/RouteDefinitions have an id.
>> then you can find one from the other through that, but the coupling is
>> loose and possibly for a good reason.
>>
>> It seems more that a RouteDefinition is a sort of template for
>> creating a Route .. probably there is something historic in this as
>> the javadocs refer specifically to the  element, so there is
>> clearly a jaxb model type relationship.  Except that the configure()
>> method of RouteBuilder also creates a RouteDefinition rather than a
>> Route, so RouteDefinition is a bit broader in its semantics than
>> that..
>>
>> Still exploring further .. thanks.
>> Bob
>>
>>>
>>> Babak
>>>
>>>
>>>
>>> --
>>> View this message in context: 
>>> http://camel.465427.n5.nabble.com/RouteDefinition-vs-Route-tp5716578p5716579.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
-Sam


Re: Options for creating dynamic filters

2012-07-29 Thread soumya_sd
I found a solution for this. 

I added the following and now the Camel forces the route to shutdown in 1
seconds (timeout time) instead of the default 300 seconds. 









--
View this message in context: 
http://camel.465427.n5.nabble.com/Options-for-creating-dynamic-filters-tp5716584p5716585.html
Sent from the Camel - Users mailing list archive at Nabble.com.