30
Java CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM

Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Java

CAPS Basics

Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM

Page 2: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Czapski_book.fm Page ii Friday, March 7, 2008 4:56 PM

Page 3: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Java

CAPS Basics

Implementing Common EAI Patterns

Michael CzapskiSebastian Krueger

Brendan MarrySaurabh SahaiPeter Vaneris

Andrew Walker

Upper Saddle River, NJ • Boston • Indianapolis • San Francisco

New York • Toronto • Montreal • London • Munich • Paris • Madrid

Capetown • Sydney • Tokyo • Singapore • Mexico City

Czapski_book.fm Page iii Friday, March 7, 2008 4:56 PM

Page 4: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those des-ignations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capi-tal letters or in all capitals.

Sun Microsystems, Inc. has intellectual property rights relating to implementations of the technology described in this publication. Inparticular, and without limitation, these intellectual property rights may include one or more U.S. patents, foreign patents, or pendingapplications.

Sun, Sun Microsystems, the Sun logo, J2ME, J2EE, Java Card, and all Sun- and Java-based trademarks and logos are trademarks or reg-istered trademarks of Sun Microsystems, Inc., in the United States and other countries. UNIX is a registered trademark in the UnitedStates and other countries, exclusively licensed through X/Open Company, Ltd. THIS PUBLICATION IS PROVIDED “AS IS” WITH-OUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR-RANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THIS PUBLICATIONCOULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TOTHE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION.SUN MICROSYSTEMS, INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PRO-GRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME.

The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind andassume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection withor arising out of the use of the information or programs contained herein.

The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may includeelectronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding inter-ests. For more information, please contact: U.S. Corporate and Government Sales, (800) 382-3419, [email protected].

For sales outside the United States please contact: International Sales, [email protected].

This Book Is Safari Enabled

The Safari® Enabled icon on the cover of your favorite technology book means the book is available through Safari Bookshelf. When you buy this book, you get free access to the online edition for 45 days.

Safari Bookshelf is an electronic reference library that lets you easily search thousands of technical books, find code samples, download chapters, and access technical information whenever and wherever you need it.

To gain 45-day Safari Enabled access to this book:

• Go to http://www.prenhallprofessional.com/safarienabled• Complete the brief registration form• Enter the coupon code RSGP-E1MF-1USJ-UKFG-MUS6

If you have difficulty registering on Safari Bookshelf or accessing the online edition, please e-mail [email protected].

Visit us on the Web: www.prenhallprofessional.com

Library of Congress Cataloging-in-Publication Data:

Java CAPS basics : implementing common EAI patterns / Michael Czapski ... [et al.].

p. cm.Includes bibliographical references and index.ISBN-13: 978-0-13-713071-9 (hardover : alk. paper)ISBN-10: 0-13-713071-6 (hardcover : alk. paper)

1. Java (Computer program language) 2. Enterprise application integration (Computer systems) I. Czapski, Michael.QA76.73.J38J3633 2008005.13'3—dc22 2008007526

Copyright © 2008 Sun Microsystems, Inc.4150 Network Circle, Santa Clara, California 95054 U.S.A.All rights reserved.

Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the pub-lisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic,mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc., Rightsand Contracts Department, 75 Arlington Street, Suite 300, Boston, MA 02116, Fax: (617) 848-7047.

ISBN-13: 978-0-13-713071-9ISBN-10: 0-13-713071-6 Text printed in the United States on recycled paper at Courier in Westford, Massachusetts.First printing April 2008

Czapski_book.fm Page iv Friday, March 7, 2008 4:56 PM

Page 5: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

v

Czapski_book.fm Page v Friday, March 7, 2008 4:56 PM

Page 6: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

vi

Czapski_book.fm Page vi Friday, March 7, 2008 4:56 PM

Page 7: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

v

Contents

Preface xv

Acknowledgments xxvii

About the Authors xxix

SECTION I PRELIMINARIES 1

Chapter One Enterprise Integration Styles 3

1.1 Introduction 3

1.2 File Transfer 3

1.3 Database Sharing 4

1.4 Remote Procedure Invocation 5

1.5 Messaging 6

1.6 Service Orchestration 7

1.7 Centralized versus Distributed 8

1.8 Chapter Summary 11

Chapter Two Java CAPS Architecture 13

2.1 Introduction 13

2.2 Historical Note 13

2.3 Context 14

2.4 Java CAPS Architecture 16

2.5 Solution Development Stages 20

2.6 Chapter Summary 23

Chapter Three Project Structure and Deployment 25

3.1 Introduction 25

3.2 From Logical Solution to Physical Deployment 26

Czapski_book.fm Page v Friday, March 7, 2008 4:56 PM

Page 8: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

vi Contents

3.3 Project Structure Considerations 26

3.3.1 Connectivity Map and Deployment Profile 28

3.3.2 Variables and Constants 33

3.4 Backup of Development Artifacts 36

3.5 Release Management 40

