Chapter 1. Meeting Camel
Listing 1.1. Routing files from one folder to another in plain Java
Listing 1.2. Routing files from one folder to another with Apache Camel
Listing 1.3. The Maven POM required to use Camel’s core library
Listing 1.4. Routing files from one folder to another with Apache Camel
Chapter 2. Routing with Camel
Listing 2.1. Polling for FTP messages and sending them to the incomingOrders queue
Listing 2.2. A Spring configuration that produces the same results as listing 2.1
Listing 2.3. A Spring DSL example that produces the same results as listing 2.1
Chapter 3. Transforming data with Camel
Listing 3.1. Using a Processor to translate from a custom format to CSV format
Listing 3.2. Using a bean to translate from a custom format to CSV format
Listing 3.3. Using pollEnrich to merge additional data with an existing message
Listing 3.4. Using XStream to transform a message into XML
Listing 3.5. Annotating a bean with JAXB so it can be transformed to and from XML
Listing 3.6. Using JAXB to serialize objects to and from XML
Listing 3.7. Model object annotated for CSV transformation
Listing 3.8. Using Bindy to transform a model object to CSV format
Listing 3.9. An HTTP service that returns order summaries rendered in JSON format
Listing 3.10. Configuring the CSV data format
Listing 3.11. Developing a custom data format that can reverse strings
Listing 3.12. A custom type converter to convert from byte[] to PurchaseOrder type
Chapter 4. Using beans with Camel
Listing 4.1. Using a Processor to invoke the hello method on the HelloBean
Listing 4.2. Setting up Spring to use a Camel route that uses the HelloBean
Listing 4.3. A Camel route using a Processor to invoke HelloBean
Listing 4.4. Using SimpleRegistry to unit test a Camel route
Listing 4.5. A service that stamps an order ID on an XML document
Chapter 5. Error handling
Listing 5.1. Using two error handlers at different scopes
Listing 5.2. Using error handling with Spring XML
Listing 5.3. Using doTry ... doCatch with Camel routing
Listing 5.4. Using onException in context scope
Listing 5.5. Spring XML revision of listing 5.4
Listing 5.6. Using a processor to create a failure response to be returned to the caller
Listing 5.7. Using continued to ignore ValidationExceptions
Listing 5.8. Route using error handling with failover to FTP
Listing 5.9. A helper to determine whether an HTTP error 500 occurred
Listing 5.10. Skeleton code to illustrate principle of using retryWhile
Chapter 6. Testing with Camel
Listing 6.1. A first unit test using the Camel Test Kit
Listing 6.2. A Spring-based version of the route in listing 6.1 (firststep.xml)
Listing 6.3. A first unit test using Spring XML routes
Listing 6.4. A reusable unit test for the test and production environments
Listing 6.5. Using the Camel Properties component with the Java DSL
Listing 6.6. Using MockEndpoint in unit testing
Listing 6.7. Using expressions with MockEndpoint to set expectations
Listing 6.8. Using a custom expression to detect gaps in message ordering
Listing 6.9. Simulating a real component by using a mock endpoint
Listing 6.10. Route using error handling with a failover to FTP
Listing 6.11. Simulating an error by throwing an exception from the mock endpoint
Chapter 7. Understanding components
Listing 7.1. Topics allow multiple receivers to get a copy of the message
Listing 7.2. The CXF endpoint bean format
Listing 7.3. The WSDL for an order service
Listing 7.4. Using CXF’s wsdl2java tool
Listing 7.5. CXF endpoint configuration in camel-cxf.xml
Listing 7.6. Web-enabled route configuration
Listing 7.7. The decoder for the welder sensor
Listing 7.8. A bean that converts an incoming order to an SQL statement
Listing 7.9. An annotated POJO representing an incoming order
Listing 7.10. Hooking up the Camel JPA component to OpenJPA
Listing 7.11. Configuring the ORM tool with the persistence.xml file
Listing 7.12. A topic allows multiple receivers to get a copy of the message
Chapter 8. Enterprise integration patterns
Listing 8.1. AggregationStrategy for merging messages together
Listing 8.2. Using HawtDB with Aggregator in Java DSL
Listing 8.3. Using HawtDB with Aggregator in Spring XML
Listing 8.4. A basic example of the Splitter EIP
Listing 8.5. Splitting big files using streaming mode
Listing 8.6. Splitting big files using streaming mode in Spring XML
Listing 8.7. Combining split messages back into a single outgoing message
Listing 8.8. Handling an exception by ignoring it
Listing 8.9. Propagating back an exception
Listing 8.10. Java bean deciding where the message should be routed next
Chapter 9. Using transactions
Listing 9.1. Using a bean to map from XML to SQL
Listing 9.2. XML configuration for the Camel route, JMS broker, and database
Listing 9.3. Simulating a connection failure that causes lost messages
Listing 9.4. XML configuration using Spring transactions
Listing 9.5. Testing a simulated rollback on the first try and a commit on the second try
Listing 9.6. Unit test with a transacted route calling a non-transacted route
Chapter 10. Concurrency and scalability
Listing 10.1. Rider Auto Parts application for updating inventory
Listing 10.2. Rider Auto Parts inventory-update application using SEDA
Listing 10.3. Using ExecutorServiceStrategy to create a thread pool
Listing 10.4. Asynchronous task execution using the Java API
Listing 10.5. Using a callback to gather replies asynchronously
Listing 10.6. ErpProducer using the asynchronous processing model
Chapter 11. Developing Camel projects
Listing 11.1. Layout of the project created by camel-archetype-java
Listing 11.2. Layout of a project created by camel-archetype-component
Listing 11.3. Custom Camel endpoint—MyEndpoint
Listing 11.4. Custom Camel producer—MyProducer
Listing 11.5. Custom Camel consumer—MyConsumer
Listing 11.6. A custom interceptor
Listing 11.7. Configuring compilation of both Java and Scala sources
Chapter 12. Management and monitoring
Listing 12.1. A custom event notifier publishes failure events to a central log database
Chapter 13. Running and deploying Camel
Listing 13.1. Starting routes in a specific order
Listing 13.2. Spring XML version of listing 13.1
Listing 13.3. After a file has been processed, the route is stopped
Listing 13.4. A RoutePolicy that flips two routes being active at runtime
Listing 13.5. Bootstrapping Camel in your Java application
Listing 13.6. The Spring applicationContext.xml file with Camel embedded
Listing 13.7. The web.xml file with CXFServlet to tap into Apache Tomcat
Listing 13.8. Setting up the Camel CXF component to tap into Apache Tomcat
Chapter 14. Bean routing and remoting
Listing 14.1. A Java class that can update the inventory database
Listing 14.2. InventoryUpdater class connected to JMS queue by @Consume
Listing 14.3. Using the @Produce annotation to set up a ProducerTemplate
Listing 14.4. Using the @Produce annotation to set up a producer on an interface
Listing 14.5. Simulating Rider Auto Parts
Appendix A. Simple, the expression language
Listing A.1. Using the Simple language from custom Java code
Appendix B. Expressions and predicates
Listing B.1. Implementing a custom expression
Listing B.2. Implementing custom expression by extending ExpressionAdapter
Appendix C. The producer and consumer templates
Listing C.1. Using a ProducerTemplate to send a message to a JMS topic
Listing C.2. Using a ProducerTemplate to get a reply from an endpoint
Listing C.3. Declaring reusable producer and consumer templates
Appendix E. Akka and Camel
Listing E.1. Actor as consumer receiving messages from a SEDA endpoint
Listing E.2. Actor acting as consumer which sends back replies to sender
Listing E.3. An actor sending back XML messages as reply to sender
Listing E.4. An actor as a producer sending messages to the defined HTTP endpoint
Listing E.5. Spring XML file setting up Akka and Camel