Skip to content

Latest commit

 

History

History
87 lines (52 loc) · 4.56 KB

File metadata and controls

87 lines (52 loc) · 4.56 KB

Spring Integration - Monitoring

This application demonstrates managing and monitoring Spring Integration Applications.

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.

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.

Alternatively, there is a simple main class SpringIntegrationTest.

2.2 Updates:

The application context now includes an example of <int-jmx:notification-publishing-channel-adapter/>, to which the tweets are published. You can navigate to the MBean - spring.application:type=TweetPublisher,name=tweeter, click the Notifications tab and then subscribe. You will then see the notifications.

An additional class NotificationListener is now included. It demonstrates the use of <int-jmx:notification-listening-channel-adapter> and <int-jmx:attribute-polling-channel-adapter>.

Also, it shows how to use an <int-jmx:operation-invoking-channel-adapter> to stop/start the dummyAdapter in the web application.

These adapters use a client connector to connect to the Twitter search web application to catch notifications published by it, polls the sendCount attribute of the twitterChannel. and invokes operations on the dummyAdapter.

You will need to update the credentials on the clientConnector in remote-monitor-context.xml to match your environment. If you are using STS, you can find the credentials in Servers | [server] | jmxremote.password. You can then run the NotificationListener's main method.

You should observe log output of the notifications as well as polling the channel's sendCount. Simply use the console to enter 'n' to stop and 'y' to start the adapter.

These changes show how you can create a sophisticated monitoring application using Spring Integration - it is important to understand that the application being monitored doesn't have to be a Spring or Spring Integration application - any application that exports MBeans can be monitored in this way.

Note:

Twitter now requires an authenticated user to perform searches. By default, this project now uses a dummy adapter to avoid having to configure the credentials. To use a real adapter, uncomment the spring.profiles.active context-param element in the web.xml.

To run the SpringIntegrationTest command-line application, use -Dspring.profiles.active=twitter command line argument in the launch configuration.

However, you will need to configure OAuth and set the values in the OAuth properties.

To use OAuth authentication/authorization with Twitter you must create a new Application on the Twitter Developer's site. Follow the directions below to create a new application and obtain the consumer keys and the access token:

  • Go to http://dev.twitter.com/
  • Log in to your account
  • Go to My applications.
  • Click on 'Create a new application' link and fill out all required fields on the form provided;
  • Submit the form.
  • If everything is successful you'll be presented with the 'Consumer Key' and 'Consumer Secret'.
  • Copy both values to a safe place.
  • On the same page you should see 'My Access Token' button on bottom of the page.
  • Click on it and you'll be presented with two more values: 'Access Token' and 'Access Token Secret'.
  • Copy these values to a safe place as well.

When done, fill out oauth.properties file so it looks similar to this.

twitter.oauth.consumerKey=4XzBPabcJQxyBzzzH3TrRQ
twitter.oauth.consumerSecret=ab2piKdMfPu8bVa3ab6DAIvIWEVZyMDL0RSEN2I8
twitter.oauth.accessToken=21691649-4XYZY5iJEOfz2A9qCFd9SjBRGb3HLmIm4HNE6AMv4
twitter.oauth.accessTokenSecret=AbRxUAvyNCtqQtvxFK8w5ZMtMj20KFhB6oEfTA0

NOTE: the above values are samples only.


For help please see the Spring Integration documentation:

http://www.springsource.org/spring-integration