concept case in category camel
appears as: case, cases, case, cases

This is an excerpt from Manning's book Camel in Action.
Figure 7.7 The Circuit Breaker pattern operates in three states. In the closed state (green), the operation is successful. Upon a number of successive failures, the breaker trips into the open state (red) and fails fast. After a short period, the breaker attempts to reset in the half-open state (yellow). If it’s successful, the break resets into a closed state (green), and in case of failure transfers back to an open state (red).
![]()
Listing 9.25 Pax Exam Integration test class with deployment and actual test
@RunWith(PaxExam.class) #1 public class PaxExamIT { @Inject @Filter("(camel.context.name=quotesCamel)") #2 protected CamelContext camelContext; @Configuration #3 public Option[] config() { return new Option[]{ karafDistributionConfiguration() #4 .frameworkUrl(maven().groupId("org.apache.karaf") #4 .artifactId("apache-karaf").version("4.1.2").type("tar.gz")) #4 .karafVersion("4.1.2") #4 .name("Apache Karaf") #4 .useDeployFolder(false) #4 .unpackDirectory(new File("target/karaf")), #4 keepRuntimeFolder(), #5 configureConsole().ignoreRemoteShell(), logLevel(LogLevelOption.LogLevel.WARN), #6 junitBundles(), features(getCamelKarafFeatureUrl(), "camel", "camel-test"), #7 features(getCamelKarafFeatureUrl(), "camel-http4"), #8 features(maven().groupId("com.camelinaction") #9 .artifactId("chapter9-paxexam").version("2.0.0") .classifier("features").type("xml"), "camel-quote") }; } public static UrlReference getCamelKarafFeatureUrl() { return mavenBundle(). groupId("org.apache.camel.karaf").artifactId("apache-camel") .version("2.20.1").classifier("features").type("xml"); } @Test public void testPaxExam() throws Exception { #10 long total = camelContext.getManagedCamelContext().getExchangesTotal(); assertEquals("Should be 0 exchanges completed", 0, total); Thread.sleep(2000); #11 String url = "http4://localhost:8181/camel/say"; ProducerTemplate template = camelContext.createProducerTemplate(); String json = template.requestBody(url, null, String.class); #12 System.out.println("Wiseman says: " + json); total = camelContext.getManagedCamelContext().getExchangesTotal(); assertEquals("Should be 1 exchanges completed", 1, total); } #1 Runs this test with Pax Exam #2 Injects the CamelContext from the application #3 Sets up the deployment unit #4 Configures the Apache Karaf server to use #5 Keeps the runtime folder so we can look there in case of errors #6 Sets the logging level to not be verbose #7 Installs Apache Camel #8 Installs the camel-http4 component we use in this test #9 Installs this example using the Maven coordinates #10 The actual test method that runs inside Karaf container #11 Pax-Exam needs a little delay before really ready #12 Calls the Camel Servlet and prints the response
Around the invocation of the service is the logic that attempts redelivery, in case an error occurs. After five attempts, it gives up and throws the exception.