0
点赞
收藏
分享

微信扫一扫

camel in action

Star英 2023-06-30 阅读 62

FIRST STEPS. .......................................................1 

 1 Meeting Camel 3 

 1.1 Introducing Camel 4 

 What is Camel? 4 ■ Why use Camel? 5 ■ Getting 

 started 8 ■ Getting Camel 8 ■ Your first Camel ride 9 

 1.2 Camel’s message model 13 

 Message 13 ■ Exchange 14 

 1.3 Camel’s architecture 15 

 Architecture from 10,000 feet 15 ■ Camel concepts 16 

 1.4 Your first Camel ride, revisited 20 

 1.5 Summary 21 

 x CONTENTS 

 2 Routing with Camel 22 

 2.1 Introducing Rider Auto Parts 23 

 2.2 Understanding endpoints 24 

 Working with files over FTP 24 ■ Sending to a JMS queue 26 

 2.3 Creating routes in Java 28 

 Using the RouteBuilder 29 ■ The Java DSL 30 

 2.4 Creating routes with Spring 34 

 Bean injection and Spring 34 ■ The Spring DSL 37 ■ Using 

 Camel and Spring 40 

 2.5 Routing and EIPs 43 

 Using a content-based router 44 ■ Using message filters 49 

 Using multicasting 50 ■ Using recipient lists 52 ■ Using the 

 wireTap method 55 

 2.6 Summary and best practices 57 

 PART 2 CORE CAMEL ....................................................59 

 3 Transforming data with Camel 61 

 3.1 Data transformation overview 62 

 Data transformation with Camel 62 

 3.2 Transforming data using EIPs and Java 63 

 Using the Message Translator EIP 63 ■ Using the Content 

 Enricher EIP 70 

 3.3 Transforming XML 73 

 Transforming XML with XSLT 73 ■ Transforming XML with 

 object marshaling 75 

 3.4 Transforming with data formats 77 

 Data formats provided with Camel 78 ■ Using Camel’s CSV data 

 format 79 ■ Using Camel’s Bindy data format 80 ■ Using 

 Camel’s JSON data format 83 ■ Configuring Camel data 

 formats 84 ■ Writing your own data format 85 

 3.5 Transforming with templates 86 

 Using Apache Velocity 87 

 3.6 About Camel type converters 88 

 How the Camel type-converter mechanism works 88 ■ Using Camel 

 type converters 90 ■ Writing your own type converter 90 

 3.7 Summary and best practices 92 

 CONTENTS xi 

 4 Using beans with Camel 93 

 4.1 Using beans the hard way and the easy way 94 

 Invoking a bean from pure Java 94 ■ Invoking a bean defined in 

 Spring 95 ■ Using beans the easy way 96 

 4.2 The Service Activator pattern 97 

 4.3 Camel’s bean registries 98 

 SimpleRegistry 100 ■ JndiRegistry 101 ■ ApplicationContext- 

 Registry 101 ■ OsgiServiceRegistry 102 

 4.4 Selecting bean methods 103 

 How Camel selects bean methods 104 ■ Camel’s method-selection 

 algorithm 105 ■ Some method-selection examples 107 

 Potential method-selection problems 109 

 4.5 Bean parameter binding 111 

 Binding with multiple parameters 112 ■ Binding using built-in 

 types 113 ■ Binding using Camel annotations 114 ■ Binding 

 using Camel language annotations 115 

 4.6 Summary and best practices 119 

 5 Error handling 120 

 5.1 Understanding error handling 121 

 Recoverable and irrecoverable errors 121 ■ Where Camel’s error 

 handling applies 123 

 5.2 Error handlers in Camel 124 

 The default error handler 125 ■ The dead letter channel error 

 handler 126 ■ The transaction error handler 128 ■ The no error 

 handler 128 ■ The logging error handler 128 ■ Features of the 

 error handlers 128 

 5.3 Using error handlers with redelivery 129 

 An error-handling use case 129 ■ Using redelivery 130 ■ Error 

 handlers and scopes 135 ■ Handling faults 137 

 5.4 Using exception policies 138 

 Understanding how onException catches exceptions 139 ■ Understanding 

 how onException works with redelivery 142 ■ Understanding how 

 onException can handle exceptions 143 ■ Custom exception 

 handling 146 ■ Ignoring exceptions 148 ■ Implementing an error 

 handler solution 149 

 5.5 Other error-handling features 150 

 Using onWhen 150 ■ Using onRedeliver 151 ■ Using 

 retryWhile 152 

 5.6 Summary and best practices 153 

 xii CONTENTS 

 6 Testing with Camel 154 

 6.1 Introducing the Camel Test Kit 155 

 The Camel JUnit extensions 155 ■ Using the Camel Test Kit 156 

 Unit testing with the CamelTestSupport class 156 ■ Unit testing an 

 existing RouteBuilder class 159 ■ Unit testing with the SpringCamel- 

 TestSupport class 159 ■ Unit testing in multiple environments 161 

 6.2 Using the Mock component 166 

 Introducing the Mock component 167 ■ Unit testing with the Mock 

 component 167 ■ Verifying that the correct message arrived 169 

 Using expressions with mocks 170 ■ Testing the ordering of 

 messages 174 ■ Using mocks to simulate real components 175 

 6.3 Simulating errors 178 

 Simulating errors using a processor 178 ■ Simulating errors using 

 mocks 180 ■ Simulating errors using interceptors 180 

 6.4 Testing without mocks 183 

 Integration testing 183 ■ Using NotifyBuilder 185 

 6.5 Summary and best practices 187 

 7 Understanding components 188 

 7.1 Overview of Camel components 189 

 Manually adding components 190 ■ Autodiscovering components 190 

 7.2 Working with files (File and FTP components) 192 

 Reading and writing files with the File component 193 ■ Accessing remote 

 files with the FTP component 196 

 7.3 Asynchronous messaging (JMS component) 197 

 Sending and receiving messages 200 ■ Request-reply 

 messaging 201 ■ Message mappings 202 

 7.4 Web services (CXF component) 205 

 Configuring CXF 206 ■ Using a contract-first approach 209 

 Using a code-first approach 215 

 7.5 Networking (MINA component) 216 

 Using MINA for network programming 217 ■ Using custom codecs 219 

 7.6 Working with databases (JDBC and JPA components) 221 

 Accessing data with the JDBC component 221 ■ Persisting objects with the 

 JPA component 224 

 7.7 In-memory messaging (Direct, SEDA, and VM 

 components) 229 

 Synchronous messaging with the Direct component 229 

 Asynchronous messaging with SEDA and VM 230 

 CONTENTS xiii 

 7.8 Automating tasks (Timer and Quartz components) 232 

 Using the Timer component 232 ■ Enterprise scheduling with 

 Quartz 233 

 7.9 Summary and best practices 235 

 8 Enterprise integration patterns 237 

 8.1 Introducing enterprise integration patterns 238 

 The Aggregator and Splitter EIPs 238 ■ The Routing Slip and 

 Dynamic Router EIPs 239 ■ The Load Balancer EIP 239 

 8.2 The Aggregator EIP 239 

 Introducing the Aggregator EIP 240 ■ Completion conditions for 

 the Aggregator 243 ■ Using persistence with the Aggregator 248 

 Using recovery with the Aggregator 251 

 8.3 The Splitter EIP 255 

 Using the Splitter 256 ■ Using beans for splitting 258 ■ Splitting 

 big messages 260 ■ Aggregating split messages 262 ■ When errors 

 occur during splitting 264 

 8.4 The Routing Slip EIP 266 

 Using the Routing Slip EIP 267 ■ Using a bean to compute the 

 routing slip header 267 ■ Using an Expression as the routing 

 slip 268 ■ Using @RoutingSlip annotation 269 

 8.5 The Dynamic Router EIP 270 

 Using the Dynamic Router 270 ■ Using the @DynamicRouter 

 annotation 271 

 8.6 The Load Balancer EIP 272 

 Introducing the Load Balancer EIP 272 ■ Load-balancing 

 strategies 274 ■ Using the failover load balancer 275 ■ Using a 

 custom load balancer 278 

 8.7 Summary and best practices 280 

 PART 3 OUT IN THE WILD ............................................281 

 9 Using transactions 283 

 9.1 Why use transactions? 284 

 The Rider Auto Parts partner integration application 284 ■ Setting 

 up the JMS broker and the database 287 ■ The story of the lost 

 message 288 

 9.2 Transaction basics 289 

 About Spring’s transaction support 290 ■ Adding 

 transactions 291 ■ Testing transactions 293 

 xiv CONTENTS 

 9.3 The Transactional Client EIP 296 

 Using local transactions 297 ■ Using global transactions 298 

 9.4 Configuring and using transactions 301 

 Configuring transactions 301 ■ Using transactions with multiple 

 routes 303 ■ Returning a custom response when a transaction 

 fails 306 

 9.5 Compensating for unsupported transactions 309 

 Introducing UnitOfWork 309 ■ Using Synchronization 

 callbacks 310 ■ Using onCompletion 312 

 9.6 Summary and best practices 313 

 10 Concurrency and scalability 315 

 10.1 Introducing concurrency 316 

 Running the example without concurrency 318 ■ Using 

 concurrency 318 

 10.2 Using thread pools 323 

 Understanding thread pools in Java 323 ■ Camel thread pool 

 profiles 326 ■ Creating custom thread pools 328 ■ Using 

 ExecutorServiceStrategy 329 

 10.3 Using concurrency with EIPs 330 

 Using concurrency with the Threads EIP 331 ■ Using concurrency 

 with the Multicast EIP 332 ■ Using concurrency with the Wire 

 Tap EIP 334 

 10.4 Synchronicity and threading 335 

 Asynchronous caller using one thread 336 ■ Synchronous caller 

 using one thread 337 ■ Asynchronous caller using multiple 

 threads 339 ■ Synchronous caller using multiple threads 340 

 Returning an early reply to a caller 342 

 10.5 The concurrency client API 344 

 The concurrency client API in Java 344 ■ The concurrency client 

 API in Camel 347 

 10.6 The asynchronous routing engine 350 

 Hitting the scalability limit 350 ■ Scalability in Camel 352 

 Components supporting asynchronous processing 353 

 Asynchronous API 354 ■ Writing a custom asynchronous 

 component 356 

 10.7 Summary and best practices 358 

 CONTENTS xv 

 11 Developing Camel projects 359 

 11.1 Managing projects with Maven 360 

 Using Camel Maven archetypes 360 ■ Camel Maven 

 dependencies 364 ■ Using Camel in Eclipse 366 ■ Using the 

 Maven Eclipse plugin 366 ■ Using the m2eclipse plugin 368 

 11.2 Developing custom components 371 

 Setting up a new Camel component 371 ■ Diving into the 

 implementation 373 

 11.3 Developing interceptors 377 

 Creating an InterceptStrategy 377 

 11.4 Using alternative languages 380 

 The Scala DSL 380 ■ Adding Scala routes to the CamelContext 382 

 Mixing Java and Scala 382 

 11.5 Summary and best practices 384 

 12 Management and monitoring 385 

 12.1 Monitoring Camel 386 

 Checking health at the network level 386 ■ Checking health at the 

 JVM level 388 ■ Checking health at the application level 388 

 12.2 Using JMX with Camel 389 

 Using JConsole to manage Camel 390 ■ Using JConsole to remotely 

 manage Camel 391 

 12.3 Tracking application activity 393 

 Using log files 393 ■ Using core logs 394 ■ Using custom 

 logging 394 ■ Using Tracer 398 ■ Using notifications 402 

 12.4 Managing Camel applications 405 

 Managing Camel application lifecycles 405 ■ Managing custom 

 Camel components 406 

 12.5 Summary and best practices 409 

 13 Running and deploying Camel 410 

 13.1 Starting Camel 411 

 How Camel starts 411 ■ Camel startup options 413 ■ Ordering 

 routes 416 ■ Disabling autostartup 418 

 13.2 Starting and stopping routes at runtime 419 

 Using CamelContext to start and stop routes at runtime 420 

 Using RoutePolicy to start and stop routes at runtime 422 

 xvi CONTENTS 

 13.3 Shutting down Camel 424 

 Graceful shutdown 425 

 13.4 Deploying Camel 428 

 Embedded in a Java application 428 ■ Embedded in a web 

 application 430 ■ Embedded in JBoss Application Server 436 

 13.5 Camel and OSGi 437 

 Setting up Maven to generate an OSGi bundle 438 ■ Installing 

 and running Apache Karaf 439 ■ Deploying the example 440 

 13.6 Summary and best practices 441 

 14 Bean routing and remoting 443 

 14.1 Using beans for routing 444 

 Inventory update at Rider Auto Parts 444 ■ Receiving messages 

 with @Consume 445 ■ Sending messages with @Produce 448 

 When to use beans for routing 450 

 14.2 Hiding middleware 451 

 Introducing the starter kit 453 ■ Using Spring remoting and 

 Camel proxies 456 

 14.3 Summary and best practices 460 

 appendix A Simple, the expression language 461 

 appendix B Expressions and predicates 471 

 appendix C The producer and consumer templates 477 

 appendix D The Camel community 483 

 appendix E Akka and Camel 487 

 index 501 

 xvii

举报

相关推荐

0 条评论