You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Cappa Roberto <ro...@guest.telecomitalia.it> on 2010/07/13 16:59:00 UTC

Dynamically change HTTP endpoint parameters

Hi,

I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?

Thanks.

Re: R: Dynamically change HTTP endpoint parameters

Posted by Willem Jiang <wi...@gmail.com>.
Just one more comment.
I guess the http endpoint url doesn't take the proxy parameter into 
account. So camel context just return the first endpoint from the the 
endpoint cache which uses the endpoint url as the key.

Willem

Cappa Roberto wrote:
> The recipient list was one of choice I've evaluated, but there is another problem: when I create a dynamic recipient list, for example http://host:port?porxyHost=proxy1 it works. In the next route execution (without restarting the context) I set http://host:port?porxyHost=proxy2, but the route continues to use the old one (proxy1). Is there a sort of component caching, that store component and options and reuse it in the next execution?
> 
> Thanks
> ________________________________________
> Da: Claus Ibsen [claus.ibsen@gmail.com]
> Inviato: martedì 13 luglio 2010 21.43
> A: users@camel.apache.org
> Oggetto: Re: Dynamically change HTTP endpoint parameters
> 
> Hi
> 
> I do not know if the Apache HTTP Client can change proxy value at runtime?
> 
> You can with Camel stop the HTTP producer, adjust the http endpoint or
> create a new http endpoint, and then create a new http producer using
> that endpoint.
> 
> Or use recipient list EIP which can use dynamic endpoints.
> 
> 
> On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
> <ro...@guest.telecomitalia.it> wrote:
>> Hi,
>>
>> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>>
>> Thanks.
> 
> 
> 
> --
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 


Re: R: R: Dynamically change HTTP endpoint parameters

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

The configure is per HttpEndpoint, it can work for the concurrent
requests :)

Willem
 ----------------------------------
   Apache Camel, Apache CXF committer
   Open Source Integration http://www.fusesource.com
   Blog http://willemjiang.blogspot.com
   Tiwtter http://twitter.com/willemjiang


Cappa Roberto wrote:
> Hi, thanks for the solution.
> 
> A last question:
> 
> I've tryed with the 2.5-SNAPSHOT and it works, also if I don't create a new HTTP component from code, but only using a different http url dynamically loaded with recipientList. This is the code:
> 
> from(FROM_URL)
>         .process(new Processor() {
>             public void process(Exchange exc) throws Exception {
>                 String username = ((HttpServletRequest)exc.getIn().getBody(HttpServletRequest.class)).getParameter("username");
>                 String password = ((HttpServletRequest)exc.getIn().getBody(HttpServletRequest.class)).getParameter("password");
>                 
>                //Setting final endpoint with dynamic proxy username/password, read from user input
>                 exc.getIn().setHeader("FinalEndpoint", 
>                         "http:/host:port/CB?proxyHost=proxy&proxyPort=port&proxyAuthMethod=Basic&proxyAuthUsername="+username+"&proxyAuthPassword=" + password);
>                 
>             }
>         })
>         .recipientList(header("FinalEndpoint"));
> 
> The question is: does it work also in case of concurrent requests? I've the suspect that in this case there is only one http component, reconfigured at runtime. Is this solution safe in concurrent case? Or is it preferrable to create new "httpX" components with a progressive 'X' in each call, in order to avoid the reuse of the same component?
> 
> Thanks.
> 
> ________________________________________
> Da: Willem Jiang [willem.jiang@gmail.com]
> Inviato: sabato 17 luglio 2010 13.15
> A: Willem Jiang
> Cc: users@camel.apache.org
> Oggetto: Re: R: Dynamically change HTTP endpoint parameters
> 
> FYI,the patch of CAMEL-2950 is applied into camel trunk, please check
> out the latest Camel 2.5-SNAPSHOT to verify the fix :)
> 
> Willem
> ----------------------------------
>   Apache Camel, Apache CXF committer
>   Open Source Integration http://www.fusesource.com
>   Blog http://willemjiang.blogspot.com
>   Tiwtter http://twitter.com/willemjiang
> 
> Willem Jiang wrote:
>> Yes, they are the same problem.
>> Current camel-http component can't deal with the address part rightly.
>> It should skip the URI which protocal part is not start with http: or
>> https, in this way we could register a customer protocal name for it.
>>
>> I just create a JIRA[1] for it.
>>
>> [1]https://issues.apache.org/activemq/browse/CAMEL-2950
>>
>> Willem
>> ----------------------------------
>> Apache Camel, Apache CXF committer
>> Open SOA http://www.fusesource.com
>> Blog http://willemjiang.blogspot.com
>> Tiwtter http://twitter.com/willemjiang
>>
>> Cappa Roberto wrote:
>>> The two versions:
>>>
>>> HttpComponent httpComponent = new HttpComponent();
>>>         getContext().addComponent("http2", httpComponent);
>>>
>>>
>>> or
>>> getContext().addComponent("http2", getContext().getComponent("http"));
>>>
>>> have the same behaviour when the endpoint is used (the  "unsupported
>>> protocol: 'http2'" exception). Probably there is another problem.
>>>
>>> Thanks
>>>
> 


R: R: Dynamically change HTTP endpoint parameters

Posted by Cappa Roberto <ro...@guest.telecomitalia.it>.
Hi, thanks for the solution.

A last question:

I've tryed with the 2.5-SNAPSHOT and it works, also if I don't create a new HTTP component from code, but only using a different http url dynamically loaded with recipientList. This is the code:

from(FROM_URL)
        .process(new Processor() {
            public void process(Exchange exc) throws Exception {
                String username = ((HttpServletRequest)exc.getIn().getBody(HttpServletRequest.class)).getParameter("username");
                String password = ((HttpServletRequest)exc.getIn().getBody(HttpServletRequest.class)).getParameter("password");
                
               //Setting final endpoint with dynamic proxy username/password, read from user input
                exc.getIn().setHeader("FinalEndpoint", 
                        "http:/host:port/CB?proxyHost=proxy&proxyPort=port&proxyAuthMethod=Basic&proxyAuthUsername="+username+"&proxyAuthPassword=" + password);
                
            }
        })
        .recipientList(header("FinalEndpoint"));

The question is: does it work also in case of concurrent requests? I've the suspect that in this case there is only one http component, reconfigured at runtime. Is this solution safe in concurrent case? Or is it preferrable to create new "httpX" components with a progressive 'X' in each call, in order to avoid the reuse of the same component?

Thanks.

________________________________________
Da: Willem Jiang [willem.jiang@gmail.com]
Inviato: sabato 17 luglio 2010 13.15
A: Willem Jiang
Cc: users@camel.apache.org
Oggetto: Re: R: Dynamically change HTTP endpoint parameters

FYI,the patch of CAMEL-2950 is applied into camel trunk, please check
out the latest Camel 2.5-SNAPSHOT to verify the fix :)

