INT-706 moved config file to the same directory as code and added description
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/* Copyright 2002-2008 the original author or authors.
|
||||
/**
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,13 +21,19 @@ import java.io.IOException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* Demonstrates the handling of Exceptions in an asynchronous messaging
|
||||
* environment. View the 'errorHandlingDemo.xml' configuration file within
|
||||
* this same package. Notice the use of a <header-enricher/> element
|
||||
* within a <chain/> that establishes an 'error-channel' reference
|
||||
* prior to passing the message to a <service-activator/>.
|
||||
*
|
||||
* @author Iwein Fuld
|
||||
*/
|
||||
public class PartyDemo {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new ClassPathXmlApplicationContext("errorHandlingDemo.xml", PartyDemo.class);
|
||||
System.out.println("hit key to stop");
|
||||
System.out.println("hit any key to stop");
|
||||
try {
|
||||
System.in.read();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-2.5.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
|
||||
http://www.springframework.org/schema/integration/stream
|
||||
http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd">
|
||||
|
||||
<context:component-scan
|
||||
base-package="org.springframework.integration.samples.errorhandling" />
|
||||
|
||||
<poller default="true" max-messages-per-poll="1">
|
||||
<interval-trigger interval="1000" />
|
||||
</poller>
|
||||
|
||||
<inbound-channel-adapter ref="partyHost"
|
||||
method="nextInvitation" channel="invitations" />
|
||||
|
||||
<channel id="invitations">
|
||||
<queue capacity="100" />
|
||||
</channel>
|
||||
|
||||
<chain input-channel="invitations">
|
||||
<header-enricher error-channel="failed-invitations" />
|
||||
<service-activator ref="partyGuest" method="onInvitation" />
|
||||
</chain>
|
||||
|
||||
<channel id="failed-invitations" />
|
||||
|
||||
<chain input-channel="failed-invitations">
|
||||
<transformer ref="errorUnwrapper" />
|
||||
<service-activator ref="partyHost" method="onInvitationFailed" />
|
||||
</chain>
|
||||
|
||||
<!--
|
||||
If you don't listen to the default error channel you risk losing track
|
||||
of exceptions, as they cannot be passed back to the sender in band. It
|
||||
is recommended to have a generic error handler in your configuration
|
||||
to prevent this.
|
||||
-->
|
||||
<stream:stderr-channel-adapter channel="errorChannel"
|
||||
append-newline="true" />
|
||||
|
||||
</beans:beans>
|
||||
Reference in New Issue
Block a user