use of org.apache.camel.component.rabbitmq.testbeans.TestPartiallySerializableObject in project camel by apache.
the class RabbitMQInOutIntTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:rabbitMQ").id("producingRoute").setHeader("routeHeader", simple("routeHeader")).inOut(rabbitMQEndpoint);
from(rabbitMQEndpoint).id("consumingRoute").log("Receiving message").process(new Processor() {
public void process(Exchange exchange) throws Exception {
if (exchange.getIn().getBody(TestSerializableObject.class) != null) {
TestSerializableObject foo = exchange.getIn().getBody(TestSerializableObject.class);
foo.setDescription("foobar");
} else if (exchange.getIn().getBody(TestPartiallySerializableObject.class) != null) {
TestPartiallySerializableObject foo = exchange.getIn().getBody(TestPartiallySerializableObject.class);
foo.setNonSerializableObject(new TestNonSerializableObject());
foo.setDescription("foobar");
} else if (exchange.getIn().getBody(String.class) != null) {
if (exchange.getIn().getBody(String.class).contains("header")) {
assertEquals(exchange.getIn().getHeader("String"), "String");
assertEquals(exchange.getIn().getHeader("routeHeader"), "routeHeader");
}
if (exchange.getIn().getBody(String.class).contains("Exception")) {
throw new IllegalArgumentException("Boom");
}
if (exchange.getIn().getBody(String.class).contains("TimeOut")) {
Thread.sleep(TIMEOUT_MS * 2);
}
exchange.getIn().setBody(exchange.getIn().getBody(String.class) + " response");
}
}
});
from("direct:rabbitMQNoAutoAck").id("producingRouteNoAutoAck").setHeader("routeHeader", simple("routeHeader")).inOut(noAutoAckEndpoint);
from(noAutoAckEndpoint).id("consumingRouteNoAutoAck").to(resultEndpoint).throwException(new IllegalStateException("test exception"));
}
};
}
use of org.apache.camel.component.rabbitmq.testbeans.TestPartiallySerializableObject in project camel by apache.
the class RabbitMQInOutIntTest method partiallySerializeTest.
@Test
public void partiallySerializeTest() throws InterruptedException, IOException {
TestPartiallySerializableObject foo = new TestPartiallySerializableObject();
foo.setName("foobar");
try {
TestPartiallySerializableObject reply = template.requestBodyAndHeader("direct:rabbitMQ", foo, RabbitMQConstants.EXCHANGE_NAME, EXCHANGE, TestPartiallySerializableObject.class);
} catch (CamelExecutionException e) {
// expected
}
// Make sure we didn't crash the one Consumer thread
String reply2 = template.requestBodyAndHeader("direct:rabbitMQ", "partiallySerializeTest1", RabbitMQConstants.EXCHANGE_NAME, EXCHANGE, String.class);
assertEquals("partiallySerializeTest1 response", reply2);
}
Aggregations