Willem
----------------------------------
  Apache Camel, Apache CXF committer
  Open Source Integration http://www.fusesource.com
  Blog http://willemjiang.blogspot.com
  Tiwtter http://twitter.com/willemjiang

Willem Jiang wrote:
> Yes, they are the same problem.
> Current camel-http component can't deal with the address part rightly.
> It should skip the URI which protocal part is not start with http: or
> https, in this way we could register a customer protocal name for it.
>
> I just create a JIRA[1] for it.
>
> [1]https://issues.apache.org/activemq/browse/CAMEL-2950
>
> Willem
> ----------------------------------
> Apache Camel, Apache CXF committer
> Open SOA http://www.fusesource.com
> Blog http://willemjiang.blogspot.com
> Tiwtter http://twitter.com/willemjiang
>
> Cappa Roberto wrote:
>> The two versions:
>>
>> HttpComponent httpComponent = new HttpComponent();
>>         getContext().addComponent("http2", httpComponent);
>>
>>
>> or
>> getContext().addComponent("http2", getContext().getComponent("http"));
>>
>> have the same behaviour when the endpoint is used (the  "unsupported
>> protocol: 'http2'" exception). Probably there is another problem.
>>
>> Thanks
>>

Re: R: Dynamically change HTTP endpoint parameters

Posted by Willem Jiang <wi...@gmail.com>.
FYI,the patch of CAMEL-2950 is applied into camel trunk, please check 
out the latest Camel 2.5-SNAPSHOT to verify the fix :)

Willem
----------------------------------
  Apache Camel, Apache CXF committer
  Open Source Integration http://www.fusesource.com
  Blog http://willemjiang.blogspot.com
  Tiwtter http://twitter.com/willemjiang

