Open Source ESBs in Action Open Source ESBs in Action EXAMPLE IMPLEMENTATIONS IN MULE AND SERVICEMIX TIJS RADEMAKERS JOS DIRKSEN MANNING Greenwich (74° w. long.) 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. Sound View Court 3B Fax: (609) 877-8256 Greenwich, CT 06830 Email: [email protected] ©2009 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% recycled and processed elemental chlorine-free Development Editor: Jeff Bleil Manning Publications Co. Copyeditors: Liz Welch, Tiffany Taylor Sound View Court 3B Typesetter: Denis Dalinnik Greenwich, CT 06830 Cover designer: Leslie Haimes ISBN: 1933988215 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – MAL – 12 11 10 09 08 brief contents PART 1 UNDERSTANDING ESB FUNCTIONALITY..........................1 1 ■ The world of open source ESBs 3 2 ■ Architecture of Mule and ServiceMix 42 3 ■ Setting up the Mule and ServiceMix environments 72 4 ■ The foundation of an integration solution 111 PART 2 USING ESB CORE FUNCTIONALITIES ..........................153 5 ■ Working with messages 155 6 ■ Connectivity options 194 7 ■ Web services support 243 8 ■ Implementing enterprise-quality message flows 280 PART 3 ESB CASE STUDIES.....................................................317 9 ■ Implementing a case study using patterns 319 10 ■ Managing and monitoring the ESB 358 11 ■ Implementing a process engine in the ESB 393 v contents foreword xiii foreword xvii preface xix acknowledgments xxi about this book xxiii PART 1 UNDERSTANDING ESB FUNCTIONALITY................1 The world of open source ESBs 3 1 1.1 Why do you need an ESB? 4 Benefits of an ESB 5 ■ Using an ESB from an application perspective 8 1.2 Explaining the core functionalities of an ESB 12 Location transparency 13 ■ Transport protocol conversion 14 ■ Message transformation 15 Message routing 16 ■ Message enhancement 17 Security 18 ■ Monitoring and management 19 Core functionality overview 20 1.3 Researching the open source ESB market 21 Demystifying the open source ESB 21 ■ Overview of open source ESBs 23 vii viii CONTENTS 1.4 Why did we choose Mule and ServiceMix? 30 Defining selection criteria 30 ■ Assessing the open source ESBs 31 1.5 Hello world with Mule and ServiceMix 33 Taking a donkey ride with Mule 34 ■ Taking a JBI dive with ServiceMix 37 1.6 Summary 40 Architecture of Mule and ServiceMix 42 2 2.1 Mule architecture and components 43 Mule components overview 43 ■ Mule endpoints 46 Transformers 48 ■ Routers 50 ■ Component 53 Mule deployment models 54 ■ Mule wrap-up 55 2.2 JBI, the foundation for ServiceMix 56 Service engines and binding components 57 Services and endpoints 59 ■ Normalized message router 60 Service description, invocation, and message exchanges 62 Service unit and service assembly 64 ■ JBI wrap-up 65 2.3 ServiceMix architecture and components 65 ServiceMix overview 65 ■ Routing and transformations in ServiceMix 67 ■ ServiceMix deployment models 70 ServiceMix wrap-up 71 2.4 Summary 71 Setting up the Mule and ServiceMix environments 72 3 3.1 Three technologies enhancing the ESB functionality 73 Using Spring as an object container 73 ■ XML marshaling with JiBX 81 ■ Using JMS with the ActiveMQ broker 89 3.2 Preparing the development environment 94 Setting up ESBs, tools, and required libraries 94 Running examples from Eclipse 96 3.3 Inaugurate the Mule environment 98 Writing and configuring the Mule components 99 Running the Mule example 102 3.4 Inaugurate the ServiceMix environment 103 Select the necessary JBI components 103 ■ Configuring the ServiceMix example implementation 104 ■ Running the ServiceMix example 109 3.5 Summary 110 CONTENTS ix The foundation of an integration solution 111 4 4.1 Implementing integration logic with Mule 112 Creating a logging solution with Mule 112 ■ Developing a custom transformer with Mule 115 ■ Integrating Mule and Spring 117 4.2 Implementing integration logic with ServiceMix 120 Creating a logging service assembly for ServiceMix 120 Creating service units and a service assembly 121 Integrating ServiceMix and Spring 125 4.3 Constructing message flows with an ESB 127 What is a message flow? 128 ■ A message flow case study 130 4.4 Implementing a message flow with Mule 131 Implementing the request flow with Mule 132 ■ Implementing the response flow with Mule 133 4.5 Implementing a message flow with ServiceMix 138 Implementing the request flow with ServiceMix 138 Implementing the response flow with ServiceMix 142 4.6 Interlude: Spring Integration 148 A quick example with Spring Integration 149 4.7 Summary 151 PART 2 USING ESB CORE FUNCTIONALITIES ................153 Working with messages 155 5 5.1 Routing messages 156 Fixed router 156 ■ Content-based router 158 5.2 Validating messages 170 Validating messages with Mule 171 ■ Validating messages with ServiceMix 175 ■ An alternative way to perform message validation using Synapse 180 5.3 Transforming messages 182 Implementing message transformation in Mule 182 Implementing message transformation in ServiceMix 188 5.4 Summary 193 x CONTENTS Connectivity options 194 6 6.1 File connectivity 196 Mule File transport 196 ■ ServiceMix file transport 198 6.2 Connecting to JMS 202 Connecting Mule to JMS 203 ■ Connecting ServiceMix to JMS 206 6.3 Connecting to a database using JDBC 209 Connecting Mule to JDBC 210 ■ Connecting ServiceMix to JDBC 213 6.4 Connecting to mail servers 222 Connecting Mule to POP3 and SMTP 223 ■ Connecting ServiceMix to POP3 and SMTP 225 6.5 FTP connectivity 229 FTP and Mule 230 ■ FTP and ServiceMix 233 6.6 Connecting to EJB 3 234 Using EJB 3 from Mule 237 ■ EJB 3 and ServiceMix 239 6.7 Summary 242 Web services support 243 7 7.1 Top-down approach web service 244 Java implementation of the web service 250 ■ Implementing a top-down web service using Mule 252 ■ Implementing a top-down web service using ServiceMix 256 7.2 Bottom-up approach 259 Bottom-up approach using Mule 260 ■ Bottom-up approach using ServiceMix 260 7.3 Consuming web services 263 Consuming web services with Mule 263 ■ Consuming web services using ServiceMix 264 7.4 Web service standards 266 WS-Security 267 ■ Using WS-Security with Mule 267 Using WS-Security with ServiceMix 272 ■ WS-Addressing 274 Using WS-Addressing in Mule 275 ■ Using WS-Addressing in ServiceMix 277 7.5 Summary 279 CONTENTS xi Implementing enterprise-quality message flows 280 8 8.1 Handling errors in your message flow 281 Error handling with Mule 281 ■ Error handling in ServiceMix 284 8.2 Securing the ESB environment 288 Authentication and authorization with Mule 288 Authentication and authorization with ServiceMix 302 8.3 Making your message flows transactional 307 Implementing transactional message flows in Mule 309 Implementing transactional message flows in ServiceMix 312 8.4 Summary 316 PART 3 ESB CASE STUDIES...........................................317 Implementing a case study using patterns 319 9 9.1 Introducing a design approach for integration projects 320 Introducing the Enterprise Integration patterns 320 Analyzing a pattern-based design approach 322 9.2 Introducing a restaurant table reservation case study 324 9.3 Designing the restaurant table reservation solution 325 Designing a publish-subscribe message flow 325 ■ Designing a filtering and routing message flow 327 9.4 Implementing the case study with Mule and ServiceMix 328 The Spring and Hibernate building blocks 328 ■ Implementing the Mule message flow 332 ■ Implementing the ServiceMix message flow 339 9.5 Testing and deploying the integration solution 352 Using JUnit to test the Mule and ServiceMix flows 352 Deploying an integration solution to a production environment 356 9.6 Summary 357 xii CONTENTS Managing and monitoring the ESB 358 10 10.1 System-management Enterprise Integration patterns 359 The Wire Tap pattern 359 ■ The Message Store pattern 363 The Detour pattern 368 10.2 Monitoring using JMX 375 Using JMX to administer Mule 376 ■ Monitoring Mule using MC4J 380 ■ Mule Galaxy and Mule HQ 382 Using JMX to administer ServiceMix 386 ■ Monitoring ServiceMix using MC4J 388 10.3 Summary 391 Implementing a process engine in the ESB 393 11 11.1 Introducing the process engine 394 The execution environment for processes 395 ■ Designing processes for a process engine 397 11.2 A process engine case study: booking a day of scuba diving 400 11.3 Diving into the messages and services 402 Designing the case study message definitions 403 ■ Serializing the case study messages to XML with JiBX 405 ■ Setting the stage for the case study implementation 406 11.4 Implementing a process engine with jBPM and jPDL 411 Orchestrating services with jPDL 411 ■ Implementing the case study with jBPM and Mule 415 11.5 Implementing a process engine with Apache ODE and WS-BPEL 426 Orchestrating services with WS-BPEL 426 ■ Implementing the case study with Apache ODE and ServiceMix 429 11.6 Summary 435 appendix A: ServiceMix 4.0 436 appendix B: Differences between Mule 1.4.x and Mule 2.0.x 441 appendix C: Graphical tool support 445 appendix D: Mule component overview 452 appendix E: ServiceMix component overview 469 appendix F: The Swing test client 477 appendix G: Overview of tools and libraries 481 index 484 foreword Getting different applications to work together has never been fun.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages529 Page
-
File Size-