3.5.1 Using Java CAPS Source Control System 40

3.5.2 Using a Third-Party Source Control System 46

3.6 Deployment Architectures 50

3.6.1 Small Deployment 50

3.6.2 Medium to Large Deployment 52

3.7 Command-Line Build and Deployment 54

3.7.1 Scripting the Build Process 54

3.7.2 Project Build Script 54

3.7.3 Project Deployment Script 55

3.8 Chapter Summary 56

SECTION II PATTERNS REVIEW AND APPLICATION 57

Chapter Four Message Exchange Patterns 59

4.1 Introduction 59

4.2 Document Message 60

4.3 Command Message 60

4.4 Event Message 61

4.5 Request/Reply 63

4.5.1 JMS Request/Reply 64

4.5.2 HTTP Request/Reply 73

4.5.3 eInsight Subprocess 74

4.5.4 SOAP Request/Reply 74

4.5.5 Web Services Implementation 75

4.5.6 Request/Reply Summary 76

4.6 Return Address 76

4.7 Correlation 77

4.8 Message Sequence 77

4.8.1 JMS Serial Mode Concurrency 79

4.8.2 Sun SeeBeyond JMS Message Server FIFO Modes 80

4.8.3 Serializing Business Processes via JMS and XA 81

Czapski_book.fm Page vi Friday, March 7, 2008 4:56 PM

Page 9: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Contents vii

4.9 Message Expiration 82

4.10 Format Indicator 86

4.11 Data Streaming 88

4.11.1 Batch eWay Streaming 88

4.11.2 eTL Streaming 90

4.12 Message Security 90

4.13 Chapter Summary 91

Chapter Five Messaging Infrastructure 93

5.1 Introduction 93

5.2 Java Message Service (JMS) 94

5.3 JMS Implementation Interoperability 95

5.4 Using JMS to Integrate Non-Java Environments 95

5.5 Queues versus Topics 96

5.6 Sun SeeBeyond IQ Manager 97

5.6.1 JMS Destination Creation and Destruction 97

5.6.2 Temporary JMS Destinations 98

5.6.3 Security 99

5.6.4 Transactionality 99

5.6.5 Concurrency 105

5.6.6 Persistence 105

5.6.7 Selectors 107

5.6.8 FIFO Modes 114

5.6.9 Throttling 115

5.6.10 Redelivery Handling 116

5.6.11 Message Journaling 117

5.7 Resilient JMS with JMS Grid 119

5.8 Competing Consumers 127

5.8.1 eGate and Java Collaborations 127

5.8.2 eInsight Business Processes 129

5.9 Point-to-Point Channel 131

5.10 Publish-Subscribe Channel 132

5.11 Datatype Channel 132

5.11.1 JMS Message Body Formats 132

5.11.2 Endpoint-Dependent Datatypes 133

5.11.3 Multiple Datatypes in Java Collaborations 134

5.11.4 Multiple Datatypes in Business Processes 135

Czapski_book.fm Page vii Friday, March 7, 2008 4:56 PM

Page 10: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

viii Contents

5.12 Invalid Message Channel 136

5.13 Dead Letter Channel 136

5.13.1 Java CAPS Releases Prior to 5.1.2 137

5.13.2 Java CAPS Release 5.1.2 139

5.13.3 Documentation Note 140

5.14 Guaranteed Delivery 140

5.14.1 Is Guaranteed Delivery Always Required? 140

5.14.2 Java CAPS Facilities for Guaranteed Delivery 141

5.14.3 Persistence Notes 142

5.14.4 JMS-Based Guaranteed Delivery 143

5.14.5 eInsight Guaranteed Delivery 145

5.14.6 Solution-Specific Guaranteed Delivery 148

5.14.7 Summary 149

5.15 Channel Adapter 150

5.16 Messaging Bridge 151

5.16.1 Bridging Independent Java CAPS Solutions 152

5.16.2 Bridging Other JMS Messaging Implementations 156

5.16.3 Other Bridging Solutions 156

5.17 Message Bus 157

5.18 Chapter Summary 158

Chapter Six Message Routing 161

6.1 Introduction 161

6.2 Overview 161

6.3 Fixed Router 163

6.4 Content-based Router 165

6.5 Message Filter 168

6.6 Recipient List 169

6.7 Splitter 171

6.8 Aggregator 172

6.9 Resequencer 173

6.10 Composed Message Processor 175

6.11 Scatter-Gather 175

6.12 Routing Slip 176

6.13 Process Manager 177

6.14 Message Broker 177

6.15 Chapter Summary 178

Czapski_book.fm Page viii Friday, March 7, 2008 4:56 PM

Page 11: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Contents ix

Chapter Seven Message Construction 179

7.1 Introduction 179

7.2 Message 179

7.3 Object Type Definitions 180

7.3.1 Generating Oracle Table OTD 181

7.3.2 Other OTD Wizards 187

7.4 Envelope Wrapper 188

7.4.1 Delimited Envelope Wrapper 190