Willem Jiang wrote:
> Yes, they are the same problem.
> Current camel-http component can't deal with the address part rightly.
> It should skip the URI which protocal part is not start with http: or 
> https, in this way we could register a customer protocal name for it.
> 
> I just create a JIRA[1] for it.
> 
> [1]https://issues.apache.org/activemq/browse/CAMEL-2950
> 
> Willem
> ----------------------------------
> Apache Camel, Apache CXF committer
> Open SOA http://www.fusesource.com
> Blog http://willemjiang.blogspot.com
> Tiwtter http://twitter.com/willemjiang
> 
> Cappa Roberto wrote:
>> The two versions:
>>
>> HttpComponent httpComponent = new HttpComponent();
>>         getContext().addComponent("http2", httpComponent);
>>
>>
>> or
>> getContext().addComponent("http2", getContext().getComponent("http"));
>>
>> have the same behaviour when the endpoint is used (the  "unsupported 
>> protocol: 'http2'" exception). Probably there is another problem.
>>
>> Thanks
>>

Re: R: Dynamically change HTTP endpoint parameters

Posted by Willem Jiang <wi...@gmail.com>.
Yes, they are the same problem.
Current camel-http component can't deal with the address part rightly.
It should skip the URI which protocal part is not start with http: or 
https, in this way we could register a customer protocal name for it.

I just create a JIRA[1] for it.

[1]https://issues.apache.org/activemq/browse/CAMEL-2950

Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang

Cappa Roberto wrote:
> The two versions:
> 
> HttpComponent httpComponent = new HttpComponent();
>         getContext().addComponent("http2", httpComponent);
> 
> 
> or 
> 
> getContext().addComponent("http2", getContext().getComponent("http"));
> 
> have the same behaviour when the endpoint is used (the  "unsupported protocol: 'http2'" exception). Probably there is another problem.
> 
> Thanks
> 
> 
> ________________________________________
> Da: Claus Ibsen [claus.ibsen@gmail.com]
> Inviato: mercoledì 14 luglio 2010 10.57
> A: users@camel.apache.org
> Oggetto: Re: Dynamically change HTTP endpoint parameters
> 
> You most likely need to create a new HttpComponent using new
> constructor and not copy the old one.
> 
> HttpComponent http2 = new ...
> // and set stuff here
> 
> 
> 
> On Wed, Jul 14, 2010 at 10:18 AM, Cappa Roberto
> <ro...@guest.telecomitalia.it> wrote:
>> The solution you have suggested is clear, but after creating a new "http2" component in a custom processor, when I try to use it in a dynamic recipient list, the following exception is thrown:
>>
>> Any idea?
>>
>> (now, my final endpoint is dynamically built like this: "http2://host:port/....")
>>
>> Thanks
>>
>> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
>>        at org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:49)
>>        at org.apache.camel.component.http.HttpProducer.createMethod(HttpProducer.java:246)
>>        at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:63)
>>        at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>>        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>>        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>>        at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>>        at org.apache.camel.processor.MulticastProcessor.doProcess(MulticastProcessor.java:278)
>>        at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:240)
>>        at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:157)
>>        at org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:136)
>>        at org.apache.camel.processor.RecipientList.process(RecipientList.java:101)
>>        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>>        at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>>        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:97)
>>        at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>>        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>>        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>>        at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>>        at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
>>        at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:56)
>>        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>>        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>>        at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>>        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:97)
>>        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>>        at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>>        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>>        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>>        at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>>        at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
>>        at org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:70)
>>        at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>>        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>>        at org.apache.camel.component.http.CamelServlet.service(CamelServlet.java:71)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
>>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1216)
>>        at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:94)
>>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
>>        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:425)
>>        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:931)
>>        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
>>        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
>>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
>>        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
>>        at org.eclipse.jetty.server.Server.handle(Server.java:334)
>>        at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
>>        at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:992)
>>        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:541)
>>        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
>>        at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
>>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
>>        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
>>        at java.lang.Thread.run(Thread.java:619)
>> Caused by: java.lang.reflect.InvocationTargetException
>>        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>>        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>>        at org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:47)
>>        ... 56 more
>> Caused by: java.lang.IllegalStateException: unsupported protocol: 'http2'
>>        at org.apache.commons.httpclient.protocol.Protocol.lazyRegisterProtocol(Protocol.java:149)
>>        at org.apache.commons.httpclient.protocol.Protocol.getProtocol(Protocol.java:117)
>>        at org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:107)
>>        at org.apache.commons.httpclient.HttpMethodBase.setURI(HttpMethodBase.java:280)
>>        at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:220)
>>        at org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)
>>        ... 61 more
>>
>> ________________________________________
>> Da: Claus Ibsen [claus.ibsen@gmail.com]
>> Inviato: mercoledì 14 luglio 2010 9.57
>> A: users@camel.apache.org
>> Oggetto: Re: Dynamically change HTTP endpoint parameters
>>
>> Hi
>>
>> I have created a ticket to look into this in the future
>> https://issues.apache.org/activemq/browse/CAMEL-2945
>>
>> On Wed, Jul 14, 2010 at 9:53 AM, Claus Ibsen <cl...@gmail.com> wrote:
>>> On Wed, Jul 14, 2010 at 9:51 AM, Claus Ibsen <cl...@gmail.com> wrote:
>>>> Hi
>>>>
>>>> You most likely need to use a per http component for the different
>>>> proxy settings.
>>>> the proxy is generally per component based.
>>>>
>>>> So when you need a new proxy you just add a new http component
>>>> context.addComponent("http2", context.getComponent("http"));
>>>>
>>> And then set the proxy settings as you want on http2 component.
>>> You may also just create a new component which is more understandable
>>>
>>> HttpComponent http2 = new HttpComponent();
>>> http2.setProxyStuffHere
>>> context.addComponent("http2", http2);
>>>
>>> The current logic in http endpoint is not cut for using different
>>> proxy settings per endpoint.
>>>
>>>
>>>
>>>> And then use http2 in your endpoints.
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, Jul 14, 2010 at 8:38 AM, Cappa Roberto
>>>> <ro...@guest.telecomitalia.it> wrote:
>>>>> The recipient list was one of choice I've evaluated, but there is another problem: when I create a dynamic recipient list, for example http://host:port?porxyHost=proxy1 it works. In the next route execution (without restarting the context) I set http://host:port?porxyHost=proxy2, but the route continues to use the old one (proxy1). Is there a sort of component caching, that store component and options and reuse it in the next execution?
>>>>>
>>>>> Thanks
>>>>> ________________________________________
>>>>> Da: Claus Ibsen [claus.ibsen@gmail.com]
>>>>> Inviato: martedì 13 luglio 2010 21.43
>>>>> A: users@camel.apache.org
>>>>> Oggetto: Re: Dynamically change HTTP endpoint parameters
>>>>>
>>>>> Hi
>>>>>
>>>>> I do not know if the Apache HTTP Client can change proxy value at runtime?
>>>>>
>>>>> You can with Camel stop the HTTP producer, adjust the http endpoint or
>>>>> create a new http endpoint, and then create a new http producer using
>>>>> that endpoint.
>>>>>
>>>>> Or use recipient list EIP which can use dynamic endpoints.
>>>>>
>>>>>
>>>>> On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
>>>>> <ro...@guest.telecomitalia.it> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>>>>>>
>>>>>> Thanks.
>>>>>
>>>>>
>>>>> --
>>>>> Claus Ibsen
>>>>> Apache Camel Committer
>>>>>
>>>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>>> Open Source Integration: http://fusesource.com
>>>>> Blog: http://davsclaus.blogspot.com/
>>>>> Twitter: http://twitter.com/davsclaus
>>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
> 
> 
> 
> --
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 


