Skip to content

cheesterx3/spring-int-tcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic tcp outbound gateway implementation

Description

Allows to create tcp outbound gateways using host/port according some expressions(for example from headers).

Also allows to cache connections to prevent register/unregister flows and beans in runtime.

This is just a simple implementation of single request/reply using dynamic registration integration flows

Includes

  • Dynamic tcp outbound gateway library
  • Dynamic tcp outbound autoconfigure

Usage

    private final DynamicTcpOutboundGatewaySpec outboundGatewaySpec;

    @Bean
    public IntegrationFlow serverRequestFlow() {
        return IntegrationFlows.from("serverInfoRequestChannel")
                .route(outboundGatewaySpec
                        .host("headers['host']").port("headers['port']")
                        .deserializer(deserializer)
                        .serializer(serializer)
                        .cacheable("!headers['host'].equals(\"127.0.0.1\")")
                        .connectTimeout(30)
                        .remoteTimeout(20_000L)                        
                        .responseChannelName("serverResponseChannel"))
                .get();
    }

    @Bean
    public IntegrationFlow serverResponseFlow() {
        return IntegrationFlows.from("serverResponseChannel")
                .transform(Transformers.objectToString())
                .transform(dataTransformer)
                .channel("serverInfoResponseChannel")
                .get();
    }

About

Spring tcp outbound gateway dynamic wrapper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages