4

I am new to Spring Integration and I am considering using it in order to poll a directory for new files in order to process those files.

My question is: is Spring Integration some sort of daemon one can launch and that one can use in order to poll a directory?

Is this is possible can someone please direct me to relevant section of the official documentation on how to launch Spring Integration?

balteo
  • 23,602
  • 63
  • 219
  • 412

2 Answers2

3

All you need is to have a main method (or a WAR file if you want to deploy to Tomcat or another servlet container) that creates a Spring ApplicationContext (e.g. new ClassPathXmlApplicationContext("file-poller.xml"))

It can run with a cron trigger, fixed-rate or fixed-delay trigger.

JMX operations can be exposed on Spring Integration's File adapter (or any adapter) by simply adding a single config element (e.g. <mbean-export>).

Bottom line: you REALLY do not need an ESB if you simply want a File poller to run continuously. You can have a single small config file and one line of code in a main method.

Visit the samples for more info: https://github.com/springsource/spring-integration-samples (look under basic/file specifically)

Hope that helps, Mark

mfisher
  • 506
  • 2
  • 3
2

Spring Integration is a part of framework, its not a programm or daemon.

What you cant do — is to configure Spring Integration to poll a directory, lunch JVM with Spring onboard and poller will do what you want.

You can start with this blog post. More samples

Relevant section of documentation

vacuum
  • 2,273
  • 3
  • 20
  • 32
  • Thanks Vacuum. Do you recommend I use some sort of ESB together with Spring Integration in order to make sure the needed functionality (i.e. directory polling) is available 24 hours/day? – balteo Jul 27 '12 at 08:42
  • @balteo Spring Integration and ESB is about the same. See question: http://stackoverflow.com/questions/292860/spring-integration-as-embedded-alternative-to-standalone-esb – vacuum Jul 27 '12 at 08:51
  • I am just concerned about the plain bootstrap class described in the blog post. How do I monitor/administer it? – balteo Jul 27 '12 at 08:54
  • @balteo to monitor work of poller you need to add JMX support or similar. – vacuum Jul 27 '12 at 09:03
  • OK. I guess I am going to have a look into ESBs.. Thanks a lot for your support! – balteo Jul 27 '12 at 09:06
  • 1
    This is not a good reason to abandon S.I. for an ESB. There are many ways to run a java main() class as a system service. Take a look at Tanuki wrapper, for example. – Gary Russell Jul 27 '12 at 11:44