R: Dynamically change HTTP endpoint parameters

Posted by Cappa Roberto <ro...@guest.telecomitalia.it>.
The two versions:

HttpComponent httpComponent = new HttpComponent();
        getContext().addComponent("http2", httpComponent);


or 

getContext().addComponent("http2", getContext().getComponent("http"));

have the same behaviour when the endpoint is used (the  "unsupported protocol: 'http2'" exception). Probably there is another problem.

Thanks


________________________________________
Da: Claus Ibsen [claus.ibsen@gmail.com]
Inviato: mercoledì 14 luglio 2010 10.57
A: users@camel.apache.org
Oggetto: Re: Dynamically change HTTP endpoint parameters

You most likely need to create a new HttpComponent using new
constructor and not copy the old one.

HttpComponent http2 = new ...
// and set stuff here



On Wed, Jul 14, 2010 at 10:18 AM, Cappa Roberto
<ro...@guest.telecomitalia.it> wrote:
> The solution you have suggested is clear, but after creating a new "http2" component in a custom processor, when I try to use it in a dynamic recipient list, the following exception is thrown:
>
> Any idea?
>
> (now, my final endpoint is dynamically built like this: "http2://host:port/....")
>
> Thanks
>
> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
>        at org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:49)
>        at org.apache.camel.component.http.HttpProducer.createMethod(HttpProducer.java:246)
>        at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:63)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>        at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at org.apache.camel.processor.MulticastProcessor.doProcess(MulticastProcessor.java:278)
>        at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:240)
>        at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:157)
>        at org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:136)
>        at org.apache.camel.processor.RecipientList.process(RecipientList.java:101)
>        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>        at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:97)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>        at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
>        at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:56)
>        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>        at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:97)
>        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>        at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
>        at org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:70)
>        at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at org.apache.camel.component.http.CamelServlet.service(CamelServlet.java:71)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1216)
>        at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:94)
>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
>        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:425)
>        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:931)
>        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
>        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
>        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
>        at org.eclipse.jetty.server.Server.handle(Server.java:334)
>        at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
>        at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:992)
>        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:541)
>        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
>        at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
>        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.reflect.InvocationTargetException
>        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>        at org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:47)
>        ... 56 more
> Caused by: java.lang.IllegalStateException: unsupported protocol: 'http2'
>        at org.apache.commons.httpclient.protocol.Protocol.lazyRegisterProtocol(Protocol.java:149)
>        at org.apache.commons.httpclient.protocol.Protocol.getProtocol(Protocol.java:117)
>        at org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:107)
>        at org.apache.commons.httpclient.HttpMethodBase.setURI(HttpMethodBase.java:280)
>        at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:220)
>        at org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)
>        ... 61 more
>
> ________________________________________
> Da: Claus Ibsen [claus.ibsen@gmail.com]
> Inviato: mercoledì 14 luglio 2010 9.57
> A: users@camel.apache.org
> Oggetto: Re: Dynamically change HTTP endpoint parameters
>
> Hi
>
> I have created a ticket to look into this in the future
> https://issues.apache.org/activemq/browse/CAMEL-2945
>
> On Wed, Jul 14, 2010 at 9:53 AM, Claus Ibsen <cl...@gmail.com> wrote:
>> On Wed, Jul 14, 2010 at 9:51 AM, Claus Ibsen <cl...@gmail.com> wrote:
>>> Hi
>>>
>>> You most likely need to use a per http component for the different
>>> proxy settings.
>>> the proxy is generally per component based.
>>>
>>> So when you need a new proxy you just add a new http component
>>> context.addComponent("http2", context.getComponent("http"));
>>>
>>
>> And then set the proxy settings as you want on http2 component.
>> You may also just create a new component which is more understandable
>>
>> HttpComponent http2 = new HttpComponent();
>> http2.setProxyStuffHere
>> context.addComponent("http2", http2);
>>
>> The current logic in http endpoint is not cut for using different
>> proxy settings per endpoint.
>>
>>
>>
>>> And then use http2 in your endpoints.
>>>
>>>
>>>
>>>
>>> On Wed, Jul 14, 2010 at 8:38 AM, Cappa Roberto
>>> <ro...@guest.telecomitalia.it> wrote:
>>>> The recipient list was one of choice I've evaluated, but there is another problem: when I create a dynamic recipient list, for example http://host:port?porxyHost=proxy1 it works. In the next route execution (without restarting the context) I set http://host:port?porxyHost=proxy2, but the route continues to use the old one (proxy1). Is there a sort of component caching, that store component and options and reuse it in the next execution?
>>>>
>>>> Thanks
>>>> ________________________________________
>>>> Da: Claus Ibsen [claus.ibsen@gmail.com]
>>>> Inviato: martedì 13 luglio 2010 21.43
>>>> A: users@camel.apache.org
>>>> Oggetto: Re: Dynamically change HTTP endpoint parameters
>>>>
>>>> Hi
>>>>
>>>> I do not know if the Apache HTTP Client can change proxy value at runtime?
>>>>
>>>> You can with Camel stop the HTTP producer, adjust the http endpoint or
>>>> create a new http endpoint, and then create a new http producer using
>>>> that endpoint.
>>>>
>>>> Or use recipient list EIP which can use dynamic endpoints.
>>>>
>>>>
>>>> On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
>>>> <ro...@guest.telecomitalia.it> wrote:
>>>>> Hi,
>>>>>
>>>>> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>>>>>
>>>>> Thanks.
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Dynamically change HTTP endpoint parameters

