Thông tin tài liệu
www.it-ebooks.info
Camel in Action
www.it-ebooks.info
www.it-ebooks.info
Camel in Action
CLAUS IBSEN
JONATHAN ANSTEY
MANNING
Greenwich
(74° w. long.)
www.it-ebooks.info
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
180 Broad Street, Suite 1323
Stamford, CT 06901
Email: orders@manning.com
©2011 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books are
printed on paper that is at least 15 percent recycled and processed without the use of elemental
chlorine.
Manning Publications Co. Development editor: Cynthia Kane
180 Broad Street, Suite 1323 Copyeditor: Andy Carroll
Stamford, CT 06901 Cover designer: Marija Tudor
Typesetter: Gordan Salinovic
ISBN 978-1-935182-36-8
Printed in the United States of America
12345678910 –MAL –151413121110
www.it-ebooks.info
To the Apache Camel community
May this book be a helpful companion on your journeys with Camel
www.it-ebooks.info
www.it-ebooks.info
vii
brief contents
PART 1 FIRST STEPS . 1
1 ■ Meeting Camel 3
2 ■ Routing with Camel 22
PART 2 CORE CAMEL 59
3 ■ Transforming data with Camel 61
4 ■ Using beans with Camel 93
5 ■ Error handling 120
6 ■ Testing with Camel 154
7 ■ Understanding components 188
8 ■ Enterprise integration patterns 237
PART 3 OUT IN THE WILD 281
9 ■ Using transactions 283
10 ■ Concurrency and scalability 315
11 ■ Developing Camel projects 359
12 ■ Management and monitoring 385
13 ■ Running and deploying Camel 410
14 ■ Bean routing and remoting 443
www.it-ebooks.info
www.it-ebooks.info
ix
contents
foreword xvii
foreword xix
preface xxi
acknowledgments xxiii
about this book xxv
about the cover illustration xxix
about the authors xxxi
PART 1 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
www.it-ebooks.info
[...]... 2 Routing with Camel 22 2.1 2.2 Introducing Rider Auto Parts 23 Understanding endpoints 24 Working with files over FTP 2.3 Creating routes in Java Using the RouteBuilder 2.4 24 28 29 ■ The Java DSL 30 Creating routes with Spring 34 Bean injection and Spring 34 Camel and Spring 40 2.5 Sending to a JMS queue 26 ■ Routing and EIPs The Spring DSL ■ 37 ■ Using 43 Using a content-based router 44 Using message... Transaction basics 289 About Spring’s transaction support 290 Adding transactions 291 Testing transactions 293 ■ ■ www.it-ebooks.info xiv CONTENTS 9.3 The Transactional Client EIP Using local transactions 297 9.4 296 Using global transactions 298 ■ Configuring and using transactions 301 Configuring transactions 301 Using transactions with multiple routes 303 Returning a custom response when a transaction... www.it-ebooks.info 358 xv CONTENTS 11 Developing Camel projects 11.1 359 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 Setting up a new Camel component implementation 373 11.3 Developing interceptors ■ Diving into the 377 Creating... error-handling features Using onWhen 150 retryWhile 152 5.6 ■ ■ 150 Using onRedeliver 151 Summary and best practices www.it-ebooks.info 153 ■ Using 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 SpringCamelTestSupport... OsgiServiceRegistry 102 ■ ■ Selecting bean methods ■ ApplicationContext- 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... marshaling 75 3.4 63 63 73 Transforming with data formats ■ Transforming XML with 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. .. 389 Using JConsole to manage Camel 390 manage Camel 391 12.3 Tracking application activity Using log files logging 394 12.4 ■ Using JConsole to remotely 393 393 Using core logs 394 Using custom Using Tracer 398 Using notifications 402 ■ ■ ■ ■ Managing Camel applications 405 Managing Camel application lifecycles 405 Camel components 406 12.5 13 Summary and best practices ■ Managing custom 409 Running... 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 Using the Dynamic... deploying Camel 410 13.1 Starting Camel 411 How Camel starts 411 Camel startup options routes 416 Disabling autostartup 418 ■ 413 ■ Ordering ■ 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 www.it-ebooks.info xvi CONTENTS 13.3 Shutting down Camel 424 Graceful shutdown 13.4 425 Deploying... Martin Krasser and shows how to use Akka with Camel Who should read this book We wrote this book primarily for developers who have found the online Camel documentation lacking and needed a guidebook that explained things in a more detailed and organized way Although we mainly targeted existing Camel users, Camel in Action www.it-ebooks.info ABOUT THIS BOOK xxvii is a great way to start learning about Camel . parameter binding 111
Binding with multiple parameters 112
■
Binding using built -in
types 113
■
Binding using Camel annotations 114
■
Binding
using Camel.
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
Ngày đăng: 06/03/2014, 15:20
Xem thêm: Camel in Action pdf, Camel in Action pdf, 2 Working with files (File and FTP components), 6 Working with databases (JDBC and JPA components), 7 In-memory messaging (Direct, SEDA, and VM components), 8 Automating tasks (Timer and Quartz components), D.5 JIRA, mailing lists, and IRC