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());
}
}
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;
}
Aggregations