@@ -110,19 +110,41 @@ public ReactorNettyTcpClient(String host, int port, ReactorNettyCodec<P> codec)
110
110
this .channelGroup = new DefaultChannelGroup (ImmediateEventExecutor .INSTANCE );
111
111
this .loopResources = LoopResources .create ("tcp-client-loop" );
112
112
this .poolResources = ConnectionProvider .elastic ("tcp-client-pool" );
113
+ this .codec = codec ;
113
114
114
115
this .tcpClient = TcpClient .create (this .poolResources )
115
116
.host (host ).port (port )
116
117
.runOn (this .loopResources , false )
117
118
.doOnConnected (conn -> this .channelGroup .add (conn .channel ()));
119
+ }
118
120
121
+ /**
122
+ * A variant of {@link #ReactorNettyTcpClient(String, int, ReactorNettyCodec)}
123
+ * that still manages the lifecycle of the {@link TcpClient} and underlying
124
+ * resources, but allows for direct configuration of other properties of the
125
+ * client through a {@code Function<TcpClient, TcpClient>}.
126
+ * @param clientConfigurer the configurer function
127
+ * @param codec for encoding and decoding the input/output byte streams
128
+ * @since 5.1.3
129
+ * @see org.springframework.messaging.simp.stomp.StompReactorNettyCodec
130
+ */
131
+ public ReactorNettyTcpClient (Function <TcpClient , TcpClient > clientConfigurer , ReactorNettyCodec <P > codec ) {
132
+ Assert .notNull (codec , "ReactorNettyCodec is required" );
133
+
134
+ this .channelGroup = new DefaultChannelGroup (ImmediateEventExecutor .INSTANCE );
135
+ this .loopResources = LoopResources .create ("tcp-client-loop" );
136
+ this .poolResources = ConnectionProvider .elastic ("tcp-client-pool" );
119
137
this .codec = codec ;
138
+
139
+ this .tcpClient = clientConfigurer .apply (TcpClient
140
+ .create (this .poolResources )
141
+ .runOn (this .loopResources , false )
142
+ .doOnConnected (conn -> this .channelGroup .add (conn .channel ())));
120
143
}
121
144
122
145
/**
123
146
* Constructor with an externally created {@link TcpClient} instance whose
124
147
* lifecycle is expected to be managed externally.
125
- *
126
148
* @param tcpClient the TcpClient instance to use
127
149
* @param codec for encoding and decoding the input/output byte streams
128
150
* @see org.springframework.messaging.simp.stomp.StompReactorNettyCodec
0 commit comments