Merge pull request #43 from ghillert/INTSAMPLES-54
INTSAMPLES-54 - Update README.md
This commit is contained in:
@@ -1,8 +1,37 @@
|
||||
Hello World Sample
|
||||
==================
|
||||
|
||||
This is an obvious place to get started. It demonstrates a simple message flow represented by the diagram below:
|
||||
This is an obvious place to get started. This sample project contains 2 basic sample applications:
|
||||
|
||||
Message -> Channel -> ServiceActivator -> QueueChannel
|
||||
* Hello World
|
||||
* Poller Application
|
||||
|
||||
## Hello World
|
||||
|
||||
The Hello World application demonstrates a simple message flow represented by the diagram below:
|
||||
|
||||
Message -> Channel -> ServiceActivator -> QueueChannel
|
||||
|
||||
To run the sample simply execute **HelloWorldApp** in package **org.springframework.integration.samples.helloworld**. You can also execute that class using the [Exec Maven Plugin](http://mojo.codehaus.org/exec-maven-plugin/):
|
||||
|
||||
$ mvn clean package exec:java -P hello
|
||||
|
||||
You should see the following output:
|
||||
|
||||
INFO : org.springframework.integration.samples.helloworld.HelloWorldApp - ==> HelloWorldDemo: Hello World
|
||||
|
||||
## Poller Application
|
||||
|
||||
This simple application will print out the current system time twice every 20 seconds.
|
||||
|
||||
More specifically, an **Inbound Channel Adapter** polls for the current system time 2 times every 20 seconds (20000 milliseconds). The resulting message contains as payload the time in milliseconds and the message is sent to a **Logging Channel Adapter**, which will print the time to the command prompt.
|
||||
|
||||
To run the sample simply execute **PollerApp** in package **org.springframework.integration.samples.helloworld**. You can also execute that class using the [Exec Maven Plugin](http://mojo.codehaus.org/exec-maven-plugin/):
|
||||
|
||||
$ mvn clean package exec:java -P poller
|
||||
|
||||
You should see output like the following:
|
||||
|
||||
INFO : org.springframework.integration.samples.helloworld - 1328892135471
|
||||
INFO : org.springframework.integration.samples.helloworld - 1328892135524
|
||||
|
||||
To run sample simply execute a test case in the **org.springframework.integration.samples.helloworld** package.
|
||||
@@ -12,7 +12,24 @@
|
||||
<spring.integration.version>2.1.0.RELEASE</spring.integration.version>
|
||||
<log4j.version>1.2.16</log4j.version>
|
||||
<junit.version>4.10</junit.version>
|
||||
<java.main.class>org.springframework.integration.samples.helloworld.HelloWorldApp</java.main.class>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>hello</id>
|
||||
<properties>
|
||||
<java.main.class>org.springframework.integration.samples.helloworld.HelloWorldApp</java.main.class>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>poller</id>
|
||||
<properties>
|
||||
<java.main.class>org.springframework.integration.samples.helloworld.PollerApp</java.main.class>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
@@ -45,6 +62,14 @@
|
||||
<showDeprecation>false</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2</version>
|
||||
<configuration>
|
||||
<mainClass>${java.main.class}</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.springframework.integration.samples.helloworld;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
public class DelayerApp {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) throws Exception{
|
||||
new ClassPathXmlApplicationContext("META-INF/spring/integration/delay.xml");
|
||||
System.in.read();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.samples.helloworld;
|
||||
|
||||
/**
|
||||
* Simple POJO to be referenced from a Service Activator.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class HelloService {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -33,20 +33,20 @@ import org.springframework.integration.message.GenericMessage;
|
||||
* <p>
|
||||
* View the configuration of the channels and the endpoint (a <service-activator/>
|
||||
* element) in 'helloWorldDemo.xml' within this same package.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
*/
|
||||
public class HelloWorldApp {
|
||||
|
||||
private static Logger logger = Logger.getLogger(HelloWorldApp.class);
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/helloWorldDemo.xml", HelloWorldApp.class);
|
||||
MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class);
|
||||
PollableChannel outputChannel = context.getBean("outputChannel", PollableChannel.class);
|
||||
inputChannel.send(new GenericMessage<String>("World"));
|
||||
logger.info("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload());
|
||||
logger.info("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.integration.samples.helloworld;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
public class PollerApp {
|
||||
|
||||
/**
|
||||
* Simple application that polls the current system time 2 times every
|
||||
* 20 seconds (20000 milliseconds).
|
||||
*
|
||||
* The resulting message contains the time in milliseconds and the message
|
||||
* is routed to a Logging Channel Adapter which will print the time to the
|
||||
* command prompt.
|
||||
*
|
||||
* @param args Not used.
|
||||
*/
|
||||
public static void main(String[] args) throws Exception{
|
||||
new ClassPathXmlApplicationContext("META-INF/spring/integration/delay.xml");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,8 @@
|
||||
<int:inbound-channel-adapter expression="T(java.lang.System).currentTimeMillis()" channel="logger">
|
||||
<int:poller fixed-delay="20000" max-messages-per-poll="2" />
|
||||
</int:inbound-channel-adapter>
|
||||
|
||||
<int:logging-channel-adapter id="logger"/>
|
||||
|
||||
|
||||
<int:logging-channel-adapter id="logger" logger-name="org.springframework.integration.samples.helloworld"/>
|
||||
|
||||
<task:executor id="executor" queue-capacity="20" pool-size="5-20"/>
|
||||
</beans>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
|
||||
|
||||
#log4j.category.org.springframework=WARN
|
||||
#log4j.category.org.springframework.integration.sftp=TRACE
|
||||
log4j.category.org.springframework=TRACE
|
||||
@@ -24,5 +24,5 @@
|
||||
<priority value="warn" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
|
||||
</log4j:configuration>
|
||||
Reference in New Issue
Block a user