diff --git a/README.md b/README.md index 5bce4e6b..946f5c4b 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ This category targets developers who are already more familiar with the Spring I * **rest-http** - This sample demonstrates how to send an HTTP request to a Spring Integration's HTTP service while utilizing Spring Integration's new HTTP Path usage. This sample also uses Spring Security for HTTP Basic authentication. With HTTP Path facility, the client program can send requests with URL Variables. * **stored-procedures-derby** Provides an example of the stored procedure Outbound Gateway using *[Apache Derby](http://db.apache.org/derby/)* * **stored-procedures-oracle** Provides an example of the stored procedure Outbound Gateway using *ORACLE XE* +* **monitoring** The project used in the *[Spring Integration Management and Monitoring Webinar](http://www.springsource.org/node/3598)* Also available on the *[SpringSourceDev YouTube Channel](http://www.youtube.com/SpringSourceDev)* ## Advanced diff --git a/intermediate/monitoring/README.md b/intermediate/monitoring/README.md index 43a13e02..a780fffd 100644 --- a/intermediate/monitoring/README.md +++ b/intermediate/monitoring/README.md @@ -3,7 +3,25 @@ Spring Integration - Monitoring This application demonstrates managing and monitoring Spring Integration Applications. -It was used in the webinar here TBD. +It is based on the STS 'Spring Integration Project (war)' template project, available using + +New... | Spring Template Project + +It was used in the "Managing and Monitoring Spring Integration" webinar available +on the SpringSource Developer YouTube Channel http://www.youtube.com/SpringSourceDev + +If you wish to see the changes made during the webinar, please use the following git command: + +git log -p <The commit titled 'Webinar End State'> + + +To run the sample, in STS, use Run As... | Run on Server + +and then use VisualVM/JConsole to explore the MBeans. + +The twitter search results can be examined at http://localhost:8080/monitoring + +-------------------------------------------------------------------------------- For help please see the Spring Integration documentation: diff --git a/intermediate/monitoring/pom.xml b/intermediate/monitoring/pom.xml index 0f7a1e50..c98a738e 100644 --- a/intermediate/monitoring/pom.xml +++ b/intermediate/monitoring/pom.xml @@ -16,7 +16,7 @@ UTF-8 - 2.2.0.M2 + 2.2.0.M3 3.1.1.RELEASE 1.2.16 4.10 diff --git a/intermediate/monitoring/src/main/java/org/springframework/integration/service/TwitterService.java b/intermediate/monitoring/src/main/java/org/springframework/integration/service/TwitterService.java index 500f353b..ac4b9d61 100644 --- a/intermediate/monitoring/src/main/java/org/springframework/integration/service/TwitterService.java +++ b/intermediate/monitoring/src/main/java/org/springframework/integration/service/TwitterService.java @@ -44,6 +44,9 @@ public interface TwitterService { */ void stopTwitterAdapter(); + /** + * Performs an orderly shutdown of the Spring Integration twitter application. + */ void shutdown(); } diff --git a/intermediate/monitoring/src/main/java/_org/springframework/integration/PayloadAwareTimingInterceptor.java b/intermediate/monitoring/src/main/java/org/springintegration/PayloadAwareTimingInterceptor.java similarity index 93% rename from intermediate/monitoring/src/main/java/_org/springframework/integration/PayloadAwareTimingInterceptor.java rename to intermediate/monitoring/src/main/java/org/springintegration/PayloadAwareTimingInterceptor.java index df157f98..a50b78f2 100644 --- a/intermediate/monitoring/src/main/java/_org/springframework/integration/PayloadAwareTimingInterceptor.java +++ b/intermediate/monitoring/src/main/java/org/springintegration/PayloadAwareTimingInterceptor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package _org.springframework.integration; +package org.springintegration; import java.util.Map; import java.util.Map.Entry; @@ -27,6 +27,9 @@ import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.util.StopWatch; /** + * A sample channel interceptor that illustrates a technique to capture elapsed times + * based on message payload types. + * * @author Gary Russell * @since 2.2 * @@ -38,6 +41,11 @@ public class PayloadAwareTimingInterceptor extends ChannelInterceptorAdapter { private Map, Stats> statsMap = new ConcurrentHashMap, PayloadAwareTimingInterceptor.Stats>(); + /** + * + * @param classes An array of types for which statistics will be captured; if + * not supplied {@link Object} will be added as a catch-all. + */ public PayloadAwareTimingInterceptor(Class[] classes) { for (Class clazz : classes) { this.statsMap.put(clazz, new Stats()); diff --git a/intermediate/monitoring/src/main/java/_org/springframework/integration/service/impl/DefaultTwitterService.java b/intermediate/monitoring/src/main/java/org/springintegration/service/impl/DefaultTwitterService.java similarity index 93% rename from intermediate/monitoring/src/main/java/_org/springframework/integration/service/impl/DefaultTwitterService.java rename to intermediate/monitoring/src/main/java/org/springintegration/service/impl/DefaultTwitterService.java index fd1ec912..982b3b6a 100644 --- a/intermediate/monitoring/src/main/java/_org/springframework/integration/service/impl/DefaultTwitterService.java +++ b/intermediate/monitoring/src/main/java/org/springintegration/service/impl/DefaultTwitterService.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package _org.springframework.integration.service.impl; +package org.springintegration.service.impl; import java.util.Collection; import java.util.LinkedHashMap; @@ -25,21 +25,20 @@ import org.springframework.integration.Message; import org.springframework.integration.MessageChannel; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.model.TwitterMessage; -import org.springframework.integration.monitor.IntegrationMBeanExporter; import org.springframework.integration.service.TwitterService; import org.springframework.integration.support.MessageBuilder; import org.springframework.jmx.export.annotation.ManagedMetric; +import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.jmx.support.MetricType; -import org.springframework.social.twitter.api.Tweet; import org.springframework.stereotype.Service; /** * Implementation of the TwitterService interface. - * In the _org package because SI excludes all org.springframework.integration.* + * In the org.springintegration package because SI excludes all org.springframework.integration.* * classes from MBean export. */ @Service - +@ManagedResource public class DefaultTwitterService implements TwitterService { /** Holds a collection of polled Twitter messages */ diff --git a/intermediate/monitoring/src/main/resources/META-INF/spring/integration/spring-integration-context.xml b/intermediate/monitoring/src/main/resources/META-INF/spring/integration/spring-integration-context.xml index d95a8a91..5378aeed 100644 --- a/intermediate/monitoring/src/main/resources/META-INF/spring/integration/spring-integration-context.xml +++ b/intermediate/monitoring/src/main/resources/META-INF/spring/integration/spring-integration-context.xml @@ -12,22 +12,54 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration/twitter http://www.springframework.org/schema/integration/twitter/spring-integration-twitter.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - + + + + + + + + - - + + + + + + + + + + + Thread.sleep(1000) + payload + + + + - + + + + + java.lang.String + org.springframework.social.twitter.api.Tweet + + + diff --git a/intermediate/monitoring/src/main/webapp/META-INF/MANIFEST.MF b/intermediate/monitoring/src/main/webapp/META-INF/MANIFEST.MF index 254272e1..b3c893a3 100644 --- a/intermediate/monitoring/src/main/webapp/META-INF/MANIFEST.MF +++ b/intermediate/monitoring/src/main/webapp/META-INF/MANIFEST.MF @@ -1,3 +1,3 @@ Manifest-Version: 1.0 -Class-Path: +Class-Path: diff --git a/intermediate/monitoring/src/test/java/org/springframework/integration/SpringIntegrationTest.java b/intermediate/monitoring/src/test/java/org/springframework/integration/SpringIntegrationTest.java index 068b628f..bc782e8a 100644 --- a/intermediate/monitoring/src/test/java/org/springframework/integration/SpringIntegrationTest.java +++ b/intermediate/monitoring/src/test/java/org/springframework/integration/SpringIntegrationTest.java @@ -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. @@ -16,20 +16,19 @@ package org.springframework.integration; -import org.junit.Test; -import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** + * Run this class to run the sample from the command line. + * @author Gary Russell */ public class SpringIntegrationTest { - @Test - public void testSpringIntegrationContextStartup() throws Exception{ + public static void main(String[] args) throws Exception { - final ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml", SpringIntegrationTest.class); + new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml", SpringIntegrationTest.class); + System.out.println("Hit Enter to terminate"); System.in.read(); - } }