i try to develop a SpringBoot Rest Server with Spring Integration HTTP -> inboundGateway.
I've an Controller, annotated with "@Controller" and "@RequestMapping" and try to create following flow:
GET Request "/" -> Channel: httpRequestChannel -> Run IndexController -> Channel: httpReplyChannel -> back to Browser
But it's not working.
My Integration Xml:
<int:channel id="httpRequestChannel">
<int:interceptors>
<int:wire-tap channel="logHttpRequestChannel" />
</int:interceptors>
</int:channel>
<int:channel id="httpReplyChannel">
<int:interceptors>
<int:wire-tap channel="logHttpReplyChannel" />
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="logHttpRequestChannel" level="INFO" logger-name="httpRequestChannel" log-full-message="true" />
<int:logging-channel-adapter id="logHttpReplyChannel" level="INFO" logger-name="httpReplyChannel" log-full-message="true" />
<int-http:inbound-gateway id="inboundGateway"
request-channel="httpRequestChannel" reply-channel="httpReplyChannel"
auto-startup="true" supported-methods="GET" path="/">
<int-http:request-mapping produces="application/json" />
</int-http:inbound-gateway>
The error is:
Dispatcher has no subscribers
But in my opinion, the controller should be an subscriber via the RequestMapping Annotation...
I upload a sample github project: https://github.com/marcelalburg/spring-boot-integration-rest-server
Thanks for you help Marcel
UPDATE
Hello,
i see something in the documentation:
The parsing of the HTTP Inbound Gateway or the HTTP Inbound Channel Adapter registers an integrationRequestMappingHandlerMapping bean of type IntegrationRequestMappingHandlerMapping, in case there is none registered, yet. This particular implementation of the HandlerMapping delegates its logic to the RequestMappingInfoHandlerMapping. The implementation provides similar functionality as the one provided by the org.springframework.web.bind.annotation.RequestMapping annotation in Spring MVC.
So, i changed following:
<int-http:inbound-gateway id="indexGateway"
request-channel="httpRequestChannel" reply-channel="httpReplyChannel"
auto-startup="true" supported-methods="GET" path="/, /test" reply-timeout="100" />
and my controller
@ServiceActivator( inputChannel = "httpRequestChannel", outputChannel = "httpReplyChannel" )
@RequestMapping( value = "/", method = RequestMethod.GET, produces = "application/json" )
public String testGateway( LinkedMultiValueMap payload, @Headers Map<String, Object> headerMap )
{
// IntegrationRequestMappingHandlerMapping
System.out.println( "Starting process the message [reciveing]" );
return "{HelloMessage: \"Hello\"}";
}
@ServiceActivator( inputChannel = "httpRequestChannel", outputChannel = "httpReplyChannel" )
@RequestMapping( value = "/test", method = RequestMethod.GET, produces = "application/json" )
public String testGateway2( LinkedMultiValueMap payload, @Headers Map<String, Object> headerMap )
{
// IntegrationRequestMappingHandlerMapping
System.out.println( "Starting process the message [reciveing]" );
return "{HelloMessage: \"Test\"}";
}
now, i get an response but it returns randomized "Test" and "Hello" ...
Thanks