Reputation: 85
I am very new to this but I would like to retrieve a json file from this url: https://builds.apache.org/job/Accumulo-1.5/api/json
I would like to put this url in my ActiveMQ My code looks like this:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<!--Link naar activemq-->
<property name="brokerURL" value="tcp://localhost:61616"/>
</bean>
</property>
</bean>
<bean id="downloadLogger" class="camelinaction.DownloadLogger"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<json id="json" library="Jackson"/>
</dataFormats>
<route>
<from uri="jetty:https://builds.apache.org:443/job/Accumulo-1.5/api/json"/>
<process ref="downloadLogger"/>
<to uri="jms:TestQueue"/>
</route>
<route>
<from uri="jms:TestQueue"/>
<process ref="downloadLogger"/>
<to uri="file:src/result"/>
</route>
</camelContext>
</beans>
The queue is working. I tried to put a xml file in the queue and it wasn't a problem. However the input of my route configuration is a link to an existing url.
Is this possible? if yes, what is my fault?
Thanks in advance.
Upvotes: 0
Views: 1748
Reputation: 85
Fixed it using Java DSL in stead of Spring DSL.
Solution:
@Component
public class AccumoloToJmsRouteBuilder extends SpringRouteBuilder {
@Override
public void configure() throws Exception {
from("timer://foo?fixedRate=true&delay=0&period=2000&repeatCount=1")
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.to("https://builds.apache.org:443/job/Accumulo-1.5/api/json")
.convertBodyTo(String.class)
.to("myProcessor")
.log(LoggingLevel.DEBUG, "com.project", "HTTP GET response body: ${body}")
.to("activemq://TestQueue");
}
}
Upvotes: 1