Posted by Claus Ibsen <cl...@gmail.com>.
You most likely need to create a new HttpComponent using new
constructor and not copy the old one.

HttpComponent http2 = new ...
// and set stuff here



On Wed, Jul 14, 2010 at 10:18 AM, Cappa Roberto
<ro...@guest.telecomitalia.it> wrote:
> The solution you have suggested is clear, but after creating a new "http2" component in a custom processor, when I try to use it in a dynamic recipient list, the following exception is thrown:
>
> Any idea?
>
> (now, my final endpoint is dynamically built like this: "http2://host:port/....")
>
> Thanks
>
> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
>        at org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:49)
>        at org.apache.camel.component.http.HttpProducer.createMethod(HttpProducer.java:246)
>        at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:63)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>        at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at org.apache.camel.processor.MulticastProcessor.doProcess(MulticastProcessor.java:278)
>        at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:240)
>        at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:157)
>        at org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:136)
>        at org.apache.camel.processor.RecipientList.process(RecipientList.java:101)
>        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>        at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:97)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>        at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
>        at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:56)
>        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>        at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:97)
>        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
>        at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
>        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
>        at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
>        at org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:70)
>        at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at org.apache.camel.component.http.CamelServlet.service(CamelServlet.java:71)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1216)
>        at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:94)
>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
>        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:425)
>        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:931)
>        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
>        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
>        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
>        at org.eclipse.jetty.server.Server.handle(Server.java:334)
>        at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
>        at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:992)
>        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:541)
>        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
>        at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
>        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.reflect.InvocationTargetException
>        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>        at org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:47)
>        ... 56 more
> Caused by: java.lang.IllegalStateException: unsupported protocol: 'http2'
>        at org.apache.commons.httpclient.protocol.Protocol.lazyRegisterProtocol(Protocol.java:149)
>        at org.apache.commons.httpclient.protocol.Protocol.getProtocol(Protocol.java:117)
>        at org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:107)
>        at org.apache.commons.httpclient.HttpMethodBase.setURI(HttpMethodBase.java:280)
>        at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:220)
>        at org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)
>        ... 61 more
>
> ________________________________________
> Da: Claus Ibsen [claus.ibsen@gmail.com]
> Inviato: mercoledì 14 luglio 2010 9.57
> A: users@camel.apache.org
> Oggetto: Re: Dynamically change HTTP endpoint parameters
>
> Hi
>
> I have created a ticket to look into this in the future
> https://issues.apache.org/activemq/browse/CAMEL-2945
>
> On Wed, Jul 14, 2010 at 9:53 AM, Claus Ibsen <cl...@gmail.com> wrote:
>> On Wed, Jul 14, 2010 at 9:51 AM, Claus Ibsen <cl...@gmail.com> wrote:
>>> Hi
>>>
>>> You most likely need to use a per http component for the different
>>> proxy settings.
>>> the proxy is generally per component based.
>>>
>>> So when you need a new proxy you just add a new http component
>>> context.addComponent("http2", context.getComponent("http"));
>>>
>>
>> And then set the proxy settings as you want on http2 component.
>> You may also just create a new component which is more understandable
>>
>> HttpComponent http2 = new HttpComponent();
>> http2.setProxyStuffHere
>> context.addComponent("http2", http2);
>>
>> The current logic in http endpoint is not cut for using different
>> proxy settings per endpoint.
>>
>>
>>
>>> And then use http2 in your endpoints.
>>>
>>>
>>>
>>>
>>> On Wed, Jul 14, 2010 at 8:38 AM, Cappa Roberto
>>> <ro...@guest.telecomitalia.it> wrote:
>>>> The recipient list was one of choice I've evaluated, but there is another problem: when I create a dynamic recipient list, for example http://host:port?porxyHost=proxy1 it works. In the next route execution (without restarting the context) I set http://host:port?porxyHost=proxy2, but the route continues to use the old one (proxy1). Is there a sort of component caching, that store component and options and reuse it in the next execution?
>>>>
>>>> Thanks
>>>> ________________________________________
>>>> Da: Claus Ibsen [claus.ibsen@gmail.com]
>>>> Inviato: martedì 13 luglio 2010 21.43
>>>> A: users@camel.apache.org
>>>> Oggetto: Re: Dynamically change HTTP endpoint parameters
>>>>
>>>> Hi
>>>>
>>>> I do not know if the Apache HTTP Client can change proxy value at runtime?
>>>>
>>>> You can with Camel stop the HTTP producer, adjust the http endpoint or
>>>> create a new http endpoint, and then create a new http producer using
>>>> that endpoint.
>>>>
>>>> Or use recipient list EIP which can use dynamic endpoints.
>>>>
>>>>
>>>> On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
>>>> <ro...@guest.telecomitalia.it> wrote:
>>>>> Hi,
>>>>>
>>>>> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>>>>>
>>>>> Thanks.
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