7.4.2 Enveloping XML within XML 192

7.4.3 JMS User Properties Envelope Wrappers 201

7.5 Chapter Summary 202

Chapter Eight Message Transformation 203

8.1 Introduction 203

8.2 Envelope Wrapper 203

8.3 Content Enricher 203

8.4 Content Filter 204

8.5 Claim Check 205

8.6 Normalizer 206

8.7 Canonical Data Model 207

8.8 Chapter Summary 208

Chapter Nine Messaging Endpoints 209

9.1 Introduction 209

9.2 Messaging Gateway 209

9.3 Transactional Client 210

9.4 Polling Consumer 211

9.4.1 Polling File System 211

9.4.2 Other Batch Pollers 214

9.4.3 Polling JMS Destination 214

9.5 Event-Driven Consumer 216

9.6 Competing Consumers 217

9.7 Message Dispatcher 218

9.8 Selective Consumer 219

9.9 Durable Subscriber 219

9.10 Idempotent Receiver 220

9.11 Service Activator 223

9.12 Chapter Summary 225

Czapski_book.fm Page ix Friday, March 7, 2008 4:56 PM

Page 12: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

x Contents

Chapter Ten System Management 227

10.1 Introduction 227

10.2 Java CAPS Monitoring and Management 227

10.2.1 Overview 227

10.2.2 Monitoring eGate-Based Solutions 228

10.2.3 Monitoring eInsight-Based Solutions 233

10.2.5 Event Notification with Alert Agent 245

10.2.6 SNMP Agent 259

10.2.7 Enterprise Manager Command-Line Tool 267

10.2.8 Enterprise Manager Web Service API 271

10.2.9 Java Management Extensions (JMX) 296

10.2.11 Summary 317

10.3 Solution-Specific Management 317

10.3.1 Overview 317

10.3.2 Control Bus 318

10.3.3 Detour 318

10.3.4 Wire Tap 319

10.3.5 Message (Route) History 321

10.3.6 Message Store 325

10.3.7 Test Message 327

10.3.8 Channel Purger 329

10.4 Chapter Summary 331

SECTION III SPECIALIZED JAVA CAPS TOPICS 333

Chapter Eleven Message Correlation 335

11.1 Introduction 335

11.2 Overview 336

11.3 JMSCorrelationID 337

11.4 eInsight Correlations 337

11.5 eInsight Correlation Processor: First Cut 338

11.6 Correlation Identifier 343

11.7 eInsight Correlation Processor: Second Cut 344

11.8 Derived Correlation Identifiers 349

11.9 Derived Correlation Identifiers: Alternative 354

Czapski_book.fm Page x Friday, March 7, 2008 4:56 PM

Page 13: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Contents xi

11.10 Message Relationship Patterns 357

11.10.1 Header-Items-Trailer Correlation 357

11.10.2 Any Order Two Items Correlation 358

11.10.3 Any Order Two Items Correlation with Timeout 360

11.10.4 Items-Trailer Correlation 360

11.10.5 Header-Counted-Items Correlation 362

11.10.6 Counted and Timed Items Correlation 363

11.10.7 Timed Items Correlation 363

11.10.8 Scatter-Gather Correlation 364

11.10.9 Message Relationship Patterns Summary 365

11.11 eGate Correlation with Dynamic Selectors 366

11.11.1 Items-Trailer Correlation 367

11.12 Chapter Summary 369

Chapter Twelve Reusability 371

12.1 Introduction 371

12.2 Using JMS Request/Reply 371

12.3 Using New Web Service Collaborations 372

12.4 Using eInsight Subprocesses for Reusability 373

12.4.1 Request/Response Subprocess 375

12.4.2 OneWayOperation Subprocess 376

12.4.3 Notification Subprocess 376

12.5 Using eInsight Web Services for Reusability 378

12.5.1 Request/Response Web Service 378

12.5.2 OneWayOperation Web Service 381

12.5.3 Notification Web Service 381

12.6 eInsight Service Process Reusability Note 382

12.7 Chapter Summary 382

Chapter Thirteen Scalability and Resilience 383

13.1 Introduction 383

13.2 Distributing Components 383

13.2.1 eGate Component Distribution 384

13.2.2 eInsight Component Distribution 387

13.3 Exception Handling 388

13.3.3 Higher-Level Exception Handling 393

13.4 Compensation 394

Czapski_book.fm Page xi Friday, March 7, 2008 4:56 PM

Page 14: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xii Contents

13.5 High-Availability Architecture 395

13.5.1 Introduction 396

13.5.2 Java CAPS Platform Components 396

13.5.3 Application Connectivity 401

13.5.4 Intersite Failover Architecture 403

13.5.5 Summary 406

13.6 Chapter Summary 407

Chapter Fourteen Security Features 409

14.1 Introduction 409

14.2 HTTP Proxy Server Configuration 409

14.3 HTTP Basic Authentication 410

14.4 Secure Sockets Layer (SSL, TLS) 415

