use of org.apache.camel.Message in project camel by apache.
the class NettyHttpBridgeRouteUsingHttpClientTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() {
port1 = getPort();
port2 = getNextPort();
errorHandler(noErrorHandler());
Processor serviceProc = new Processor() {
public void process(Exchange exchange) throws Exception {
// get the request URL and copy it to the request body
String uri = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
exchange.getOut().setBody(uri);
}
};
from("netty4-http:http://localhost:" + port2 + "/test/hello").to("http://localhost:" + port1 + "?throwExceptionOnFailure=false&bridgeEndpoint=true");
from("netty4-http:http://localhost:" + port1 + "?matchOnUriPrefix=true").process(serviceProc);
// check the from request
from("netty4-http:http://localhost:" + port2 + "/form?bridgeEndpoint=true").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
// just take out the message body and send it back
Message in = exchange.getIn();
String request = in.getBody(String.class);
exchange.getOut().setBody(request);
}
});
}
};
}
use of org.apache.camel.Message in project camel by apache.
the class NettyHttpConvertPayloadToInputStreamTest method testConvertPayloadToInputStream.
@Test
public void testConvertPayloadToInputStream() throws Exception {
MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
mockEndpoint.expectedMessageCount(1);
template.requestBodyAndHeader("netty4-http:http://localhost:{{port}}/test", expectedBody, "Content-Type", "application/xml");
mockEndpoint.assertIsSatisfied();
List<Exchange> list = mockEndpoint.getReceivedExchanges();
Exchange exchange = list.get(0);
assertNotNull("exchange", exchange);
Message in = exchange.getIn();
assertNotNull("in", in);
Object actual = in.getBody();
InputStream value = assertIsInstanceOf(InputStream.class, actual);
assertNotNull("InputStream", value);
}
use of org.apache.camel.Message in project camel by apache.
the class PortProducer method doGet.
private void doGet(Exchange exchange) {
final Message msg = exchange.getIn();
final String id = msg.getHeader(OpenstackConstants.ID, msg.getHeader(NeutronConstants.PORT_ID, String.class), String.class);
ObjectHelper.notEmpty(id, "Port ID");
final Port result = os.networking().port().get(id);
msg.setBody(result);
}
use of org.apache.camel.Message in project camel by apache.
the class PortProducer method doUpdate.
private void doUpdate(Exchange exchange) {
final Message msg = exchange.getIn();
final Port port = messageToPort(msg);
final Port updatedPort = os.networking().port().update(port);
msg.setBody(updatedPort);
}
use of org.apache.camel.Message in project camel by apache.
the class RouterProducer method doGet.
private void doGet(Exchange exchange) {
final Message msg = exchange.getIn();
final String id = msg.getHeader(OpenstackConstants.ID, msg.getHeader(NeutronConstants.ROUTER_ID, String.class), String.class);
ObjectHelper.notEmpty(id, "Router ID");
final Router result = os.networking().router().get(id);
msg.setBody(result);
}
Aggregations