R: Dynamically change HTTP endpoint parameters

Posted by Cappa Roberto <ro...@guest.telecomitalia.it>.
The solution you have suggested is clear, but after creating a new "http2" component in a custom processor, when I try to use it in a dynamic recipient list, the following exception is thrown:

Any idea?

(now, my final endpoint is dynamically built like this: "http2://host:port/....")

Thanks

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:49)
	at org.apache.camel.component.http.HttpProducer.createMethod(HttpProducer.java:246)
	at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:63)
	at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
	at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
	at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
	at org.apache.camel.processor.MulticastProcessor.doProcess(MulticastProcessor.java:278)
	at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:240)
	at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:157)
	at org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:136)
	at org.apache.camel.processor.RecipientList.process(RecipientList.java:101)
	at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
	at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
	at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:97)
	at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
	at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
	at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
	at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
	at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:56)
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
	at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
	at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
	at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:97)
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
	at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185)
	at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151)
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89)
	at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
	at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:75)
	at org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:70)
	at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
	at org.apache.camel.component.http.CamelServlet.service(CamelServlet.java:71)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1216)
	at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:94)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:425)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:931)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
	at org.eclipse.jetty.server.Server.handle(Server.java:334)
	at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
	at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:992)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:541)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
	at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
	at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:47)
	... 56 more
Caused by: java.lang.IllegalStateException: unsupported protocol: 'http2'
	at org.apache.commons.httpclient.protocol.Protocol.lazyRegisterProtocol(Protocol.java:149)
	at org.apache.commons.httpclient.protocol.Protocol.getProtocol(Protocol.java:117)
	at org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:107)
	at org.apache.commons.httpclient.HttpMethodBase.setURI(HttpMethodBase.java:280)
	at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:220)
	at org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)
	... 61 more

________________________________________
Da: Claus Ibsen [claus.ibsen@gmail.com]
Inviato: mercoledì 14 luglio 2010 9.57
A: users@camel.apache.org
Oggetto: Re: Dynamically change HTTP endpoint parameters

Hi

I have created a ticket to look into this in the future
https://issues.apache.org/activemq/browse/CAMEL-2945