14.4.4 HTTP eWay Mutual Authentication 424

14.4.5 SSL in Java CAPS HTTP eWay Use Notes 428

14.4.6 Strong Cipher Suites 428

14.4.7 Web Services and SSL 430

14.5 Secure Batch FTP variants 433

14.6 Chapter Summary 435

Bibliography 437

Index 445

Czapski_book.fm Page xii Friday, March 7, 2008 4:56 PM

Page 15: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xv

Preface

In their book

Enterprise Integration Patterns: Designing, Building, and DeployingMessaging Solutions

[EIP], Gregor Hohpe and Bobby Woolf elaborate on the sub-ject of enterprise application integration using messaging. They present, discuss,and illustrate over sixty EAI design patterns. These patterns, they believe, are keypatterns most designers of EAI solutions will use when building enterprise integra-tion solutions. Most examples in [EIP] use raw C# and raw Java to illustrate detailsof EAI patterns under discussion. Most of these patterns can be implemented suc-cinctly, elegantly, and comprehensively using tools and technologies provided inthe Sun Java Composite Application Platform Suite [Java CAPS].

This book is about implementing selected enterprise integration patterns,discussed in [EIP], using Java CAPS as the means to building practical enterpriseintegration solutions. It bridges the gap between the somewhat abstract patternlanguage and the practical implementation details. It is designed for integrationarchitects, solution architects, and developers who wish to quickly implemententerprise solutions with Java CAPS. It discusses how EIP patterns can be imple-mented quickly and efficiently by leveraging the Java CAPS tools and the authors’field experience.

While this book discusses Java CAPS implementation of [EIP] patterns, itdoes not discuss the patterns in depth. It is assumed that you are already familiarwith the subject and need to apply the theoretical knowledge using Java CAPS.

This book is also about basics of the essential Java CAPS Suite components,based on the premise that you cannot apply patterns if you cannot effectively use thetools with which to do it. Since the complete Java CAPS offering has so many com-ponents, including ones that are not essential to integration, that this book elabo-rates only on the basic integration tools: eGate, eInsight, eWays, and

Java MessageService (

JMS).

This book also provides information you may need to effectively use JavaCAPS. A considerable amount of Java CAPS-related material, provided in the text,is not published anywhere else.

The companion text,

Java™ CAPS Basics: Implementing Common EAI Patterns

(located on the accompanying CD-ROM), provides over 60 detailed examples that

Czapski_book.fm Page xv Friday, March 7, 2008 4:56 PM

Page 16: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xvi Preface

illustrate concepts and patterns under discussion. Some examples are high level,illustrating specific points. Other examples follow a step-by-step approach.

Java CAPS projects discussed and developed as examples are available forimport and perusal.

H

OW

T

HIS

B

OOK

I

S

O

RGANIZED

The book is divided into three sections. Section I, “Preliminaries,” contains chap-ters that discuss integration and background Java CAPS topics, including enterpriseintegration styles, Java CAPS architecture, and project structure and deployment.

Section II, “Patterns Review and Application,” covers most [EIP] patterns withdiscussion of Java CAPS approaches to implementing them. This section includeschapters dealing with Message Exchange patterns, message correlation, messag-ing infrastructure, message routing, message construction, message transforma-tion, messaging endpoints, and system management patterns and concepts. Whilediscussing Java CAPS implementation of specific patterns, relevant Java CAPSconcepts and methods are also discussed. When discussing implementations of theMessage Sequence pattern, for example, Java CAPS concepts of JMS serial modeconcurrency, Sun SeeBeyond JMS Message Server FIFO modes, and serializingeInsight Business Processes via JMS and XA are also discussed.

Section III, “Specialized Java CAPS Topics,” discusses non-pattern matters ofimportance like solution partitioning, subprocess and Web Services implementa-tion, management, reusability, scalability and resilience options, and others thatare not covered elsewhere. This section also covers security features of Java CAPS.

The accompanying CD-ROM contains over 60 detailed examples implement-ing most of the patterns and concepts under discussion as well as two completeexample solutions using many of the patterns discussed and illustrated in bothbooks. The CD-ROM also contains a detailed practical walkthrough of genera-tion and use of cryptographic objects such as X.509 Certificates, PKCS#12 andJKS Keystores, and related matters.

A

BOUT

THE

E

XAMPLES

Conventions

Java CAPS Enterprise Designer (eDesigner) is a NetBeans-based Integrated Devel-opment Environment (IDE), which developers use to design and build Java CAPSintegration solutions. The vast majority of tasks can be accomplished in eDesigner

Czapski_book.fm Page xvi Friday, March 7, 2008 4:56 PM

Page 17: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Preface xvii

