I found a xml configured inbound adapter example what I do not fully understand. The configuration specifies a REST request setting request method, consumed format, etc.
I thought from the Spring Integration point of view the response should be much more important because the response is what is acutally feeding the message channel. Am I right?
The HTTP inbound adapter is used as message endpoint (actually a message startpoint) which calls a HTTP request - the URL of a REST service, let's say "http://myRest/transfer/next" - feeding a SI message channel with its result. Is that right?
It is either hard to find an example or to transform other examples into something which covers my needs. Even more as many examples are XML configured whereas I want to configure with Java or Dsl.
I am looking for an example where a REST service (which I will provide) is called which returns a JSON representation of TransferRequest
object of mine which is fed into the SI channel "transfer_next_channel" to get processed by the Message Handler.
My code approach is rather skeleton-like. What do I have to do?
@Bean
public IntegrationFlow httpInboundFlow() {
return IntegrationFlows
.from(Http.inboundChannelAdapter("http://myRest/transfer/next")
.requestMapping(r -> r
.methods(HttpMethod.GET)
.consumes("text/html"))
.requestPayloadType(TransferRequest.class)
.headerMapper(myHeaderMapper)
)
.channel("transfer_next_channel")
.get();
}
@Bean
@ServiceActivator(inputChannel = "transfer_next_channel")
public MessageHandler handler() {
return new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
System.out.println("myHandler: " + message.getPayload());
System.out.println("myHandler: " + message.getHeaders());
}
};
}
EDIT 1
The whole thing is to generate a data message of a person from persistent DB state to a String message via TCP/IP. At first there is the information what message is needed. It is provided via external REST service. The result is a TransferRequest
entity. From this the message has to be generated: another external REST service call to transform TransferRequest
into some kind of DataMessage
, the required data message. That result will be delivered via TCP/IP server as soon as a TCP/IP client has connected.
EDIT 2
The message channel is: starts with a request "http://myRest/transfer/next" to an external service, gets TransferRequest
(containing a personId
), push it as message into the channel, transformer/handler to request (another) external service "http://myRest/message/{personId}", gets DataMessage
, push it as message into another channel, handler to push the message into a TcpOutboundGateway to be received by an external system.