Apache camel developers cookbook

424 55 0
Apache camel developers cookbook

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

www.it-ebooks.info Apache Camel Developer's Cookbook Solve common integration tasks with over 100 easily accessible Apache Camel recipes Scott Cranton Jakub Korab BIRMINGHAM - MUMBAI www.it-ebooks.info Apache Camel Developer's Cookbook Copyright © 2013 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: December 2013 Production Reference: 1181213 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-78217-030-3 www.packtpub.com Cover Image by VisitRenoTahoe.com and Reno-Sparks Convention and Visitors Authority (RSCVA) www.it-ebooks.info Credits Authors Scott Cranton Project Coordinator Anugya Khurana Jakub Korab Proofreaders Reviewers Bilgin Ibryam Simran Bhogal Maria Gould Claus Ibsen Christian Posta Phil Wilkins Acquisition Editors Saleem Ahmed Sam Wood Lead Technical Editor Ankita Shashi Technical Editors Dipika Gaonkar Pramod Kumavat Indexers Hemangini Bari Tejal R Soni Graphics Ronak Dhruv Abhinash Sahu Production Coordinator Arvindkumar Gupta Cover Work Arvindkumar Gupta Tarunveer Shetty www.it-ebooks.info About the Authors Scott Cranton is an open source software contributor and evangelist He has been working with Apache Camel since the release of version 1.5 almost years ago, and has over 20 years of commercial experience in middleware software as a developer, architect, and consultant During his time at FuseSource, and now Red Hat, he has worked closely with many core committers for Apache Camel, ActiveMQ, ServiceMix, Karaf, and CXF He has also helped many companies successfully create and deploy large and complex integration and messaging systems using Camel and other open source projects He divides his professional time between hacking code, delivering webinars on using Camel and open source, and helping companies to learn how to use Camel to solve their integration problems I want to thank my amazing wife, Mary Elizabeth, for putting up with me these many years, and always answering the phone when I'd call late at night from the office while I've got a compile going This book would not have been possible without her always being there for me no matter what To my three wonderful children, Gilbert, Eliza, and Lucy, who always make me smile especially during crazy weekend writing sessions when they'd want me to take a break, "… but Dad, it's the weekend…" I love you all! www.it-ebooks.info Jakub Korab is a consulting software engineer specializing in integration and messaging With a formal background in software engineering and distributed systems, in the 14 years that he has worked in software across the telecoms, financial services, and banking industries, he naturally gravitated from web development towards systems integration When he discovered Apache Camel, it became apparent to him how much time and effort it could have saved him in the past compared to writing bespoke integration code, and he has not looked back since Over the years, working as a consultant, he has helped dozens of clients build scalable, fault-tolerant, and performant systems integrations He currently runs his own specialist consultancy, Ameliant, which focuses on systems integration and messaging using a stack of integration products from the Apache Software Foundation, of which Camel is a corner stone When not gluing systems together, you will find him spending time with his young family, and far too infrequently kitesurfing or skiing—neither of which he gets much chance to in his adopted home, London The writing of this book has taken place against the background of starting a new company, a huge amount of work travel, a quickly growing baby, house move, and hundreds of little distractions that get in the way of sitting down in what is left of the day to put pen to paper It could never have happened without the love, support, and understanding of my wife, Anne-Marie It has been a team effort Thank you Also to my little girl, Alex, for helping me keep it all in perspective www.it-ebooks.info Acknowledgments We would like to thank the Apache Camel community for being so awesome Very welcoming and vibrant, they have always been willing to answer questions and accept code contributions Big thanks to the many, many Camel community members We would like to also thank all the reviewers, editors, and unseen people in the background Getting a book out is a substantial project of which the writing is only one part, and it could not have happened without you Thanks to Rob Davies, Claus Ibsen, and the whole Fuse team for showing us how much fun open source is by always being there to answer questions, geek out about some new project, and drinking beer on those rare occasions when we could get together It's been a real pleasure working with you all, and we hope it continues for a long time Special thanks to James Strachan for being so James; your infectious enthusiasm and love of writing code makes you truly inspirational to all those who meet you We hope to keep playing with you on any and all of your latest new projects www.it-ebooks.info About the Reviewers Bilgin Ibryam is a software engineer with master's degree in Computer Science and he currently works for Red Hat as Middleware Consultant His passions include distributed applications, message-oriented middleware, and application integration He is the author of a book about Apache Camel and Enterprise Integration Patterns called Instant Apache Camel Message Routing He is also heavily involved with open source and is a committer to Apache OFBiz, and other Apache Camel projects In his spare time, he enjoys contributing to open source projects and blogging at http://ofbizian.com He can be contacted via his Twitter handle @bibryam Claus Ibsen has worked as a software engineer, architect, and consultant for more than 15 years For the past five years he has been working full time as an open source developer at FuseSource and Red Hat in the middleware team, on the Fuse products He has worked extensively on the Apache Camel project for over six years, being the top contributor, and has given talks at conferences about integration using Apache Camel He is author of Camel in Action, Manning Publications, 2011 I would like to congratulate Scott and Jakub for stepping up and writing this fantastic book It is great to see the Camel community grow from strength to strength This book will help new users to become more successful with "riding" Apache Camel, and experienced users can find valuable information from many of its recipes www.it-ebooks.info Christian Posta is based in Phoenix, AZ, and is a Principal Consultant and Architect He specializes in messaging-based enterprise integrations with high scalability and throughput demands He has been in development for over 10 years covering a wide range of domains; from embedded systems to UI and UX design and lots of integration in between He's passionate about software development, loves solving tough technical problems, and enjoys learning new languages and programing paradigms His favorite languages are Python and Scala, but he spends a lot of time writing Java too He is a committer on Apache Camel, Apache ActiveMQ, and Apache Apollo projects as well as PMC on ActiveMQ He blogs about Camel, ActiveMQ, and integration at http://www.christianposta.com/blog as well as tweets about interesting technology on his Twitter handle @christianposta Thanks to Scott and Jakub for asking me to review the book I think this work is the ultimate complement to the other Camel book The material cuts right to the chase and shows you how to accomplish otherwise challenging integrations using this wonderful library Phil Wilkins has spent nearly 25 years in the software industry working with both multinationals and software startups He started out as a developer and has worked his way up through technical and development management roles The last 12 years have been primarily in Java-based environments He now works as an enterprise technical architect within the IT group for a global optical healthcare manufacturer and retailer Outside of his work commitments, he has contributed his technical capabilities to supporting others in a wide range of activities from the development of community websites to providing input and support to people authoring books, and developing software ideas and businesses When not immersed in work and technology, he spends his free time pursuing his passion for music and time with his wife and two boys I'd like to take this opportunity to thank my wife Catherine and our two sons Christopher and Aaron for their tolerance for the innumerable hours that I've spent in front of a computer contributing to both my employer and the many other IT related activities that I've supported over the years www.it-ebooks.info www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy Get in touch with us at service@ packtpub.com for more details At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library Here, you can access, read and search across Packt's entire library of books Why Subscribe? ff Fully searchable across every book published by Packt ff Copy and paste, print and bookmark content ff On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books Simply use your login credentials for immediate access Instant Updates on New Packt Books Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page www.it-ebooks.info .. .Apache Camel Developer's Cookbook Solve common integration tasks with over 100 easily accessible Apache Camel recipes Scott Cranton Jakub Korab BIRMINGHAM - MUMBAI www.it-ebooks.info Apache Camel. .. The Apache Camel website (http:/ /camel .apache. org) is the authoritative site on Camel, with a long list of articles and documentation that will help you on your journey of using Camel What is Camel? ... about Apache Camel and Enterprise Integration Patterns called Instant Apache Camel Message Routing He is also heavily involved with open source and is a committer to Apache OFBiz, and other Apache