by means of manipulating components represented by graphical objects, connect-ing graphical objects with lines, filling information in dialog boxes and propertysheets, and choosing components in drop-down menus. The intention was tomake development of integration solutions easy for business analysts and similarpersons whose coding skills might not be up to the task in nongraphical environ-ments. Since development of Java CAPS solutions results in production of J2EEEnterprise Applications, this graphical orientation might come as a bit of a sur-prise to hardcore J2EE developers used to writing raw Java and the fine-grainedcontrol they exercise through deployment descriptors and other J2EE artifacts. Bethat as it may, you will find most Java Collaboration examples shown using Javasource code rather than its graphical equivalent. This is principally to make thesamples concise, clearly showing essential parts of each solution, and to minimizewasting space on graphics that add no particular value to the discussion. Every oneof the Java Collaborations could have been shown in “Standard mode,” but thatwould have required numerous pictures, pretty much one for each Java statement,to illustrate what just a few lines of Java code can show in just a few lines. Figure P-1shows an example of a Java Collaboration in Standard mode.

Evident are several lines of pseudocode in the Business Rules pane and justone mapping in the Business Rules Designer pane.

FIGURE P-1: Java Collaboration in Standard mode

Czapski_book.fm Page xvii Friday, March 7, 2008 4:56 PM

Page 18: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xviii Preface

In contrast, the same Java Collaboration in Source Code mode is much moreilluminating, as seen in Figure P-2, as it shows all there is to know about 30 or solines of code all at once.

Since switching between Standard mode and Source Code mode is a button-click away, we chose to use Source Code mode for Java Collaboration examples.

eInsight Business Processes are much easier to understand when presented inthe graphical view, appearing similar to what is shown in Figure P-3. Object icons,taken from the Business Process Modeling Notation, are quite pleasant to look at,in this author’s opinion.

In contrast, working directly with BPEL4WS XML source, an example ofwhich is shown in Figure P-4, which is possible, is in this author’s opinion bor-dering on cruel and unusual punishment, just as working directly with any otherXML-based procedural language would be.

So, Java Collaborations are mostly shown in the Source Code mode, and eIn-sight Business Processes are mostly shown with the Business Rules Designer.

How you work with the tool is still up to you.

FIGURE P-2: Java Collaboration in Source Code mode

Czapski_book.fm Page xviii Friday, March 7, 2008 4:56 PM

Page 19: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Preface xix

FIGURE P-3: eInsight Business Processes in the graphical view

FIGURE P-4: BPEL4WS XML source

Czapski_book.fm Page xix Friday, March 7, 2008 4:56 PM

Page 20: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xx Preface

L

IST

OF

I

LLUSTRATIONS

AND

E

XAMPLES

To include both discussion and all relevant examples in one book would havemade it over 1,000 pages in length—too large for printing. As a consequence, theoriginal manuscript has been broken up into two parts. Part I,

Java™ CAPS Basic:Implementing Common EAI Patterns

(this book) discusses Java CAPS facilities,focusing on their application to implementation of EIP patterns, with high-level illus-trations and references to detailed examples in Part II, which is contained on the CD-ROM that accompanies this book. Part II provides both detailed illustrations for mostof the patterns as well as two completely worked-through Java CAPS–based casestudy solutions that implement a number of the patterns discussed in this book.Part II also contains a chapter dealing with cryptographic objects used to configuresecurity-related aspects of the suit

e.Illustrations and examples from Part II are listed in Table P-1, with section

headers in the order of appearance. Of the over 60 examples, most are developedin a step-by-step manner, deployed, and exercised. In most cases, results of execu-tion are shown and discussed.

T

ABLE

P-1:

Illustrations and Examples in Part II

Chapter/Section Example Topic

Hello Java CAPS World

Introductory step-by-step example. Basic file transfer projects with separate implementations using eGate and eInsight.

Event Message Using Scheduler

Event Message pattern implementation.

Basic scheduled solution using Event Message triggered by a Scheduler eWay.

External Scheduler Example

Event Message pattern implementation.

Scheduled solution using external scheduler and an external TCP Sender client injecting an Event Message through a TCP Server eWay.

JMS Request/Reply Invoker for eInsight

Request/Reply pattern implementation.

New Web Service Java Collaboration for invoking JMS Request/Reply functionality from an eInsight Business Process.

Czapski_book.fm Page xx Friday, March 7, 2008 4:56 PM

Page 21: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Preface xxi

Chapter/Section Example Topic

JMS Request/Response Auction Pattern

Request/Reply pattern implementation.

Java Collaboration and JMS Request/Reply–based implementation of an Auction pattern where the fastest responder wins.

HTTP Request/Response

Request/Reply pattern implementation.

A series of HTTP requestor and HTTP responder implementations using both HTML and XML payloads, prefaced by a recap of HTTP principles and mechanics.

SOAP Request/Response

Request/Reply pattern implementation.

Specialization of a HTTP request/response implementation using explicitly constructed and parsed SOAP XML messages as requests and responses.

Web Service Request/Reply

Request/Reply pattern implementation.

Web Service request/response implementation as an example of a Request/Response pattern using both eInsight Business Processes and Java Collaborations.

JMS Serial Mode Concurrency

Message Sequence pattern.

Using Sun SeeBeyond JMS Message Server facilities for implementation of message sequence preserving solutions.

