Search in sources :

Example 6 with FailedToCreateConsumerException

use of org.apache.camel.FailedToCreateConsumerException in project camel by apache.

the class JmsTestConnectionOnStartupTest method testConnectionOnStartupConsumerTest.

@Test
public void testConnectionOnStartupConsumerTest() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("activemq:queue:foo?testConnectionOnStartup=true").to("mock:foo");
        }
    });
    try {
        context.start();
        fail("Should have thrown an exception");
    } catch (FailedToCreateConsumerException e) {
        assertEquals("Failed to create Consumer for endpoint: activemq://queue:foo?testConnectionOnStartup=true. " + "Reason: Cannot get JMS Connection on startup for destination foo", e.getMessage());
    }
}
Also used : FailedToCreateConsumerException(org.apache.camel.FailedToCreateConsumerException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateConsumerException(org.apache.camel.FailedToCreateConsumerException) FailedToCreateProducerException(org.apache.camel.FailedToCreateProducerException) Test(org.junit.Test)

Example 7 with FailedToCreateConsumerException

use of org.apache.camel.FailedToCreateConsumerException in project camel by apache.

the class EmptyConsumerCache method acquirePollingConsumer.

@Override
public PollingConsumer acquirePollingConsumer(Endpoint endpoint) {
    // always create a new consumer
    PollingConsumer answer;
    try {
        answer = endpoint.createPollingConsumer();
        boolean singleton = true;
        if (answer instanceof IsSingleton) {
            singleton = ((IsSingleton) answer).isSingleton();
        }
        if (getCamelContext().isStartingRoutes() && singleton) {
            // if we are currently starting a route, then add as service and enlist in JMX
            // - but do not enlist non-singletons in JMX
            // - note addService will also start the service
            getCamelContext().addService(answer);
        } else {
            // must then start service so producer is ready to be used
            ServiceHelper.startService(answer);
        }
    } catch (Exception e) {
        throw new FailedToCreateConsumerException(endpoint, e);
    }
    return answer;
}
Also used : PollingConsumer(org.apache.camel.PollingConsumer) FailedToCreateConsumerException(org.apache.camel.FailedToCreateConsumerException) IsSingleton(org.apache.camel.IsSingleton) FailedToCreateConsumerException(org.apache.camel.FailedToCreateConsumerException)

Aggregations

FailedToCreateConsumerException (org.apache.camel.FailedToCreateConsumerException)7 Endpoint (org.apache.camel.Endpoint)2 IsSingleton (org.apache.camel.IsSingleton)2 PollingConsumer (org.apache.camel.PollingConsumer)2 BeanProcessor (org.apache.camel.component.bean.BeanProcessor)2 IOException (java.io.IOException)1 CreationException (javax.enterprise.inject.CreationException)1 UnsatisfiedResolutionException (javax.enterprise.inject.UnsatisfiedResolutionException)1 Connection (javax.jms.Connection)1 CamelContext (org.apache.camel.CamelContext)1 Consumer (org.apache.camel.Consumer)1 FailedToCreateProducerException (org.apache.camel.FailedToCreateProducerException)1 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)1 RuntimeCamelException (org.apache.camel.RuntimeCamelException)1 ServicePoolAware (org.apache.camel.ServicePoolAware)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 CamelContextHelper.getMandatoryEndpoint (org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint)1 Test (org.junit.Test)1 BeansException (org.springframework.beans.BeansException)1