camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ibrahimis <>
Subject Need input on accessing http servlet
Date Fri, 23 Sep 2016 10:39:43 GMT
Hi, I have created servlet which will return a JSON object. I am trying to
connect the servlet using Camel and put it in a buffer. But my servlet
didn't invoked at all and not throwing any error. I am currently in the
beginning stage on using camel. 

Please help.

I have used the following code.

package com.test.camel;


import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;

public class TestRouteBuilder extends RouteBuilder {

	public void configure() throws Exception {

				.setHeader("stream", constant(mystream))
				.process(new Processor() {
					public void process(Exchange exchange) throws Exception {
						String contentType = exchange.getIn().getHeader(
								Exchange.CONTENT_TYPE, String.class);
						String path = exchange.getIn().getHeader(
								Exchange.HTTP_URI, String.class);
						path = path.substring(path.lastIndexOf("/"));

								contentType + "; charset=UTF-8");
						exchange.getOut().setHeader("PATH", path);
						exchange.getOut().setBody("*Hello World*");


	private OutputStream mystream = new MyOutputStream();
	private StringBuilder sb = new StringBuilder();

	private class MyOutputStream extends OutputStream {

		public void write(int b) throws IOException {
			sb.append((char) b);


View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message