Sun SeeBeyond JMS FIFO Modes

Using Sun SeeBeyond JMS Message Server facilities for implementation of message sequence preserving solutions. Series of examples demonstrates the impact of different Sun SeeBeyond JMS Message Server FIFO modes on message sequence.

Serializing Business Processes with XA

Message Sequence pattern.

Examples illustrating the impact of imposing XA transactionality on eInsight Business Processes and how it affects message sequence preservation (new in v. 5.1)

Message Expiration Java Collaboration and JMS-based example illustrating Message Expiration.

(continues)

T

ABLE

P-1:

Illustrations and Examples in Part II

(continued)

Czapski_book.fm Page xxi Friday, March 7, 2008 4:56 PM

Page 22: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xxii Preface

Chapter/Section Example Topic

Batch Local File Streaming

Data streaming examples using Batch Local File eWay with discussion of buffering and its impact on message throughput.

eTL Streaming Very basic eTL example streaming data from a flat file to a database table and a functionally equivalent Java Collaboration example.

Temporary JMS Destinations

Anti-example illustrating the use of an explicitly created JMS temporary destination.

Static Selector Example illustrating the use of static JMS selectors.

Dynamic Selector Example illustrating the use of dynamic JMS selectors, constructed at runtime and used in a Java Collaboration to explicitly choose messages to receive.

Resilient JMS with JMS Grid

Example of a simple JMS Grid-based automatic JMS Client failover.

JMS Message Body Formats

Example collaboration that inspects JMS header properties to determine JMS message body format and branch.

Dead Letter Channel in 5.1.2

Example exercising JMS Redelivery Handling functionality with undeliverable message being delivered to a Dead Letter Queue.

eInsight XA Transactionality

Example inducing success and failure outcomes that demonstrate XA transactionality of an eInsight Business Process with side effects in non-XA-capable resources.

eInsight Persistence Illustration of eInsight persistence, eInsight monitoring, and eInsight restart-recovery of in-flight process instances.

Resequencer: Basic Version

Simple resequencer with memory-based message buffer.

Resequencer: Persisted Version

More sophisticated resequencer with RDBMS-based message buffer and message sequence persistence.

Routing Slip Routing slip-based message routing solution using JSM and Java Collaborations.

JMS User Properties Envelope Wrappers

Series of examples demonstrating Envelope Wrapper pattern implemented using JMS message header properties in Java Collaborations and eInsight Business Processes.

T

ABLE

P-1:

Illustrations and Examples in Part II

(continued)

Czapski_book.fm Page xxii Friday, March 7, 2008 4:56 PM

Page 23: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Preface xxiii

Chapter/Section Example Topic

Content Enricher Content Enricher implementation using eInsight and Oracle eWay to receive a Purchase Order, enrich it with pricing information for an Oracle database, and produce an Invoice.

Polling File System Series of examples polling local file system using Scheduler eWay–driven and Batch Inbound–driven Batch Local File eWay to implement polling solutions.

Polling JMS Destination

Try-wait-retry FTP delivery solution implementing JMS Destination polling for retry scheduling.

Durable Subscriber Example illustrating the concept of a JMS topic durable subscriber and behavioral differences between nondurable and durable subscribers.

Idempotent Receiver Example illustrating message duplication detection–based Idempotent receiver solution.

Multi-Input Service Activator

Example using the OpenTravel Alliances XML Schema documents to implement a Service Activator solution that allows the business service to be activated through a file submission, JMS message submission, and Web Services invocation.

Monitoring eInsight-based Solutions

Example illustrating eInsight persistence, persistence for reporting, and runtime monitoring of eInsight Business Process instances.

Simple Alert Processor for a JMS Channel

Example implementing a simple solution that receives and processes Alert Agent alerts delivered through the JMS Alert Channel.

Catching “Uncatchable” Exceptions

Example using Alert Agent infrastructure to catch and process exceptions that occur outside the Java Collaborations and Business Processes and therefore cannot be caught and processed in JCDs or BPs. Catching and processing a database connectivity exception is the subject of this example.

Programmatic Management

Example Java Collaboration that uses the JMX instrumentation to programmatically start and stop a specified Java CAPS component, such as another Java Collaboration or a Business Process service.

(continues)

T

ABLE

P-1:

Illustrations and Examples in Part II

(continued)

Czapski_book.fm Page xxiii Friday, March 7, 2008 4:56 PM

Page 24: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xxiv Preface

Chapter/Section Example Topic

JMS Latency Java Collaboration and eInsight Business Process examples illustrating calculation of JMS message delivery latency.

eInsight Correlation Processor: First Cut

Example of an incorrect, naïve implementation of eInsight correlation.

eInsight Correlation Processor: Second Cut

Example of correct implementation of a simple eInsight correlation with a simple correlation key.

Derived Correlation Identifiers

Example of a more complex eInsight correlation with a structured, message-derived correlation key based on subprocess-based correlation key derivation solution.

