3636import io .undertow .server .HttpServerExchange ;
3737import io .undertow .server .handlers .PathHandler ;
3838import io .undertow .server .handlers .ResponseCodeHandler ;
39- import io .undertow .server .handlers .proxy .LoadBalancingProxyClient ;
4039import io .undertow .server .handlers .proxy .ProxyCallback ;
4140import io .undertow .server .handlers .proxy .ProxyConnection ;
4241import io .undertow .server .handlers .proxy .ProxyHandler ;
42+ import io .undertow .server .handlers .proxy .SimpleProxyClientProvider ;
4343import io .undertow .servlet .handlers .ServletRequestContext ;
4444import io .undertow .util .AttachmentKey ;
4545import io .undertow .util .Headers ;
@@ -169,7 +169,7 @@ public synchronized void addMappings(Proxy proxy) {
169169 @ SuppressWarnings ("deprecation" )
170170 private synchronized String addMapping (Proxy proxy , String mapping , URI target ) {
171171 String prefixPath = getPrefixPath (proxy .getId (), mapping );
172- LoadBalancingProxyClient proxyClient = new LoadBalancingProxyClient ( ) {
172+ SimpleProxyClientProvider proxyClient = new SimpleProxyClientProvider ( target ) {
173173 @ Override
174174 public void getConnection (ProxyTarget target , HttpServerExchange exchange , ProxyCallback <ProxyConnection > callback , long timeout , TimeUnit timeUnit ) {
175175 try {
@@ -180,10 +180,14 @@ public void getConnection(ProxyTarget target, HttpServerExchange exchange, Proxy
180180 super .getConnection (target , exchange , callback , timeout , timeUnit );
181181 }
182182 };
183- proxyClient .setMaxQueueSize (100 );
184- proxyClient .addHost (target );
185183
186- pathHandler .addPrefixPath (prefixPath , new ProxyHandler (proxyClient , ResponseCodeHandler .HANDLE_404 ));
184+ ProxyHandler proxyHandler = ProxyHandler .builder ()
185+ .setProxyClient (proxyClient )
186+ .setNext (ResponseCodeHandler .HANDLE_404 )
187+ .setMaxConnectionRetries (2 )
188+ .build ();
189+
190+ pathHandler .addPrefixPath (prefixPath , proxyHandler );
187191 return prefixPath ;
188192 }
189193
0 commit comments