Spring Integration in 10 minutes

The Spring Integration 1.0 GA release was announced 2 months ago at SpringOne Americas, and ever since I've been meaning to write a new, up-to-date "getting started" blog post. Well, the beginning of the year is always a busy time, so my goal is to provide a hands-on example with 10 steps. Each step should take roughly one minute… unless you stop to think
. So, without further ado, here we go!
Step 1: Download the Spring Integration distribution
You can grab the latest version (1.0.1 at the time I'm writing this) here:
http://www.springsource.com/download/community?project=Spring%20Integration
Once the download completes, unzip the file. You will see a 'dist' directory containing the JARs that comprise the Spring Integration project. You will also see a 'lib' directory that contains dependencies.
Step 2: Create a project
I'll be using Eclipse for the example, but of course you could do this in another IDE. You can also use Maven or Ivy, but the example here is so simple, it's sufficient to just create a directory and add the JARs.
Create a new 'Java Project' (In the 'Package Explorer' view, right-click, then 'New -> Java Project'), and create a 'lib' directory within that. Then, copy the following JARs from the Spring Integration 'dist' and 'lib' directory into the project's 'lib'.
from dist:
- org.springframework.integration-1.0.1.RELEASE.jar
- org.springframework.integration-file-1.0.1.RELEASE.jar
from lib:
- com.springsource.org.aopalliance-1.0.0.jar
- com.springsource.org.apache.commons.logging-1.1.1.jar
- org.springframework.aop-2.5.6.A.jar
- org.springframework.beans-2.5.6.A.jar
- org.springframework.context-2.5.6.A.jar
- org.springframework.core-2.5.6.A.jar
- org.springframework.transaction-2.5.6.A.jar
Refresh the 'lib' directory in Eclipse (hit F5) and add those JARs to the build-path (select the JARs, right-click, and choose "Build Path -> Add to Build Path"). Finally, create a 'blog' package in the 'src' directory.
Step 3: Begin the Spring configuration
If you're using Spring IDE or the SpringSource Tool Suite, you can add Spring project nature and just right-click the 'blog' package to create a new bean definition file. Otherwise, just create the following and name it 'config.xml':
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
</beans>
We will add a single element for now. This defines a Message Channel that is backed by a Java in-memory queue and will hold up to 10 Messages at a time:
<si:queue capacity="10"/>
</si:channel>
Step 4: Define a Bootstrap Java class
Spring Integration components are simply embedded within any Spring ApplicationContext. Therefore, all we need to do is create one based on this configuration file. If running within a web-app, you could bootstrap with Spring's ContextLoaderListener, or if you run within dm Server, it will also handle this for you. For this simple example, we'll just create a main() method in a class called Bootstrap (in the 'blog' package):
public static void main(String[] args) {
new ClassPathXmlApplicationContext("blog/config.xml");
}
}
(At any point, to quickly resolve imports in Eclipse you can "organize imports" with Ctrl+Shift+O… or Command+Shift+O on a Mac).
Step 5: Send and receive a Spring Integration Message
Now, we can access the channel from the context and send a Message. Because we don't have any subscribers yet (coming in the next couple steps), we will also receive from the same channel. This will prove that everything is configured properly. Modify the main() method so it looks like this:
ApplicationContext context = new ClassPathXmlApplicationContext("blog/config.xml");
PollableChannel channel = (PollableChannel) context.getBean("channel");
channel.send(new StringMessage("Spring Integration rocks"));
Message<?> reply = channel.receive();
System.out.println("received: " + reply);
}
When you run that, you should see the result of the Message's toString() method printed to the console.
Step 6: Create a Service
Spring Integration aims to be non-invasive. That means we will now gradually modify the sample so that you have no code directly tied to the framework. The first thing we'll do, however, is add a POJO Service that will become a subscriber for our messages. This example is going to simply convert the String to uppercase and add some exclamation points:
Step 7: Add the Service to the Spring configuration
The Service can be added as just a regular bean:
Next, we'll add a "Service Activator" to connect the Service bean to input and output channels. We need to rename the existing "channel" to "output", and then add a simple non-buffering channel for input. The entire configuration should look like this:
<si:channel id="output">
<si:queue capacity="10"/>
</si:channel>
<si:service-activator input-channel="input"
output-channel="output"
ref="shouter"
method="shout"/>
<bean id="shouter" class="blog.Shouter"/>
Step 8: Invoke the Service by sending a Message
Modify the main() method to send a Message to the input channel and to receive from the output channel. Notice that we're also modifying the dependency lookups and that the channels are cast to different types (the 'input' channel is non-buffering, hence it is not a PollableChannel like the output is):
ApplicationContext context = new ClassPathXmlApplicationContext("blog/config.xml");
MessageChannel input = (MessageChannel) context.getBean("input");
PollableChannel output = (PollableChannel) context.getBean("output");
input.send(new StringMessage("Spring Integration rocks"));
Message<?> reply = output.receive();
System.out.println("received: " + reply);
}
Step 9: Send the output to a File
Rather than polling for output in the main() method, we can send the result directly to a File by adding a Channel Adapter. First, you can remove the queue sub-element from the output channel, since polling will not be necessary:
Add the Channel Adapter. You can specify any existing directory, and on Windows you should include the drive letter (e.g. "C:/tmp"):
Next, you can update the Bootstrap's main() method to only send:
ApplicationContext context = new ClassPathXmlApplicationContext("blog/config.xml");
MessageChannel input = (MessageChannel) context.getBean("input");
input.send(new StringMessage("Spring Integration rocks"));
}
You also need to add the 'file' namespace to the XSD configuration. The top-level 'beans' element should look like this:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd">
Run the example, and you should see the output in a file with a ".msg" extension (you can add a filename-generator strategy, but that is beyond the scope of this post).
Step 10: Create a Gateway interface
The final step will achieve the goal of complete non-invasiveness. Rather than sending the Message to a Message Channel, it would be much cleaner to send a String as a parameter to a simple interface. Create the following interface within the 'blog' package:
Then, add the following element to your configuration:
Finally, use the Gateway in the main method instead of the channel. Now, you can simply pass a String:
ApplicationContext context = new ClassPathXmlApplicationContext("blog/config.xml");
Gateway gateway = (Gateway) context.getBean("gateway");
gateway.send("Spring Integration rocks");
}
Conclusion
Hopefully that provides a decent introduction to Spring Integration. The main point to take away is that you can easily create a dedicated integration layer that uses the non-invasive Spring programming model. The real value is apparent when you start adding multiple endpoints. Then, you may need to add filters, transformers, and routers.
Spring Integration provides much more than what this sample demonstrates. To learn more, check out the various projects within the 'org.springframework.integration.samples' module (sources are available in the 'src' directory of the distribution) and read through the Reference Documentation. Of course, you can find much more information on the Spring Integration Home Page.
Similar Posts
- Implementing Enterprise Integration Patterns part 0
- Spring Integration 1.0.3 Samples: just add Maven
- Spring Integration in Grails (Part 1)
- Spring Integration Samples
- AOP Context Binding With Named Pointcuts