Derived Correlation Identifiers: Alternative

Alternative example of a more complex eInsight correlation with a structured, message-derived correlation key based on Java Collaboration correlation key derivation preprocessor.

Message Relationship Patterns

Series of examples of using eInsight correlation facilities to implement Message Relationship patterns: Header-Items-Trailer Correlation, Any Order Two Items Correlation, Any Order Two Items Correlation with Timeout, Items-Trailer Correlation, Header Counted Items Correlation, Counted and Timed Items Correlation, Timed Items Correlation, Scatter-Gather Correlation.

Items-Trailer Correlation

Reimplementation of the Items-Trailer Correlation using a Java Collaboration, JMS, and dynamic JMS selectors—no eInsight.

Using New Web Service Collaborations

Example of using New Web Service Java Collaborations to implement reusable modules for use as activities in eInsight Business Processes.

Using eInsight Subprocesses for Reusability

Series of examples of using eInsight subprocesses as reusable components for use as activities in eInsight Business Processes: Request/Response, OneWay Operation, and Notification Subprocess implementations.

Using eInsight Web Services for Reusability

Series of examples of using Web Services as reusable components for use as activities in eInsight Business Processes: Request/Response, OneWay Operation, and Notification Web Service implementations.

JMS-Triggered Java Collaborations

Example of exception and JMS redelivery handling in a JMS message–triggered Java Collaboration.

T

ABLE

P-1:

Illustrations and Examples in Part II

(continued)

Czapski_book.fm Page xxiv Friday, March 7, 2008 4:56 PM

Page 25: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Preface xxv

Chapter/Section Example Topic

Other Java Collaborations

Example of exception processing in a non-JMS message–triggered Java Collaboration.

JMS-Triggered Business Processes

Example of exception handling in a JMS message–triggered eInsight Business Process demonstrating behavior differences between XA and non-XA processes.

Fault Handlers Example of using Fault Handlers in eInsight Business Processes.

Secure Sockets Layer (SSL, TLS)

Series of examples illustrating the use of SSL in Java CAPS solutions, both HTTP eWay- and Web Services-based. Covers server-side and mutual authentication for both server and client endpoints.

Web Service, Stored Procedures, and XA

Complete case study implementing an Employee Database Maintenance process with a multi-database update, Web Services, Oracle Stored Procedures, and an XA Business Process. This example implements and exercises a large number of patterns and suite features.

Example Travel Reservation

Complete Travel Reservation case study using Web Services orchestration and eInsight exception handling and compensation. This example implements and exercises a large number of patterns and suite features.

Handling Repeating Nodes in BPEL

Example of handling repeating nodes from XSD-based OTD in eInsight.

XML Deep Parse vs. Shallow Parse

Example implementing lazy XMLparse.

Using Multi-Operation WSDL

Example of implementing a multi-operation Web Service using WSDL and eInsight.

Cryptographic Objects Step-by-step discussion of cryptographic objects required to configure PKI-related aspects of Java CAPS, with tools, commands, and scripts necessary to create certificate signing requests, convert between various certificate formats, and create various keystore types.

T

ABLE

P-1:

Illustrations and Examples in Part II

(continued)

Czapski_book.fm Page xxv Friday, March 7, 2008 4:56 PM

Page 26: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

Czapski_book.fm Page xxvi Friday, March 7, 2008 4:56 PM

Page 27: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xxvii

Acknowledgments

First and foremost, I would like to acknowledge my family, Lorraine, Natalie, andDaniel, who graciously tolerated the long hours I put into this project, encour-aged me through the process, and rejoiced with me as I reached each significantmilestone. Without their support, this project would not be possible.

Sun’s announcement of the Red October program in November 2005, underwhich all Sun Software was going to be made available for download and use, wasmet with mixed reaction among some of the former SeeBeyond folk. Java CAPS isa complex enterprise application integration platform, not a lone-developer IDEor a data center technologist–configured infrastructure package. Some felt thatmaking the Java CAPS suite freely downloadable would be unhelpful. This wasparticularly so as a major gap was perceived to exist between material in productdocumentation and the product and context knowledge an enterprise architectand integration developer would need to effectively use Java CAPS. I felt that abook bridging this gap, and showing examples of Java CAPS solutions implement-ing enterprise integration patterns, would be appropriate and timely.

Although the manuscript took three times as long to write as I originallyanticipated, I made some of the material available to individuals both inside andoutside Sun well before it was completed. This was to validate the original intent,to help answer specific questions, and to get early feedback on the content andcoverage of various topics. I wish to acknowledge these individuals, particularlyJason Baragry, who took time to review most of the chapters and provided valu-able feedback that helped shape the manuscript. I also wish to acknowledge othermembers of the seebeyond-I community at the ITtoolbox, who took time to pro-vide feedback and who encouraged me to continue.

While this project is largely my own and was almost exclusively undertaken inmy own time, there were occasions when I worked on it during my regular hours.Ray Gear at SeeBeyond and subsequently at Sun, and Angelo Joseph at Sun, aredue credit for encouraging me to finish the project and tolerating the occasionaldiversion.

