You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by focaldi <fe...@tav.aero> on 2011/12/15 08:10:44 UTC
How can I catch a response? (http component)
Hi I am trying to read response body but I took an exception like this.
Actually, I want to read http://tcmb.gov.tr/kurlar/today.xml url. But I
couldt :(. Pls help me.
Added to pom.xml :
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>2.9.0-RC1</version>
</dependency>
My route is :
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("timer://foo?fixedRate=true&delay=0&period=10000")
.to("http://www.google.com").process(new Processor() {
@Override
public void process(Exchange arg0) throws Exception {
System.out.println(arg0.getIn());
}
});
}
});
[ main] DefaultCamelContext INFO Apache
Camel 2.9.0-RC1 (CamelContext: camel-1) is starting
[ main] DefaultCamelContext INFO
HandleFault is enabled on CamelContext: camel-1
[ main] ManagementStrategyFactory INFO JMX
enabled. Using ManagedManagementStrategy.
[ main] ultManagementLifecycleStrategy INFO
StatiticsLevel at All so enabling load performance statistics
[ main] AnnotationTypeConverterLoader INFO Found
3 packages with 15 @Converter classes to load
[ main] DefaultTypeConverter INFO Loaded
163 core type converters (total 163 type converters)
[ main] AnnotationTypeConverterLoader INFO Loaded
4 @Converter classes
[ main] DefaultTypeConverter INFO Loaded
additional 14 type converters (total 177 type converters) in 0.054 seconds
[ main] DefaultCamelContext INFO Route:
route1 started and consuming from:
Endpoint[timer://foo?delay=0&fixedRate=true&period=10000]
[ main] DefaultCamelContext INFO Total
1 routes, of which 1 is started.
[ main] DefaultCamelContext INFO Apache
Camel 2.9.0-RC1 (CamelContext: camel-1) started in 0.890 seconds
[ foo] DefaultErrorHandler ERROR Failed
delivery for exchangeId: ID-FERIT-OCALDI-59648-1323932289447-0-1. Exhausted
after delivery attempt: 1 caught: java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at
org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:49)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.component.http.HttpProducer.createMethod(HttpProducer.java:333)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:90)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:92)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.interceptor.HandleFaultInterceptor.process(HandleFaultInterceptor.java:42)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:321)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:212)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:121)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:58)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at java.util.TimerThread.mainLoop(Unknown Source)[:1.6.0_29]
at java.util.TimerThread.run(Unknown Source)[:1.6.0_29]
[ foo] TimerConsumer ERROR Error
processing exchange. Exchange[Message: [Body is null]]. Caused by:
[java.lang.RuntimeException - java.lang.reflect.InvocationTargetException]
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at
org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:49)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.component.http.HttpProducer.createMethod(HttpProducer.java:333)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:90)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:92)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.interceptor.HandleFaultInterceptor.process(HandleFaultInterceptor.java:42)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:321)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:212)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:121)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:58)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
at java.util.TimerThread.mainLoop(Unknown Source)[:1.6.0_29]
at java.util.TimerThread.run(Unknown Source)[:1.6.0_29]
--
View this message in context: http://camel.465427.n5.nabble.com/How-can-I-catch-a-response-http-component-tp5076707p5076707.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How can I catch a response? (http component)
Posted by Willem Jiang <wi...@gmail.com>.
I created a new eclipse project based on the information that you
provided.
I can't reproduce the error that you meet.
Does the error is thrown when you using mvn to run the application ?
On Fri Dec 16 14:25:35 2011, focaldi wrote:
> Hi Willem,
> I test it but it doesn't work. :(. I took the same exception. What is the
> problem? I checked for another httpclient.jar but there is not. You can
> control my pom.xml for dependencies.
> I made a new project to test http componenet. There isn't other camel
> componenet. My pom.xml is :
> /**************************************************/
> <?xml version="1.0" encoding="UTF-8"?>
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>
> <modelVersion>4.0.0</modelVersion>
>
> <groupId>aero.tav.ib.camelweb</groupId>
> <artifactId>com.test.http</artifactId>
> <packaging>jar</packaging>
> <version>0.0.1-SNAPSHOT</version>
>
> <name>A Camel Route</name>
> <url>http://www.myorganization.org</url>
>
> <dependencies>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-core</artifactId>
> <version>2.9.0-RC1</version>
> </dependency>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-spring</artifactId>
> <version>2.9.0-RC1</version>
> </dependency>
>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-http</artifactId>
> <version>2.9.0-RC1</version>
> </dependency>
>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-jms</artifactId>
> <version>2.9.0-RC1</version>
> </dependency>
>
> <dependency>
> <groupId>org.apache.activemq</groupId>
> <artifactId>activemq-core</artifactId>
> <version>5.5.1</version>
> </dependency>
>
> <dependency>
> <groupId>org.slf4j</groupId>
> <artifactId>slf4j-api</artifactId>
> <version>1.6.1</version>
> </dependency>
> <dependency>
> <groupId>org.slf4j</groupId>
> <artifactId>slf4j-log4j12</artifactId>
> <version>1.6.1</version>
> </dependency>
> <dependency>
> <groupId>log4j</groupId>
> <artifactId>log4j</artifactId>
> <version>1.2.16</version>
> </dependency>
> </dependencies>
>
> <build>
> <defaultGoal>install</defaultGoal>
>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>2.3.2</version>
> <configuration>
> <source>1.6</source>
> <target>1.6</target>
> </configuration>
> </plugin>
>
>
> <plugin>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-maven-plugin</artifactId>
> <version>2.9.0-RC1</version>
> </plugin>
> </plugins>
> </build>
> </project>
> /***********************************************************/
> And my main class :
> package aero.tav.ib.camelweb.com.test.http;
>
> import static
> org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
>
> import javax.jms.ConnectionFactory;
>
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.camel.CamelContext;
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.impl.DefaultCamelContext;
>
>
> public class ApplicationTest {
>
> public static void main(String[] args) {
>
> CamelContext camelContext = null;
> try{
> camelContext = new DefaultCamelContext();
> ConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("tcp://localhost:61616");
> camelContext.addComponent("jms",
> jmsComponentClientAcknowledge(connectionFactory));
> camelContext.addRoutes(new RouteBuilder() {
> @Override
> public void configure() throws Exception {
> from("timer://foo?fixedRate=true&delay=0&period=10000")
> .to("http://tcmb.gov.tr/kurlar/today.xml").process(new Processor() {
> @Override
> public void process(Exchange arg0) throws Exception {
> System.out.println(arg0.getIn());
> }
> });
> }
> });
> camelContext.getShutdownStrategy().setTimeout(10);
>
> // start the route and let it do its work
> camelContext.start();
> Thread.sleep(20*1000);
>
> // stop the CamelContext
> camelContext.stop();
>
> }catch(Exception ex){
> ex.printStackTrace();
> }
>
> }
>
> }
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-can-I-catch-a-response-http-component-tp5076707p5079444.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang
Re: How can I catch a response? (http component)
Posted by focaldi <fe...@tav.aero>.
Hi Willem,
I test it but it doesn't work. :(. I took the same exception. What is the
problem? I checked for another httpclient.jar but there is not. You can
control my pom.xml for dependencies.
I made a new project to test http componenet. There isn't other camel
componenet. My pom.xml is :
/**************************************************/
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>aero.tav.ib.camelweb</groupId>
<artifactId>com.test.http</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>A Camel Route</name>
<url>http://www.myorganization.org</url>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.9.0-RC1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.9.0-RC1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>2.9.0-RC1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>2.9.0-RC1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.5.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>2.9.0-RC1</version>
</plugin>
</plugins>
</build>
</project>
/***********************************************************/
And my main class :
package aero.tav.ib.camelweb.com.test.http;
import static
org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
import javax.jms.ConnectionFactory;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class ApplicationTest {
public static void main(String[] args) {
CamelContext camelContext = null;
try{
camelContext = new DefaultCamelContext();
ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
camelContext.addComponent("jms",
jmsComponentClientAcknowledge(connectionFactory));
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("timer://foo?fixedRate=true&delay=0&period=10000")
.to("http://tcmb.gov.tr/kurlar/today.xml").process(new Processor() {
@Override
public void process(Exchange arg0) throws Exception {
System.out.println(arg0.getIn());
}
});
}
});
camelContext.getShutdownStrategy().setTimeout(10);
// start the route and let it do its work
camelContext.start();
Thread.sleep(20*1000);
// stop the CamelContext
camelContext.stop();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
--
View this message in context: http://camel.465427.n5.nabble.com/How-can-I-catch-a-response-http-component-tp5076707p5079444.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How can I catch a response? (http component)
Posted by Willem Jiang <wi...@gmail.com>.
I just wrote a simple unit test on the trunk code, everything looks good.
I double if there are multiple versions of HttpClient jars.
On Thu Dec 15 16:16:17 2011, Claus Ibsen wrote:
> On Thu, Dec 15, 2011 at 9:05 AM, focaldi<fe...@tav.aero> wrote:
>> Thanks your fast answer,
>>
>> I put a screenshot, you can see that I added httpclient jar.
>>
>> http://camel.465427.n5.nabble.com/file/n5076814/Untitled.png
>>
>
> A bit weird as the exception is for camel-http to load the
> HttpGet.class from the http-client JAR.
> If you check the source code from the stacktrace.
>
>
>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/How-can-I-catch-a-response-http-component-tp5076707p5076814.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang
Re: How can I catch a response? (http component)
Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Dec 15, 2011 at 9:05 AM, focaldi <fe...@tav.aero> wrote:
> Thanks your fast answer,
>
> I put a screenshot, you can see that I added httpclient jar.
>
> http://camel.465427.n5.nabble.com/file/n5076814/Untitled.png
>
A bit weird as the exception is for camel-http to load the
HttpGet.class from the http-client JAR.
If you check the source code from the stacktrace.
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-can-I-catch-a-response-http-component-tp5076707p5076814.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: How can I catch a response? (http component)
Posted by focaldi <fe...@tav.aero>.
Thanks your fast answer,
I put a screenshot, you can see that I added httpclient jar.
http://camel.465427.n5.nabble.com/file/n5076814/Untitled.png
--
View this message in context: http://camel.465427.n5.nabble.com/How-can-I-catch-a-response-http-component-tp5076707p5076814.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How can I catch a response? (http component)
Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Dec 15, 2011 at 8:52 AM, focaldi <fe...@tav.aero> wrote:
> I run it in Eclipse and I wrote a main method.
>
Make sure you got all the JARs on the classpath.
You may miss the http client JAR that the camel-http component uses.
> package aero.tav.ib;
>
> import static
> org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
>
> import javax.jms.ConnectionFactory;
>
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.camel.CamelContext;
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.ProducerTemplate;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.impl.DefaultCamelContext;
> import org.apache.camel.impl.JndiRegistry;
> import org.apache.camel.util.jndi.JndiContext;
> import org.springframework.context.ApplicationContext;
> import org.springframework.context.support.ClassPathXmlApplicationContext;
> import org.springframework.jdbc.datasource.DriverManagerDataSource;
>
> import aero.tav.ib.configuration.ConfigurationManager;
> import aero.tav.ib.configuration.entity.Provider;
> import aero.tav.ib.configuration.entity.Source;
> import aero.tav.ib.sql.SqlProviderService;
> import aero.tav.ib.utils.ApplicationContextProvider;
> import aero.tav.ib.utils.CamelContextProvider;
>
> public class ApplicationTest {
>
> public static void main(String[] args) {
>
> CamelContext camelContext = null;
> try{
> camelContext = new DefaultCamelContext();
> camelContext.setHandleFault(true);
> CamelContextProvider.setContext(camelContext);
>
> ConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("tcp://10.1.2.5:61616"); // ActiveMQ Machine
> camelContext.addComponent("jms",
> jmsComponentClientAcknowledge(connectionFactory));
> camelContext.addRoutes(new RouteBuilder() {
> @Override
> public void configure() throws Exception {
> from("timer://foo?fixedRate=true&delay=0&period=10000")
> .to("http://tcmb.gov.tr/kurlar/today.xml").process(new Processor() {
> @Override
> public void process(Exchange arg0) throws Exception {
> System.out.println(arg0.getIn());
> }
> });
> }
> });
> camelContext.getShutdownStrategy().setTimeout(10);
>
> // start the route and let it do its work
> camelContext.start();
> Thread.sleep(20*1000);
>
> // stop the CamelContext
> camelContext.stop();
>
> }catch(Exception ex){
> ex.printStackTrace();
> }
>
> }
>
> }
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-can-I-catch-a-response-http-component-tp5076707p5076790.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: How can I catch a response? (http component)
Posted by focaldi <fe...@tav.aero>.
I run it in Eclipse and I wrote a main method.
package aero.tav.ib;
import static
org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
import javax.jms.ConnectionFactory;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.util.jndi.JndiContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import aero.tav.ib.configuration.ConfigurationManager;
import aero.tav.ib.configuration.entity.Provider;
import aero.tav.ib.configuration.entity.Source;
import aero.tav.ib.sql.SqlProviderService;
import aero.tav.ib.utils.ApplicationContextProvider;
import aero.tav.ib.utils.CamelContextProvider;
public class ApplicationTest {
public static void main(String[] args) {
CamelContext camelContext = null;
try{
camelContext = new DefaultCamelContext();
camelContext.setHandleFault(true);
CamelContextProvider.setContext(camelContext);
ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://10.1.2.5:61616"); // ActiveMQ Machine
camelContext.addComponent("jms",
jmsComponentClientAcknowledge(connectionFactory));
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("timer://foo?fixedRate=true&delay=0&period=10000")
.to("http://tcmb.gov.tr/kurlar/today.xml").process(new Processor() {
@Override
public void process(Exchange arg0) throws Exception {
System.out.println(arg0.getIn());
}
});
}
});
camelContext.getShutdownStrategy().setTimeout(10);
// start the route and let it do its work
camelContext.start();
Thread.sleep(20*1000);
// stop the CamelContext
camelContext.stop();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
--
View this message in context: http://camel.465427.n5.nabble.com/How-can-I-catch-a-response-http-component-tp5076707p5076790.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How can I catch a response? (http component)
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
How do you run the code? Do you run it in a container such as
ServiceMix, or something else?
On Thu, Dec 15, 2011 at 8:10 AM, focaldi <fe...@tav.aero> wrote:
> Hi I am trying to read response body but I took an exception like this.
> Actually, I want to read http://tcmb.gov.tr/kurlar/today.xml url. But I
> couldt :(. Pls help me.
>
> Added to pom.xml :
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-http</artifactId>
> <version>2.9.0-RC1</version>
> </dependency>
>
> My route is :
> camelContext.addRoutes(new RouteBuilder() {
> @Override
> public void configure() throws Exception {
> from("timer://foo?fixedRate=true&delay=0&period=10000")
> .to("http://www.google.com").process(new Processor() {
> @Override
> public void process(Exchange arg0) throws Exception {
> System.out.println(arg0.getIn());
> }
> });
> }
> });
>
>
> [ main] DefaultCamelContext INFO Apache
> Camel 2.9.0-RC1 (CamelContext: camel-1) is starting
> [ main] DefaultCamelContext INFO
> HandleFault is enabled on CamelContext: camel-1
> [ main] ManagementStrategyFactory INFO JMX
> enabled. Using ManagedManagementStrategy.
> [ main] ultManagementLifecycleStrategy INFO
> StatiticsLevel at All so enabling load performance statistics
> [ main] AnnotationTypeConverterLoader INFO Found
> 3 packages with 15 @Converter classes to load
> [ main] DefaultTypeConverter INFO Loaded
> 163 core type converters (total 163 type converters)
> [ main] AnnotationTypeConverterLoader INFO Loaded
> 4 @Converter classes
> [ main] DefaultTypeConverter INFO Loaded
> additional 14 type converters (total 177 type converters) in 0.054 seconds
> [ main] DefaultCamelContext INFO Route:
> route1 started and consuming from:
> Endpoint[timer://foo?delay=0&fixedRate=true&period=10000]
> [ main] DefaultCamelContext INFO Total
> 1 routes, of which 1 is started.
> [ main] DefaultCamelContext INFO Apache
> Camel 2.9.0-RC1 (CamelContext: camel-1) started in 0.890 seconds
> [ foo] DefaultErrorHandler ERROR Failed
> delivery for exchangeId: ID-FERIT-OCALDI-59648-1323932289447-0-1. Exhausted
> after delivery attempt: 1 caught: java.lang.RuntimeException:
> java.lang.reflect.InvocationTargetException
> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
> at
> org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:49)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.component.http.HttpProducer.createMethod(HttpProducer.java:333)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:90)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:92)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.interceptor.HandleFaultInterceptor.process(HandleFaultInterceptor.java:42)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:321)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:212)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:121)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:58)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at java.util.TimerThread.mainLoop(Unknown Source)[:1.6.0_29]
> at java.util.TimerThread.run(Unknown Source)[:1.6.0_29]
> [ foo] TimerConsumer ERROR Error
> processing exchange. Exchange[Message: [Body is null]]. Caused by:
> [java.lang.RuntimeException - java.lang.reflect.InvocationTargetException]
> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
> at
> org.apache.camel.component.http.HttpMethods.createMethod(HttpMethods.java:49)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.component.http.HttpProducer.createMethod(HttpProducer.java:333)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:90)[camel-http-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:92)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.interceptor.HandleFaultInterceptor.process(HandleFaultInterceptor.java:42)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:321)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:212)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:121)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at
> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:58)[camel-core-2.9.0-RC1.jar:2.9.0-RC1]
> at java.util.TimerThread.mainLoop(Unknown Source)[:1.6.0_29]
> at java.util.TimerThread.run(Unknown Source)[:1.6.0_29]
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-can-I-catch-a-response-http-component-tp5076707p5076707.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/