On Wed, Jul 14, 2010 at 9:53 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Wed, Jul 14, 2010 at 9:51 AM, Claus Ibsen <cl...@gmail.com> wrote:
>> Hi
>>
>> You most likely need to use a per http component for the different
>> proxy settings.
>> the proxy is generally per component based.
>>
>> So when you need a new proxy you just add a new http component
>> context.addComponent("http2", context.getComponent("http"));
>>
>
> And then set the proxy settings as you want on http2 component.
> You may also just create a new component which is more understandable
>
> HttpComponent http2 = new HttpComponent();
> http2.setProxyStuffHere
> context.addComponent("http2", http2);
>
> The current logic in http endpoint is not cut for using different
> proxy settings per endpoint.
>
>
>
>> And then use http2 in your endpoints.
>>
>>
>>
>>
>> On Wed, Jul 14, 2010 at 8:38 AM, Cappa Roberto
>> <ro...@guest.telecomitalia.it> wrote:
>>> The recipient list was one of choice I've evaluated, but there is another problem: when I create a dynamic recipient list, for example http://host:port?porxyHost=proxy1 it works. In the next route execution (without restarting the context) I set http://host:port?porxyHost=proxy2, but the route continues to use the old one (proxy1). Is there a sort of component caching, that store component and options and reuse it in the next execution?
>>>
>>> Thanks
>>> ________________________________________
>>> Da: Claus Ibsen [claus.ibsen@gmail.com]
>>> Inviato: martedì 13 luglio 2010 21.43
>>> A: users@camel.apache.org
>>> Oggetto: Re: Dynamically change HTTP endpoint parameters
>>>
>>> Hi
>>>
>>> I do not know if the Apache HTTP Client can change proxy value at runtime?
>>>
>>> You can with Camel stop the HTTP producer, adjust the http endpoint or
>>> create a new http endpoint, and then create a new http producer using
>>> that endpoint.
>>>
>>> Or use recipient list EIP which can use dynamic endpoints.
>>>
>>>
>>> On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
>>> <ro...@guest.telecomitalia.it> wrote:
>>>> Hi,
>>>>
>>>> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>>>>
>>>> Thanks.
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Dynamically change HTTP endpoint parameters

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

I have created a ticket to look into this in the future
https://issues.apache.org/activemq/browse/CAMEL-2945

On Wed, Jul 14, 2010 at 9:53 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Wed, Jul 14, 2010 at 9:51 AM, Claus Ibsen <cl...@gmail.com> wrote:
>> Hi
>>
>> You most likely need to use a per http component for the different
>> proxy settings.
>> the proxy is generally per component based.
>>
>> So when you need a new proxy you just add a new http component
>> context.addComponent("http2", context.getComponent("http"));
>>
>
> And then set the proxy settings as you want on http2 component.
> You may also just create a new component which is more understandable
>
> HttpComponent http2 = new HttpComponent();
> http2.setProxyStuffHere
> context.addComponent("http2", http2);
>
> The current logic in http endpoint is not cut for using different
> proxy settings per endpoint.
>
>
>
>> And then use http2 in your endpoints.
>>
>>
>>
>>
>> On Wed, Jul 14, 2010 at 8:38 AM, Cappa Roberto
>> <ro...@guest.telecomitalia.it> wrote:
>>> The recipient list was one of choice I've evaluated, but there is another problem: when I create a dynamic recipient list, for example http://host:port?porxyHost=proxy1 it works. In the next route execution (without restarting the context) I set http://host:port?porxyHost=proxy2, but the route continues to use the old one (proxy1). Is there a sort of component caching, that store component and options and reuse it in the next execution?
>>>
>>> Thanks
>>> ________________________________________
>>> Da: Claus Ibsen [claus.ibsen@gmail.com]
>>> Inviato: martedì 13 luglio 2010 21.43
>>> A: users@camel.apache.org
>>> Oggetto: Re: Dynamically change HTTP endpoint parameters
>>>
>>> Hi
>>>
>>> I do not know if the Apache HTTP Client can change proxy value at runtime?
>>>
>>> You can with Camel stop the HTTP producer, adjust the http endpoint or
>>> create a new http endpoint, and then create a new http producer using
>>> that endpoint.
>>>
>>> Or use recipient list EIP which can use dynamic endpoints.
>>>
>>>
>>> On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
>>> <ro...@guest.telecomitalia.it> wrote:
>>>> Hi,
>>>>
>>>> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>>>>
>>>> Thanks.
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Dynamically change HTTP endpoint parameters

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jul 14, 2010 at 9:51 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> You most likely need to use a per http component for the different
> proxy settings.
> the proxy is generally per component based.
>
> So when you need a new proxy you just add a new http component
> context.addComponent("http2", context.getComponent("http"));
>

And then set the proxy settings as you want on http2 component.
You may also just create a new component which is more understandable

