You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Rohan Emmanuel <ro...@gmail.com> on 2023/01/20 10:18:05 UTC

connectionsPerRoute has no impact on Connection when using http component

hi,
In my camel route i am using http component to connect to a HTTP service, I
have the  connectionsPerRoute query parameters set on the url as per the
documentation. but I see that always 2 connections are established to the
HTTP service even though I am sending many concurrent requests to the route.

I added a couple of print statements to get pool stats for every
 connect() call, I always see 2 connections getting established, I also
verified there is always 2 number of connections in the ESTABLISHED state
on the HTTP service side.

PoolStats-->[total kept alive: 0; route allocated: 2 of 2; total allocated:
2 of 20]


in the PoolingHttpClientConnectionManager code, I see that the CPool is
initialized with defaultMaxPerRoute as 2.


    this.pool = new CPool((ConnFactory)new
InternalConnectionFactory(this.configData, connFactory), 2, 20,
timeToLive, timeUnit);


Shouldnt this be overridden with the connectionsPerRoute value? is
there any way to configure thie connections Per route configuration?

any help would be appreciated.


-- 
Regards,
Rohan Emmanuel

Re: connectionsPerRoute has no impact on Connection when using http component

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Try with a newer Camel version such as 3.20.1, or 3.18.x.
We do not support old Camel versions which are EOL.


On Thu, Jan 26, 2023 at 4:29 PM Rohan Emmanuel <ro...@gmail.com>
wrote:

> hi Claus,
> thanks for responding.
> i tried setting the connections per route configuration as a component
> option, but still, i see only 2 connections being established to HTTP
> service.
> these 2 connections are the httpClient library's default value. camel is
> not able to overwrite this. i am on camel 3.7.0.
>   i have added the component option below, can you please point out if I
> have missed out anything?
>
> <bean id="http" class="org.apache.camel.component.http.HttpComponent">
> <property name="maxTotalConnections" value="22"/>
> <property name="connectionsPerRoute" value="22"/>
> </bean>
>
> On Fri, Jan 20, 2023 at 4:03 PM Claus Ibsen <cl...@gmail.com> wrote:
>
> > Hi
> >
> > It looks like setDefaultMaxPerRoute is invoked later that changes this
> > value.
> > Also you should not use query parameter as the http client may be
> > already created if you use http component elsewhere, favour set the value
> > on the component level
> >
> > On Fri, Jan 20, 2023 at 11:18 AM Rohan Emmanuel <
> > rohan.emmanuel07@gmail.com>
> > wrote:
> >
> > > hi,
> > > In my camel route i am using http component to connect to a HTTP
> > service, I
> > > have the  connectionsPerRoute query parameters set on the url as per
> the
> > > documentation. but I see that always 2 connections are established to
> the
> > > HTTP service even though I am sending many concurrent requests to the
> > > route.
> > >
> > > I added a couple of print statements to get pool stats for every
> > >  connect() call, I always see 2 connections getting established, I also
> > > verified there is always 2 number of connections in the ESTABLISHED
> state
> > > on the HTTP service side.
> > >
> > > PoolStats-->[total kept alive: 0; route allocated: 2 of 2; total
> > allocated:
> > > 2 of 20]
> > >
> > >
> > > in the PoolingHttpClientConnectionManager code, I see that the CPool is
> > > initialized with defaultMaxPerRoute as 2.
> > >
> > >
> > >     this.pool = new CPool((ConnFactory)new
> > > InternalConnectionFactory(this.configData, connFactory), 2, 20,
> > > timeToLive, timeUnit);
> > >
> > >
> > > Shouldnt this be overridden with the connectionsPerRoute value? is
> > > there any way to configure thie connections Per route configuration?
> > >
> > > any help would be appreciated.
> > >
> > >
> > > --
> > > Regards,
> > > Rohan Emmanuel
> > >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>
>
> --
> Regards,
> Rohan Emmanuel
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: connectionsPerRoute has no impact on Connection when using http component

Posted by Rohan Emmanuel <ro...@gmail.com>.
hi Claus,
thanks for responding.
i tried setting the connections per route configuration as a component
option, but still, i see only 2 connections being established to HTTP
service.
these 2 connections are the httpClient library's default value. camel is
not able to overwrite this. i am on camel 3.7.0.
  i have added the component option below, can you please point out if I
have missed out anything?

<bean id="http" class="org.apache.camel.component.http.HttpComponent">
<property name="maxTotalConnections" value="22"/>
<property name="connectionsPerRoute" value="22"/>
</bean>

On Fri, Jan 20, 2023 at 4:03 PM Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> It looks like setDefaultMaxPerRoute is invoked later that changes this
> value.
> Also you should not use query parameter as the http client may be
> already created if you use http component elsewhere, favour set the value
> on the component level
>
> On Fri, Jan 20, 2023 at 11:18 AM Rohan Emmanuel <
> rohan.emmanuel07@gmail.com>
> wrote:
>
> > hi,
> > In my camel route i am using http component to connect to a HTTP
> service, I
> > have the  connectionsPerRoute query parameters set on the url as per the
> > documentation. but I see that always 2 connections are established to the
> > HTTP service even though I am sending many concurrent requests to the
> > route.
> >
> > I added a couple of print statements to get pool stats for every
> >  connect() call, I always see 2 connections getting established, I also
> > verified there is always 2 number of connections in the ESTABLISHED state
> > on the HTTP service side.
> >
> > PoolStats-->[total kept alive: 0; route allocated: 2 of 2; total
> allocated:
> > 2 of 20]
> >
> >
> > in the PoolingHttpClientConnectionManager code, I see that the CPool is
> > initialized with defaultMaxPerRoute as 2.
> >
> >
> >     this.pool = new CPool((ConnFactory)new
> > InternalConnectionFactory(this.configData, connFactory), 2, 20,
> > timeToLive, timeUnit);
> >
> >
> > Shouldnt this be overridden with the connectionsPerRoute value? is
> > there any way to configure thie connections Per route configuration?
> >
> > any help would be appreciated.
> >
> >
> > --
> > Regards,
> > Rohan Emmanuel
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


-- 
Regards,
Rohan Emmanuel

Re: connectionsPerRoute has no impact on Connection when using http component

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

It looks like setDefaultMaxPerRoute is invoked later that changes this
value.
Also you should not use query parameter as the http client may be
already created if you use http component elsewhere, favour set the value
on the component level

On Fri, Jan 20, 2023 at 11:18 AM Rohan Emmanuel <ro...@gmail.com>
wrote:

> hi,
> In my camel route i am using http component to connect to a HTTP service, I
> have the  connectionsPerRoute query parameters set on the url as per the
> documentation. but I see that always 2 connections are established to the
> HTTP service even though I am sending many concurrent requests to the
> route.
>
> I added a couple of print statements to get pool stats for every
>  connect() call, I always see 2 connections getting established, I also
> verified there is always 2 number of connections in the ESTABLISHED state
> on the HTTP service side.
>
> PoolStats-->[total kept alive: 0; route allocated: 2 of 2; total allocated:
> 2 of 20]
>
>
> in the PoolingHttpClientConnectionManager code, I see that the CPool is
> initialized with defaultMaxPerRoute as 2.
>
>
>     this.pool = new CPool((ConnFactory)new
> InternalConnectionFactory(this.configData, connFactory), 2, 20,
> timeToLive, timeUnit);
>
>
> Shouldnt this be overridden with the connectionsPerRoute value? is
> there any way to configure thie connections Per route configuration?
>
> any help would be appreciated.
>
>
> --
> Regards,
> Rohan Emmanuel
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2