Ngày đăng: 12/03/2019, 15:34

Từ khóa liên quan

Mục lục

  • Cover

  • Copyright

  • Credits

  • About the Authors

  • Acknowledgments

  • About the Reviewers

  • www.PacktPub.com

  • Table of Contents

  • Preface

  • Chapter 1: Structuring Routes

    • Introduction

    • Using Camel in a Java application

    • Embedding Camel in a Spring application

    • Using Camel components

    • Reusing routing logic by connecting routes

    • Asynchronously connecting routes

    • Spanning Camel contexts within a single Java process

    • Using external properties in Camel routes

    • Reusing endpoints

    • Reusing routing logic through template routes

    • Controlling route startup and shutdown

  • Chapter 2: Message Routing

    • Introduction

    • Content Based Routing

    • Filtering out unwanted messages

    • Wire Tap – sending a copy of the message elsewhere

    • Multicast – routing the same message to many endpoints

    • Recipient List – routing a message to a list of endpoints

    • Throttler – restricting the number of messages flowing to an endpoint

    • Request-response route sending a one-way message

    • One-way route waiting on a request-response endpoint

    • Dynamic Routing – making routing decisions at runtime

    • Load balancing across a number of endpoints

    • Routing Slip – routing a message to a fixed list of endpoints

  • Chapter 3: Routing to your Code

    • Introduction

    • Routing messages directly to a Java method

    • Sending messages directly to a Camel endpoint

    • Using a Java method as a Predicate

    • Writing a custom Camel Processor

    • Mapping the message to method parameters

    • Writing a custom data marshaller

    • Writing a custom data type converter

  • Chapter 4: Transformation

    • Introduction

    • Transforming using a Simple Expression

    • Transforming inline with XQuery

    • Transforming with XSLT

    • Transforming from Java to XML with JAXB

    • Transforming from Java to JSON

    • Transforming from XML to JSON

    • Parsing comma-separated values (CSV)

    • Enriching your content with some help from other endpoints

    • Normalizing messages into a common XML format

  • Chapter 5: Splitting and Aggregating

    • Introduction

    • Splitting a message into fragments

    • Splitting XML messages

    • Processing split messages in parallel

    • Aggregating related messages

    • Aggregating with timeouts

    • Aggregating with intervals

    • Processing aggregated messages in parallel

    • Splitting a message, and processing and gathering responses

    • Splitting messages and re-aggregating them using different criteria

  • Chapter 6: Parallel Processing

    • Introduction

    • Increasing message consumption through multiple endpoint consumers

    • Spreading the load within a route using a set of threads

    • Routing a request asynchronously

    • Using custom thread pools

    • Using thread pool profiles

    • Working with asynchronous APIs

  • Chapter 7: Error Handling and Compensation

    • Introduction

    • Logging errors

    • Dead Letter Channel – handling errors later

    • Retrying an operation

    • Conditional retry

    • Customizing each redelivery attempt

    • Catching exceptions

    • Marking exceptions as handled

    • Fine-grained error handling using doTry…doCatch

    • Defining completion actions

    • Defining completion actions dynamically

  • Chapter 8: Transactions and Idempotency

    • Introduction

    • Preventing duplicate invocation of routing logic

    • Transactional file consumption

    • Using transactions with a database

    • Limiting the scope of a transaction

    • Rolling back a transaction

    • Using transactions with messaging

    • Idempotency inside transactions

    • Setting up XA transactions over multiple transactional resources

  • Chapter 9: Testing

    • Introduction

    • Testing routes defined in Java

    • Using mock endpoints to verify routing logic

    • Replying from mock endpoints

    • Testing routes defined in Spring

    • Testing routes defined in OSGi Blueprint

    • Auto-mocking of endpoints

    • Validating route behavior under heavy load

    • Unit testing processors and Bean Bindings

    • Testing routes with fixed endpoints using AOP

    • Testing routes with fixed endpoints using conditional events

  • Chapter 10: Monitoring and Debugging

    • Introduction

    • Logging meaningful steps within your route

    • Debugging using logging

    • Throughput logging

    • Enabling step-by-step tracing in code

    • Disabling JMX

    • Configuring JMX

    • Naming your routes to make it easier to monitor

    • Adding JMX attributes and operations

    • Monitoring other systems using the Camel JMX Component

    • Setting breakpoints in your routes

  • Chapter 11: Security

    • Introduction

    • Encrypting configuration properties

    • Digitally signing and verifying messages

    • Encrypting and decrypting a message

    • Encrypting all or parts of an XML message

    • Authentication and authorization using Spring Security

  • Chapter 12: Web Services

    • Introduction

    • Generating the service stubs from a WSDL

    • Invoking a remote web service from Camel

    • Implementing a web service with a Camel route

    • Providing multiple web service operations within a single route

    • Handling web service faults

    • Web service proxying

  • Index

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan