You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ninadmnaik <nn...@gmail.com> on 2014/01/13 21:54:33 UTC

Handling FailedToCreateProducerException

I have a route which sends a request to a MOM endpoint. Something like:

      from("direct:serviceRequest").beanRef("serviceName", "methodName").
            to("momComponent:" + momServiceDefinitionName).
            beanRef("serviceName", "methodName");

This route works when the "mom endpoint" is up. However, if the mom endpoint
is down, I see:
*Exception in thread "main"
org.apache.camel.FailedToCreateProducerException: Failed to create Producer
for endpoint:
*

Is there a way to use one of the error handlers to catch
"FailedToCreateProducerException"? If the mom endpoint is down, I want camel
to start so that I can use another route to send out email alert that the
service isn't working because the mom endpoint is down. 

Thanks.



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

Re: Handling FailedToCreateProducerException

Posted by ninadmnaik <nn...@gmail.com>.
This won't work. This will work when camel context is successfully
initialized. As I mentioned in my post, I see a
org.apache.camel.FailedToCreateProducerException. This prevents camel
startup. 



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

Re: Handling FailedToCreateProducerException

Posted by Sanjay Bhattacharya <sa...@gmail.com>.
You can have an exception handling block inside the camelcontext like so:

         <onException>
            <exception>xxx.xxx.FailedToCreateProducerException</exception>
            <handled>
                <constant>true</constant>
            </handled>
            <to uri="bean:mailBean?method=prepareEmail"/>
            <to uri="smtp://user@host"/>
        </onException>

The equivalent Java DSL would be:
onException(FailedToCreateProducerException.class)
                .handled(true)
                .bean(MailBean.class, "prepareEmail")
                .to("smtp://user@host");

Thanks,
Sanjay



On Tue, Jan 14, 2014 at 2:24 AM, ninadmnaik <nn...@gmail.com> wrote:

> I have a route which sends a request to a MOM endpoint. Something like:
>
>       from("direct:serviceRequest").beanRef("serviceName", "methodName").
>             to("momComponent:" + momServiceDefinitionName).
>             beanRef("serviceName", "methodName");
>
> This route works when the "mom endpoint" is up. However, if the mom
> endpoint
> is down, I see:
> *Exception in thread "main"
> org.apache.camel.FailedToCreateProducerException: Failed to create Producer
> for endpoint:
> *
>
> Is there a way to use one of the error handlers to catch
> "FailedToCreateProducerException"? If the mom endpoint is down, I want
> camel
> to start so that I can use another route to send out email alert that the
> service isn't working because the mom endpoint is down.
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Handling-FailedToCreateProducerException-tp5745910.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>