Czapski_book.fm Page xxvii Friday, March 7, 2008 4:56 PM

Page 28: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xxviii Acknowledgments

I wish to thank my collaborators, Sebastian Krueger, Brendan Marry, SaurabhSahai, Peter Vaneris, and Andrew Walker, all talented Java CAPS field practitio-ners, for providing material for various chapters and for reviewing the manu-script. In particular, the topics Brendan and Peter addressed would likely not havebeen covered if they had not provided the material. I would also like to thankDean Hansen, who provided notes on some of the material in early chapters andreviewed parts of the material.

Special thanks go to Jason Fordham and Peter C. Berkman, my colleagues atSun, for trying to make a virtual image of the Solaris 10-based Java CAPS instal-lation available in time for inclusion on the CD-ROM accompanying the book.Although through no fault of theirs this did not happen I am grateful to them forthe effort.

Last, but not least, I would like to thank Carol J. Lallier, who made sure thetext is in English, however American it may be; Kim Arney, who laid out the book;Elizabeth C. Ryan, who managed the publication process; and Greg Doench, whotook a punt and walked me through the process of writing and publishing a book.

Michael CzapskiSydney, December 2007.

Czapski_book.fm Page xxviii Friday, March 7, 2008 4:56 PM

Page 29: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xxix

About the Authors

Michael Czapski

has 25 years of experience in the IT industry, the last 10 in thefield of EAI. He provides Java CAPS expertise and leverages Java CAPS capabili-ties in solutions spanning the spectrum of Sun Microsystems software offerings.Michael has written a number of technical whitepapers on various topics forICAN and Java CAPS, addressing, among others, Java CAPS security configura-tion, WS-Security implementation in Java CAPS, and application of EAI patternsto Java CAPS solutions. He is a Java CAPS Apostle, an active contributor to JavaCAPS communities and forums, and a presenter at various industry conferences.

Saurabh Sahai

has over 13 years of experience in IT, developing enterprise-classmiddleware software and commercial solutions for major software vendors. Overthe past 4 years, he has worked as an integration architect within the Sun SOA/EAI professional service practice, where he is responsible for the architecture anddelivery of advanced Sun Java CAPS–based solutions to major commercial andgovernment clients within Australia and New Zealand.

Prior to Sun Microsystems, he worked for around 9 years as a J2EE/middle-ware architect for Fujitsu Australia Software Technologies, developing Java/J2EE/C++–based middleware software for Fujitsu’s INTERSTAGE enterprise productset. He has extensive experience developing commercial J2EE applications usingmajor application servers and open-source frameworks.

Saurabh is based in Sydney, Australia, and loves listening to Jazz in his sparetime.

Andrew Walker

has 18 years of experience in IT and originally joined SeeBeyondin January 1999, where he started working with one of the early EAI softwareproducts, then known as DataGate. Subsequently, he has worked with all the EAIsoftware products released by SeeBeyond and now Sun Microsystems. Andrewhas broad experience in architecting and implementing EAI and SOA solutionsfor customers in the Asia–Pacific region. He is currently based in Singapore andprovides Java CAPS consulting services throughout the Asia–Pacific region aspart of his job role in Sun Microsystems Professional Services.

Czapski_book.fm Page xxix Friday, March 7, 2008 4:56 PM

Page 30: Java CAPS Basics - blogs.czapski.id.au › wp-content › uploads › 2008 › 03 › Czapsk… · Java ™ CAPS Basics Czapski_book.fm Page i Friday, March 7, 2008 4:56 PM. Czapski_book.fm

xxx About the Authors

Brendan Marry

has over 10 years of experience in IT and is currently an integra-tion solutions architect for Sun Microsystems in Auckland, New Zealand, respon-sible for the design and delivery of enterprise integration architectures using JavaCAPS.

He has over 4 years of experience at Sun, specifically around the Sun Java CAPS.Brendan worked in the Java Mobile space and Java Enterprise space in Europebefore immigrating to New Zealand and joining Sun. He enjoys providing projectmanagement and solution architectural advice, vision, and guidance to his clientsusing the Java CAPS products.

Sebastian Krueger

started working on EAI software with SeeBeyond ICAN 5.0.5in late 2005 and has since worked on all Sun Java CAPS eGate, eInsight, andeXchange product components, as well as on JMS Grid.

Initially providing Java CAPS consulting services to the New Zealand market,he now works for the Inland Revenue Department of New Zealand, where he is asenior analyst programmer.

Sebastian is a Sun-Certified Java Programmer and an LPI-Certified LinuxProfessional.

Peter Vaneris

has 19 years of experience in the IT industry, the last 2 in the fieldof Java CAPS support. Prior to working with Java CAPS, Peter specialized in sys-tem administration, monitoring, automation, and enterprise management.

Czapski_book.fm Page xxx Friday, March 7, 2008 4:56 PM