About This Book

At its core, Spring Integration defines an API for messaging and a corresponding data model. The abstraction provided by that API and model essentially serves as a lightweight messaging framework that can be used in any runtime environment from a full-blown application server to a simple main method within a Java class that’s executed from a command line or within an IDE.

A messaging framework can be quite useful even in standalone applications that don’t require complex system integration. For example, the core enterprise integration patterns can be used to construct a pipeline of filters, transformers, and routers that all run within a single process. With the growing interest in asynchronous event-driven applications, that pipeline design might be a good match for many of your applications.

This book recognizes the value of the core messaging patterns not only as building blocks for system integration but also as a set of components that can facilitate standalone message-driven applications of a much smaller scale. The first two parts of the book, “Background” and “Messaging,” consist of seven chapters that are relevant for either type of application. The third part, “Integrating systems,” includes six chapters that build upon that core knowledge while demonstrating the most common messaging adapters for assembling distributed applications and integrating various data and messaging systems. The fourth and final part of the book, “Advanced topics,” provides another five chapters covering practical concerns for those using the framework in real-world applications.

Throughout this book, we hope you’ll find that the depth of content goes well beyond the practical concerns of the framework’s usage as it ventures into the concepts behind the patterns and the decisions to consider when applying those patterns to the design of your applications.

Roadmap

Part 1: Background

  • Chapter 1 provides a high-level introduction to Spring Integration. It also walks through the quintessential Hello World example.
  • Chapter 2 addresses the fundamentals of enterprise integration. It takes a pros-and-cons approach to such topics as tight and loose coupling, synchronous and asynchronous communication, and the four integration styles: filesystem, shared database, remote procedure calls, and messaging.

Part 2: Messaging

  • Chapter 3 offers the first jump into the Spring Integration API. It focuses only on the Message and Message Channel abstractions, since those two must be understood in depth before a meaningful exploration of the rest of the framework.
  • Chapter 4 takes the next logical step by describing the generic role of Message Endpoints. Much of what follows in later chapters will focus on specific types of endpoints, but they share the common characteristics described here.
  • Chapter 5 reveals how you connect the business logic within your application’s service layer to the messaging endpoints. It emphasizes the importance of maintaining a separation of concerns between that business logic and the integration logic.
  • Chapter 6 demonstrates how to add conditional logic to messaging flows. The Message Filter and Message Router patterns are presented within the context of several real-world scenarios.
  • Chapter 7 explains how to deal with messaging flows that require nonlinear processing. The Message Splitter, Aggregator, and Resequencer patterns are featured, along with lower-level patterns such as the Correlation Identifier and higher-level patterns like Scatter-Gather.

Part 3: Integrating systems

  • Chapter 8 focuses on XML. Unlike many integration frameworks, Spring Integration doesn’t require the use of XML for message structure, yet it’s still a popular format. This chapter introduces transformers, splitters, and routers that take advantage of XPath, XSLT, and Spring’s own XML marshalling (OXM) libraries.
  • Chapter 9 is the first to deal with messaging adapters and takes the logical starting point for a Java-based framework: the Java Message Service (JMS). Along with a detailed discussion of mapping between the JMS and Spring Integration messaging models, this chapter also dives deep into the underlying Spring Framework support so that you understand exactly how the adapters work.
  • Chapter 10 turns to email, perhaps the most widely used form of messaging in the modern world. Of course, the emphasis is on the various ways that enterprise applications can send and receive email as part of their automated processing.
  • Chapter 11 gets back to the roots of integration and the role of the shared file-system. This modern perspective approaches the topic within the context of messaging, with file directories as endpoints connected to channels either on the reading or writing end of a message flow.
  • Chapter 12 ventures into the wide world of web services. Spring Integration supports both REST- and SOAP-based services as either inbound or outbound endpoints. This chapter shows not only how to use these adapters but also provides guidance on choosing among the options.
  • Chapter 13 wraps up the discussion of adapters with two more selections from the Spring Integration toolbox. The chapter begins with the XMPP adapters that enable plugging into instant messaging systems. The chapter then provides a tour of the Twitter adapters that can be used for updating or reading a timeline, sending or receiving direct messages, detecting mentions, or performing a search.

