Reputation: 1227
I'm developing web app using Spring Integration to route my messages, but I have some problems with passing my header value. My message goes through router and service activator.
The header value is available in a routing method of my router so it seems to be ok. Let's assume that it is not a problem (I checked this by disabling my service activator).
When it comes to my service activator method the following error is thrown: "Failed to find any valid Message-handling methods named process on target class MyService."
my-spring-integration.xml
<channel id="route" />
<service-activator method="process" input-channel="route" ref="myService" output-channel="myOutputChannel" />
MyRouter.java
@Component
public class MyRouter {
public String router(String message, @Header("isValid") boolean isValid) {
// isValid is "true"
return "route";
}
}
MyService.java
@MessageEndpoint
@Transactional
public class MyService {
public void process(String message, @Header("isValid") boolean isValid) {
...
}
}
Why is that? Are headers values erased after routing? Or my configuration is wrong? I tried to add @ServiceActivator annotation to my process method, but it didn't help. Any help will be greatly appreciated.
Upvotes: 0
Views: 4363
Reputation: 1227
I'm working with legacy code and it was probably caused by old spring integration version. My application support '@Headers', but it doesn't support '@Header' annotation. @Header annotation was accepted in my router which is interface and not in my service activator which does not implement any interface. I suspect it was caused by old version of spring integration or cglib.
Upvotes: 0
Reputation: 7218
I would guess that this is caused by having an @Transactional
annotation on a Service which doesn't implement any interfaces.
Spring will implement the transactional logic using JDK dynamic proxies, these rely on proxied classes implementing suitable interfaces. There is a Spring blog about this here.
To fix this I would suggest that you create an interface called MyService with a single method called process. Then have you service implement this interface.
Upvotes: 1