Josh Long says:
Added on February 16th, 2009 at 2:58 pmAwesome post! Great work. This isn't some fancy JS widget or a web framework he's demoing. This is an architecture-healing middleware-type solution .. in 10 minutes! I don't know any other ESB I could get going (or even downloaded and installed) in 10 minutes!
Maybe a Maven archtetype would help things along even more? Give people a working default public static void main(String[] a) project OR a working web application with the flick of a command incantation. I'd definitely be happy to help here!
Peter Braswell says:
Added on February 18th, 2009 at 9:57 amI found this article very, very helpful! I will admit that it took me a little longer than 10 minutes to work through this but I got everything to run. You might consider a series of articles that build on this as a foundation. How, for example, would I start building up a work-flow system using this technology? Could I build something that used primitive constructs (polling, file-based) that eventually evolved into something more substantial? I would imagine this could be done and only the configuration would really change significantly. A real life example might be something like an basic insurance claim or something like that.
Best, Peter
Mark Fisher (blog author) says:
Added on February 18th, 2009 at 10:03 amPeter,
That's exactly what we plan to do. Obviously this particular sample is aimed at merely introducing the core concepts (e.g. message and channel). In future posts, we will add much more. As an example, the next post might add a Polling Consumer as a Channel Adapter for reading Files. Then, we can add transformation, routing, and more.
Thanks for the feedback!
Regards,
Mark
Jaro Kuruc says:
Added on February 25th, 2009 at 4:38 amHi, is there any milestone or nightly build based on Spring 3.0.0.M1?
Ivan says:
Added on February 26th, 2009 at 8:47 amThank you for good introduction to Spring integration. how would compare it to Camel? Per comment from Mr. Josh Long you should see Camel camel.apache.org. It is easy to get started. We use Spring with Camel and have good experience right away since more than one year. We build many applications for finance and trading. Camel provide many compnonents and easy api.
Hendy Irawan says:
Added on March 11th, 2009 at 5:22 amI second Ivan's query.
It would be very good to have a clear article (or just a comment reply) describing how Spring Integration compares to Apache Camel (and Mule). Are they competitors? Or complementary? What are their weakness and strengths? And why Spring introduce a(nother) integration library where there are already Apache Camel and/or Mule… instead of extending the existing libraries?
Thank you.
Mark Fisher (blog author) says:
Added on March 11th, 2009 at 10:03 am@Ivan, @Hendy:
A comparison blog or article is something that I am very interested in myself, and I intend to pursue that when I have time to do a thorough example-based side-by-side comparison. At the same time, I would be even more interested in feedback from less biased developers who have worked with both frameworks and can speak about pros and cons from the experience of developing real-world applications. I will be on the lookout for some candidates to do exactly that. For now, I'll just provide a quick reply on some of the topics you have raised.
First, the question of competing vs. complementing really depends on the situation. It doesn't typically make sense to use multiple frameworks targeted at the same domain for no good reason within a single project, so you do want to consider the best fit for an application. On the other hand, there may be strengths of two or more frameworks that can be used together. In that case, at least it's a conscious choice to include more than one. In the realm of enterprise integration, there is less of a barrier for this type of thing. For example, you can always use JMS or HTTP as a common gateway, or sometimes you can even use adapters that exist for that exact purpose. As an example of the latter, Camel provides adapters for connecting to a Spring Integration MessageChannel. Both Camel and Mule provide more adapters than Spring Integration does currently. We do have the Spring Extensions project for additional adapters, but the core is going to remain focused on mainstream connectivity (JMS, HTTP, Web Services, File, Mail).
Second, the key difference between Spring Integration and these other frameworks is the programming model itself. Hopefully, that is somewhat obvious on the surface, but a detailed comparison on that level is probably worthy of another blog or article of its own. For now, I will simply say that we chose to provide a MessageChannel interface as the primary decoupling component rather than logical channels expressed as URIs. We wanted to avoid the hard-coding of something like "jms" or "file" within code, and yet we also wanted to avoid programming in XML. Instead, with Spring Integration you use XML to *wire* channels and endpoints together. I tend to describe that as horizontal dependency injection for event-driven applications (as opposed to the vertical dependency injection across application layers).
Finally, the motivation for Spring Integration can be summarized in the following 3 points. We did not feel that any of the other frameworks adequately accomplished all of these goals:
#1: to provide support for enterprise integration components that are fully embedded within any Spring context (notice we don't have a bootstrap class, a subclass of the ApplicationContext, etc.) In other words, the Spring ApplicationContext *is* the Message Bus, and the integration logic can be implemented with POJOs (no direct usage of the Spring Integration API is required).
#2: to build as much as possible upon the proven core Spring foundation (JMS, Transactions, TaskExecutor, AOP, Component-scanning, etc).
#3: to integrate seamlessly with other Spring projects (Spring Security, Spring Web Services, Spring Batch, etc.) We have also been consciously focused on OSGi compatibility from the very beginning to facilitate deployment in dm Server (see Iwein's recent blog entry for more detail on that).
Hopefully that provides a bit of clarification.
Regards,
Mark
heina says:
Added on March 16th, 2009 at 1:31 pmHi Mark-
Do you have Polling Consumer as a Channel Adapter for receving MQ message examples posted? I am researching if PollingConsumer will be a solution for our project.
thx
heina
Mark Fisher (blog author) says:
Added on March 16th, 2009 at 1:49 pm@heina:
We do provide both Polling and Event-Driven Consumers for JMS. For more detail on the Polling Consumer for JMS, see the first example in the JMS chapter of the reference manual: http://static.springframework.org/spring-integration/reference/htmlsingle/spring-integration-reference.html#jms
heina says:
Added on March 18th, 2009 at 10:49 amHi mark-
thank you for the quick response.
I have difficulty to run those 'org.springframework.integration.samples' module. After reading this jms doc, I tried the jms adapter sample w/o changing any configuration. It gave me error pasting below. (the same for many other samples) I think it is my eclipse or project classpath setting but the error did not tell me much. There are many people having the same error when I google. But no fix posted yet. Anyway, after working with spring for 4 weeks, I found errors from spring is very clueless to me.
sorry to post it here.
p.s. I tried the "Fixing spring modules XSD errors in eclipse" article, still give me cvc-complex-type error.
Regarding connectionFactory, since my message is from websphere mq, is it true that I wont be able to use springframework class(org.springframework.jms.connection.CachingConnectionFactory) and have to use(org.apache.camel.component.jms.JmsComponent)?
——————————–
ARNING: Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 16 in XML document from class path resource [outboundChannelAdapter.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'stream:stdin-channel-adapter'.
Mark Fisher (blog author) says:
Added on March 20th, 2009 at 10:35 am@heina: I think you just need to add the JARs to your classpath (the JARs are in the 'dist' directory).
Also, you can definitely use Spring's CachingConnectionFactory with *any* implementation of ConnectionFactory as its target. However, if you are using WebSphere MQ, then you would most likely just use a 'jndi-lookup' element in your Spring configuration instead.
If you are still having problems, please post to the Spring Integration forum:
http://forum.springframework.org/forumdisplay.php?f=42
Regards,
Mark
jahid says:
Added on May 21st, 2009 at 4:59 ami have done till step 5. Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'channel' is defined
Mark Fisher (blog author) says:
Added on May 21st, 2009 at 6:22 am@jahid
I just noticed the code is no longer formatting correctly in the blog, so you are missing some of the configuration there (like the 'channel' element in step 3!). I will post back here as soon as this is resolved.
Regards,
Mark
Mark Fisher (blog author) says:
Added on May 21st, 2009 at 3:13 pm@jahid
As you can see, the code formatting has been fixed. Sorry for the confusion, and thank you for pointing it out. Now, you should be able to pick up where you left off with Step #3
Cheers,
Mark
jahid says:
Added on May 22nd, 2009 at 2:30 amHi mark !
Thanks for ur effort.
one more confusion. till step #8 i am able to run.
output:
received: [Payload=SPRING INTEGRATION ROCKS!!!][Headers={springintegration_timestamp=1242976367500, springintegration_id=977f2422-9e52-4885-b5bf-e2252324eb1b}]
but confusion in step #9
not writing to file.
my config.xml file:
Regards,
Jahid
Mark Fisher (blog author) says:
Added on May 22nd, 2009 at 9:47 am@jahid
Your XML was not escaped and therefore doesn't appear. Can you try reformatting (e.g. with < and >)?
jahid says:
Added on May 27th, 2009 at 6:16 amHi Mark,
Please find the below xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd">
<si:channel id="input"/>
<si:channel id="output"/>
<file:outbound-channel-adapter channel="output" directory="C:/SPRING_INTEGRATION_TEST_LOGS"/>
<si:service-activator input-channel="input" output-channel="output" ref="shouter" method="shout"/>
<bean id="shouter" class="src.blog.Shouter"/>
</beans>
Mark Fisher (blog author) says:
Added on May 28th, 2009 at 12:54 pm@jahid
Does that directory already exist? If not, go ahead and create it, then try again.
-Mark
jahid says:
Added on May 29th, 2009 at 1:44 amHi Mark,
directory exists.
actually it try to load the xml and after some time get some exception as follows:
>>start
May 29, 2009 12:04:11 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@54172f: display name [org.springframework.context.support.ClassPathXmlApplicationContext@54172f]; startup date [Fri May 29 12:04:11 IST 2009]; root of context hierarchy
May 29, 2009 12:04:11 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [src/blog/outputToFile/config.xml]
May 29, 2009 12:04:54 PM org.springframework.util.xml.SimpleSaxErrorHandler warning
WARNING: Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaWarning(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at src.blog.outputToFile.Bootstrap.main(Bootstrap.java:15)
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 15 in XML document from class path resource [src/blog/outputToFile/config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'file:outbound-channel-adapter'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at
package src.blog.outputToFile;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.message.GenericMessage;
public class Bootstrap {
public static void main(String[] args) {
try{
System.out.println(">>start");
ApplicationContext context = new ClassPathXmlApplicationContext("src/blog/outputToFile/config.xml");
System.out.println(">>start 1");
MessageChannel input = (MessageChannel) context.getBean("input");
boolean isSendSuccess = input.send(new StringMessage("Spring Integration Test"));
System.out.println(">>>>>isSendSuccess=" isSendSuccess);
}catch(Exception e){
e.printStackTrace();
}
}
}
Lakshmanan says:
Added on June 12th, 2009 at 11:05 amHi jahid,
Error
"cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'file:outbound-channel-adapter"
I able to reproduce this error when I remove
"http://www.springframework.org/schema/integration/file "
from the beans definition. Make sure you have this line in your config xml. As per the xml I saw above you have that already.
cpc says:
Added on September 9th, 2009 at 4:52 amwhen running step 9, an exception occured:
Caused by: java.lang.IllegalArgumentException: No poller has been defined for endpoint 'org.springframework.integration.config.ConsumerEndpointFactoryBean#0', and no default poller is available within the context.
Fixed by adding default poller into config.xml, e.g.
<si:poller max-messages-per-poll="1" id="defaultPoller"
default="true">
<si:interval-trigger interval="30000" />
</si:poller>
wh0 says:
Added on October 31st, 2009 at 8:58 pmSimple but excellent examples!!
Thanks…
Stephane says:
Added on November 5th, 2009 at 9:58 amThe Gateway object gateway doesn't know about a send(String) method… with version 1.0.3.RELEASE of SI.