Part 4: Advanced topics

  • Chapter 14 reveals how you can monitor and manage a Spring Integration application at runtime. Relevant integration patterns such as Message History, Wire Tap, and Control Bus are described here along with Spring Integration’s support for Java Management Extensions (JMX).
  • Chapter 15 provides a thorough discussion of task scheduling in a Spring Integration application. This is an important topic for any messaging flow that includes the Polling Consumer pattern. No such discussion would be complete without getting into the thorny details of concurrency, and this chapter doesn’t shy away. As a result, it’s also quite relevant for anyone relying upon asynchronous execution and parallel processing of messages.
  • Chapter 16 shows how Spring Integration and Spring Batch can be used together. First, it provides a basic overview of batch processing applications in general and then a quick introduction to Spring Batch. Learning how to add messaging capabilities to batch applications might be useful to anyone tasked with modernizing their legacy systems.
  • Chapter 17 presents the main principles behind the Open Services Gateway initiative (OSGi) and demonstrates how its approach to modularity and its service registry can be utilized in Spring Integration applications. In the process, this chapter also provides background information about the Eclipse Gemini Blueprint project, which is the successor to Spring Dynamic Modules.
  • Chapter 18 covers a topic that should never be neglected in a book aimed at developers: testing. Applications that interact with distributed systems are notoriously difficult to test, and even relatively simpler applications that rely upon messaging present challenges due to concurrent processing and asynchronous execution. This chapter offers general guidance and suggests several tools that can facilitate the test-driven methodology in the face of such challenges.

Who should read this book?

One of the main design goals of Spring Integration is to make enterprise application integration (EAI) accessible in a wide variety of use cases. Instead of a heavyweight infrastructure requiring the setup of an external integration bus and the use of specialized utilities and tools, Spring Integration builds on top of the Spring Framework and allows the inclusion of its components and concepts directly inside applications, reusing a wide array of skills and tools developers already have, like their knowledge of Java or Spring.

In a similar way, this book intends to be a companion and guide to anyone who needs to incorporate integration aspects in their applications. EAI experts will find a hands-on overview of how the concepts with which they’re already familiar materialize in the design and features of the framework. Nonspecialists, developers, and architects who need to solve specific integration problems will find a set of useful concepts and patterns described from a pragmatic, example-driven perspective. Managers will better understand the challenges inherent within the solutions whose development they supervise and, at the same time, the opportunities that the framework offers.

This book addresses an audience with varying degrees of familiarity with EAI, Spring, or even Spring Integration itself. Prior knowledge of any of these would surely help you connect the dots with greater ease, but isn’t required. The book introduces basic background concepts before discussing more advanced topics. Conversely, existing familiarity with any of these topics should detract little from the enjoyment of the book; this deep dive into technical details and best practices will provide a lot to take away.

Code conventions and downloads

All source code in listings or in the text is in a fixed-width font like this to separate it from ordinary text. Code annotations accompany some of the listings, highlighting important concepts. In most cases, numbered bullets link to explanations that follow in the text. You can download the source code for this book from the publisher’s website at www.manning.com/SpringIntegrationinAction.

Although this book project was initiated when Spring Integration was at version 1.0, we ended up making changes throughout to keep up with the latest major version of the framework: 2.0. In fact, our code sample repository actually uses the latest minor version, 2.1, which is a superset of 2.0.

You may notice that we use different approaches in XML schema namespace prefixes across the many configuration examples in the book. Sometimes we prefix namespaces with just the name of the type of adapter being configured (e.g., <mail:outbound-channel-adapter>), and other times the prefix is further qualified with an indicator that it’s for integration (e.g., <int-http:inbound-gateway>). The latter option helps avoid conflicts with other common uses of the unqualified prefix, as could clearly cause confusion in the case of the prefix http:. In yet other cases, we specify the integration namespace as the base namespace of the XML file itself so that no prefix is necessary for the components defined within that schema (e.g., <channel>). That’s typically done when it’s the Spring Integration “core” namespace in question, and in those examples, you’ll often see an explicit prefix for the Spring beans namespace (e.g., <beans:bean>). We wanted to point out these differences here, so that you aren’t confused when you encounter them. In the real world, you’ll likely stumble upon a wide variety of prefixes, so it actually helps to be accustomed to seeing a reflection of that in the book examples.

Finally, we want to clarify an approach we’ve taken to the occurrence of enterprise integration pattern names within this book. The first occurrence of a pattern name will typically be capitalized and/or italicized (e.g., Control Bus). Once the context is established for a given pattern, it will occur in regular text throughout the book. The pattern names appear so frequently in the book, we decided it was distracting to constantly use capitalization.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.60.62