diff --git a/spring-integration-reference/reference/images/cafe-demo.png b/spring-integration-reference/reference/images/cafe-demo.png new file mode 100644 index 0000000000..e97316d5a2 Binary files /dev/null and b/spring-integration-reference/reference/images/cafe-demo.png differ diff --git a/spring-integration-reference/reference/src/configuration.xml b/spring-integration-reference/reference/src/configuration.xml index f1bad9bb81..c26b895bd9 100644 --- a/spring-integration-reference/reference/src/configuration.xml +++ b/spring-integration-reference/reference/src/configuration.xml @@ -5,18 +5,17 @@
Introduction - Following the Spring philosophy, Spring Integration offers a number of configuration options. Which option you - choose depends upon your particular needs and at what level you prefer to work. As with the Spring framework in - general, it is also possible to mix and match the various techniques according to the particular problem at hand. - For example, you may choose the XSD-based namespace for the majority of configuration combined with a handful of - objects that are configured with annotations. Of course, it is also possible to always stick with a single - approach. The main point is that these are options for configuration motivated by the need - to support a user community with a wide range of preferences. That said, there has also been a concerted effort - to provide consistent naming so that, for example, the XML elements defined by the XSD schema will match the - names of annotations, and the attributes of those XML elements will match the names of annotation properties. - Direct usage of the API is yet another option and is described in detail in . We expect that - most users will choose one of the higher-level options, such as the namespace-based or annotation-driven - configuration. + Spring Integration offers a number of configuration options. Which option you choose depends upon your particular + needs and at what level you prefer to work. As with the Spring framework in general, it is also possible to mix + and match the various techniques according to the particular problem at hand. For example, you may choose the + XSD-based namespace for the majority of configuration combined with a handful of objects that are configured with + annotations. Of course, it is also possible to always stick with a single approach. The main point is that these + are options for configuration motivated by the need to support a user community with a wide + range of preferences. That said, there has also been a concerted effort to provide consistent naming so that, for + example, the XML elements defined by the XSD schema will match the names of annotations, and the attributes of + those XML elements will match the names of annotation properties. Direct usage of the API is yet another option + and is described in detail in . We expect that most users will choose one of the + higher-level options, such as the namespace-based or annotation-driven configuration.
@@ -174,6 +173,12 @@ ]]> + When exceptions occur in an endpoint's execution of its MessageHandler callback, + those exceptions will be wrapped in ErrorMessages and sent to the Message Bus' + 'errorChannel' by default. To enable global error handling, simply register a handler on that channel. For + example, you can configure Spring Integration's PayloadTypeRouter as the handler of + an endpoint that is subscribed to the 'errorChannel'. That router can then spread the error messages across + multiple channels based on Exception type. The 'message-bus' element accepts two more optional attributes. First is the size of the dispatcher thread @@ -300,5 +305,22 @@ List<LineItem> extractItems(Order order) { return order.getItems() } + + The @Publisher annotation is a convenience for sending messages with AOP after + advice. For example, each time the following method is invoked, its return will be sent to the "fooChannel": + + + + Similarly, the @Subscriber annotation triggers the retrieval of messages from a + channel, and the payload of each message will then be sent as input to an arbitrary method. This is one of the + simplest ways to configure asynchronous, event-driven behavior: + + \ No newline at end of file diff --git a/spring-integration-reference/reference/src/overview.xml b/spring-integration-reference/reference/src/overview.xml index 88cba33ad2..ee9d6f616b 100644 --- a/spring-integration-reference/reference/src/overview.xml +++ b/spring-integration-reference/reference/src/overview.xml @@ -22,13 +22,14 @@ Spring Integration is a new member of the Spring portfolio motivated by these same goals and principles. It - extends the Spring programming model into the messaging domain and builds upon the core enterprise integration - support to provide an even higher level of abstraction. It supports message-driven architectures where inversion - of control applies to runtime concerns, such as when certain business logic should execute - and where the response should be sent. It supports routing and transformation of messages so - that different transports and different data formats can be integrated without impacting testability. In other - words, the messaging and integration concerns are handled by the framework, so business components are further - isolated from the infrastructure and developers are relieved of complex integration responsibilities. + extends the Spring programming model into the messaging domain and builds upon Spring's existing enterprise + integration support to provide an even higher level of abstraction. It supports message-driven architectures + where inversion of control applies to runtime concerns, such as when certain business logic + should execute and where the response should be sent. It supports routing and transformation + of messages so that different transports and different data formats can be integrated without impacting + testability. In other words, the messaging and integration concerns are handled by the framework, so business + components are further isolated from the infrastructure and developers are relieved of complex integration + responsibilities. As an extension of the Spring programming model, Spring Integration provides a wide variety of configuration diff --git a/spring-integration-reference/reference/src/samples.xml b/spring-integration-reference/reference/src/samples.xml index fa99b0d6c6..1a8045d265 100644 --- a/spring-integration-reference/reference/src/samples.xml +++ b/spring-integration-reference/reference/src/samples.xml @@ -2,11 +2,158 @@ Spring Integration Samples -
- Introduction +
+ The Cafe Sample - The Spring Integration 1.0 Milestone 1 release includes a limited number of sample applications. Several more - interesting and comprehensive samples are in the works for upcoming releases. + In this section, we will review a sample application that is included in the Spring Integration Milestone 1 + release (see the "spring-integration-samples" JAR and source JAR). This sample is inspired by one of the samples + featured in Gregor Hohpe's Ramblings. + + + The domain is that of a Cafe, and the basic flow is depicted in the following diagram: + + + + + + + + + + The DrinkOrder object may contain multiple Drinks. Once the order + is placed, a Splitter will break the composite order message into a single message per + drink. Each of these is then processed by a Router that determines whether the drink is hot + or cold (checking the Drink object's 'isIced' property). Finally the + Barista prepares each drink, but hot and cold drink preparation are handled by two + distinct methods: 'prepareHotDrink' and 'prepareColdDrink'. + + + Here is the XML configuration: + + + + + + + + + + + + + + + + + + + +]]> + Notice that the Message Bus is defined. It will automatically detect and register all channels and endpoints. + The 'annotation-driven' element will enable the detection of the splitter and router - both of which carry + the @MessageEndpoint annotation. That annotation extends Spring's + "stereotype" annotations (by relying on the @Component meta-annotation), and so all classes carrying the + endpoint annotation are capable of being detected by the component-scanner. + split(DrinkOrder order) { + return order.getDrinks(); + } +}]]> + + + + Now turning back to the XML, you see that there are two <endpoint> elements. Each of these is delegating + to the same Barista instance but different methods. The 'barista' could have been + defined in the XML, but instead the @Component annotation is applied: + + + + As you can see from the code excerpt above, the barista methods have different delays. This simulates work being + completed at different rates. When the CafeDemo 'main' method runs, it will loop 100 + times sending a single hot drink and a single cold drink each time. + + + + If you run the CafeDemo, you will see that all 100 cold drinks are prepared in roughly the same amount of time as + only 70 of the hot drinks. This is to be expected based on their respective delays of 700 and 1000 milliseconds. + However, by configuring the endpoint concurrency, you can dramatically change the results. For example, on my + machine, the following single modification causes all 100 hot drinks to be prepared before the 4th cold drink is + ready: + + + + ]]>]]>]]> + + + In addition to experimenting with the 'concurrency' settings, you can also try adding the 'schedule' sub-element + as described in . Additionally, you can experiment with the channel's + configuration, such as adding a 'dispatcher-policy' as described in .
\ No newline at end of file