Search code examples
javaspringspring-integration

Sending request from tcp client to server with spring integration and receiving data from stored procedure


I'm a new in Spring Integration framework and want to realize some scheme.

Spring Tcp client -> Spring Tcp Server -> Database

Several clients periodically send their configuration and receive information from the database in response. The server contains some logic by calling several stored procedures in sequence. For example, the data from the DB cursor can be input parameters to another stored procedure.

Help me please, Is this framework suitable for such tasks ?

Do I understand correctly that I need to implement a TCP gateway in the client, a TCP gateway and a JDBC gateway in the server ?

And maybe you can tell what difficulties I will have to face with such an implementation?


Solution

  • Spring Integration with its loosely-coupled architecture based on messaging is really suitable for any tasks. Plus luckily there are already out-of-the-box components to help you to build the solution. And you are really on the right track: to send request and receive replies over TCP/IP you indeed need the pair of those gateways:

    https://docs.spring.io/spring-integration/docs/current/reference/html/ip.html#tcp-gateways

    And yes, the StoredProcOutboundGateway is exactly for use-case where we would like to perform some RDBMS stored procedure and get some result from there: https://docs.spring.io/spring-integration/docs/current/reference/html/jdbc.html#stored-procedure-outbound-gateway

    I don't see a reason, though, in calling several procedures sequentially from the application, where we can simply do that on DB side with one procedure all together.