Spring Integration - Calling Methods in Application Code

I have an outbound channel adapter where the corresponding configuration is shown below.

<int:outbound-channel-adapter channel="foo-fileChannel" ref="foo-handlerTarget" method="handleFeedFile"> <int:poller fixed-delay="5000" receive-timeout="1000" max-messages-per-poll="10" /> </int:outbound-channel-adapter> <int:channel id="foo-fileChannel"> <int:queue /> </int:channel> <bean id="foo-handlerTarget" class="com.abc.FooFeedHandlerImpl"> <property name="fooDescriptorFile" value="${feed.foo.fooDescriptorFile}" /> <property name="fileIdRegex" ref="foo-fileRegex" /> <property name="processId" value="${feed.processId}" /> <property name="workingLocation" value="${feed.foo.workingLocation}" /> <property name="remoteLocation" value="${feed.foo.remoteLocation}" /> <property name="stalenessThreshold" value="${feed.foo.stalenessThreshold}" /> </bean> 

And in FooFeedHandlerImpl ...

 public void handleFeedFile(File retrievedFile) { handleFeedFile(retrievedFile, null); } public void handleFeedFile(File retrievedFile, String processKey) { if (isHandlerForFileName(retrievedFile.getName())) { processFeed(retrievedFile, processKey); } } 

Questions:

What method handleFeedFile is called by the channel adapter?

When I call a method in the application code using Spring integration, how are the method parameters determined?

Thanks for any help!

Edit:

I executed my process locally (I downloaded the local SFTP server - http://www.coreftp.com/server/index.html ) and determined that the handleFeedFile(File file) method was called.

+2
java spring spring-integration enterprise-integration
source share
2 answers

You probably want to refer to the F.6 Message Matching Rules and Agreements .

Several parameters could create a lot of ambiguity regarding the definition of matching. A general tip is to annotate the parameters of your method with @Payload and / or @ Header / @ headers. The following are some examples of ambiguous conditions that give rise to an Exception.

and

Several methods:

Message handlers with several methods are displayed based on the same rules as described above, however some scenarios may still look confusing.

If you cannot comment on your target methods, you can use the SpEL expression to call your intended method:

3.3.2 Outbound adapter setup

Like many other Spring integration components, they also provide support for evaluating SpEL expressions. To use SpEL, specify the expression string through the 'expression' attribute instead of providing the 'ref' and 'method' attributes that are used to invoke the method on the bean. When an expression is evaluated, it follows the same contract as the invocation method, where: the expression for the will generates a message at any time when the result of the evaluation is a nonzero value, while the expression for a should be equivalent to the invocation return method.

+2
source share

According to the Spring integration documentation , POJO (bean foo-handlerTarget ) in your case will be called using the Message object containing the payload. Have you executed your code? I expect it to NoSuchMethodError .

You need

 public void handleFeedFile(Message<?> message); 

method.

+1
source share

All Articles