HttpComponent http2 = new HttpComponent();
http2.setProxyStuffHere
context.addComponent("http2", http2);

The current logic in http endpoint is not cut for using different
proxy settings per endpoint.



> And then use http2 in your endpoints.
>
>
>
>
> On Wed, Jul 14, 2010 at 8:38 AM, Cappa Roberto
> <ro...@guest.telecomitalia.it> wrote:
>> The recipient list was one of choice I've evaluated, but there is another problem: when I create a dynamic recipient list, for example http://host:port?porxyHost=proxy1 it works. In the next route execution (without restarting the context) I set http://host:port?porxyHost=proxy2, but the route continues to use the old one (proxy1). Is there a sort of component caching, that store component and options and reuse it in the next execution?
>>
>> Thanks
>> ________________________________________
>> Da: Claus Ibsen [claus.ibsen@gmail.com]
>> Inviato: martedì 13 luglio 2010 21.43
>> A: users@camel.apache.org
>> Oggetto: Re: Dynamically change HTTP endpoint parameters
>>
>> Hi
>>
>> I do not know if the Apache HTTP Client can change proxy value at runtime?
>>
>> You can with Camel stop the HTTP producer, adjust the http endpoint or
>> create a new http endpoint, and then create a new http producer using
>> that endpoint.
>>
>> Or use recipient list EIP which can use dynamic endpoints.
>>
>>
>> On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
>> <ro...@guest.telecomitalia.it> wrote:
>>> Hi,
>>>
>>> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>>>
>>> Thanks.
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Dynamically change HTTP endpoint parameters

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

You most likely need to use a per http component for the different
proxy settings.
the proxy is generally per component based.

So when you need a new proxy you just add a new http component
context.addComponent("http2", context.getComponent("http"));

And then use http2 in your endpoints.




On Wed, Jul 14, 2010 at 8:38 AM, Cappa Roberto
<ro...@guest.telecomitalia.it> wrote:
> The recipient list was one of choice I've evaluated, but there is another problem: when I create a dynamic recipient list, for example http://host:port?porxyHost=proxy1 it works. In the next route execution (without restarting the context) I set http://host:port?porxyHost=proxy2, but the route continues to use the old one (proxy1). Is there a sort of component caching, that store component and options and reuse it in the next execution?
>
> Thanks
> ________________________________________
> Da: Claus Ibsen [claus.ibsen@gmail.com]
> Inviato: martedì 13 luglio 2010 21.43
> A: users@camel.apache.org
> Oggetto: Re: Dynamically change HTTP endpoint parameters
>
> Hi
>
> I do not know if the Apache HTTP Client can change proxy value at runtime?
>
> You can with Camel stop the HTTP producer, adjust the http endpoint or
> create a new http endpoint, and then create a new http producer using
> that endpoint.
>
> Or use recipient list EIP which can use dynamic endpoints.
>
>
> On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
> <ro...@guest.telecomitalia.it> wrote:
>> Hi,
>>
>> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>>
>> Thanks.
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

R: Dynamically change HTTP endpoint parameters

Posted by Cappa Roberto <ro...@guest.telecomitalia.it>.
The recipient list was one of choice I've evaluated, but there is another problem: when I create a dynamic recipient list, for example http://host:port?porxyHost=proxy1 it works. In the next route execution (without restarting the context) I set http://host:port?porxyHost=proxy2, but the route continues to use the old one (proxy1). Is there a sort of component caching, that store component and options and reuse it in the next execution?

Thanks
________________________________________
Da: Claus Ibsen [claus.ibsen@gmail.com]
Inviato: martedì 13 luglio 2010 21.43
A: users@camel.apache.org
Oggetto: Re: Dynamically change HTTP endpoint parameters

Hi

I do not know if the Apache HTTP Client can change proxy value at runtime?

You can with Camel stop the HTTP producer, adjust the http endpoint or
create a new http endpoint, and then create a new http producer using
that endpoint.

Or use recipient list EIP which can use dynamic endpoints.


On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
<ro...@guest.telecomitalia.it> wrote:
> Hi,
>
> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>
> Thanks.



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Dynamically change HTTP endpoint parameters

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

I do not know if the Apache HTTP Client can change proxy value at runtime?

You can with Camel stop the HTTP producer, adjust the http endpoint or
create a new http endpoint, and then create a new http producer using
that endpoint.

Or use recipient list EIP which can use dynamic endpoints.


On Tue, Jul 13, 2010 at 4:59 PM, Cappa Roberto
<ro...@guest.telecomitalia.it> wrote:
> Hi,
>
> I need to change at runtime some of HTTP endpoint options, for example proxyHost and proxyPort. It seems possibile to use placeholders, but they can be only  used in a static manner with a configuration file. In my use case I need to change these parameters at runtime, for example in a Processor. Is there a way to obtain this behaviour?
>
> Thanks.



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus