camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cappa Roberto <roberto.ca...@guest.telecomitalia.it>
Subject R: Dynamically change HTTP endpoint parameters
Date Wed, 14 Jul 2010 09:49:22 GMT

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
<roberto.cappa@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 <claus.ibsen@gmail.com> wrote:
>> On Wed, Jul 14, 2010 at 9:51 AM, Claus Ibsen <claus.ibsen@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
>>> <roberto.cappa@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
>>>> <roberto.cappa@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

Mime
View raw message