use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class CxfBeanDestination method process.
public void process(Exchange camelExchange) throws Exception {
LOG.trace("Received request : {}", camelExchange);
org.apache.cxf.message.Message cxfMessage = endpoint.getCxfBeanBinding().createCxfMessageFromCamelExchange(camelExchange, endpoint.getHeaderFilterStrategy());
cxfMessage.put(CamelTransportConstants.CAMEL_EXCHANGE, camelExchange);
((MessageImpl) cxfMessage).setDestination(this);
// Handling the incoming message
// The response message will be send back by the outgoing chain
incomingObserver.onMessage(cxfMessage);
}
use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class CxfMessageHelper method getCxfInMessage.
public static org.apache.cxf.message.Message getCxfInMessage(HeaderFilterStrategy headerFilterStrategy, org.apache.camel.Exchange exchange, boolean isClient) {
MessageImpl answer = new MessageImpl();
org.apache.cxf.message.Exchange cxfExchange = exchange.getProperty(CamelTransportConstants.CXF_EXCHANGE, org.apache.cxf.message.Exchange.class);
org.apache.camel.Message message;
if (isClient && exchange.hasOut()) {
message = exchange.getOut();
} else {
message = exchange.getIn();
}
assert message != null;
if (cxfExchange == null) {
cxfExchange = new ExchangeImpl();
exchange.setProperty(CamelTransportConstants.CXF_EXCHANGE, cxfExchange);
}
CxfHeaderHelper.propagateCamelToCxf(headerFilterStrategy, message.getHeaders(), answer, exchange);
// body can be empty in case of GET etc.
InputStream body = message.getBody(InputStream.class);
if (body != null) {
answer.setContent(InputStream.class, body);
} else if (message.getBody() != null) {
// fallback and set the body as what it is
answer.setContent(Object.class, body);
}
answer.putAll(message.getHeaders());
answer.setExchange(cxfExchange);
cxfExchange.setInMessage(answer);
return answer;
}
use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class CamelDestinationTest method testRoundTripDestinationWithFault.
@Test
public void testRoundTripDestinationWithFault() throws Exception {
inMessage = null;
EndpointInfo conduitEpInfo = new EndpointInfo();
conduitEpInfo.setAddress("camel://direct:Producer");
// set up the conduit send to be true
CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
final Message outMessage = new MessageImpl();
endpointInfo.setAddress("camel://direct:EndpointA");
final CamelDestination destination = setupCamelDestination(endpointInfo, true);
destination.setCheckException(true);
// set up MessageObserver for handling the conduit message
MessageObserver observer = new MessageObserver() {
public void onMessage(Message m) {
try {
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(m);
m.setExchange(exchange);
verifyReceivedMessage(m, "HelloWorld");
//verifyHeaders(m, outMessage);
// setup the message for
Conduit backConduit;
backConduit = getBackChannel(destination, m);
// wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
replyMessage.setContent(Exception.class, new RuntimeCamelException());
sendoutMessage(backConduit, replyMessage, true, "HelloWorld Fault");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
MockEndpoint error = context.getEndpoint("mock:error", MockEndpoint.class);
error.expectedMessageCount(1);
//this call will active the camelDestination
destination.setMessageObserver(observer);
// set is one way false for get response from destination
// need to use another thread to send the request message
sendoutMessage(conduit, outMessage, false, "HelloWorld");
// wait for the message to be got from the destination,
// create the thread to handler the Destination incoming message
verifyReceivedMessage(inMessage, "HelloWorld Fault");
error.assertIsSatisfied();
destination.shutdown();
}
use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class CamelConduitTest method testPrepareSend.
@Test
public void testPrepareSend() throws Exception {
endpointInfo.setAddress("camel://direct:Producer");
CamelConduit conduit = setupCamelConduit(endpointInfo, false, false);
Message message = new MessageImpl();
try {
conduit.prepare(message);
} catch (Exception ex) {
ex.printStackTrace();
}
verifyMessageContent(message);
}
use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class CamelConduitTest method testSendOutRunTrip.
@Test
public void testSendOutRunTrip() throws Exception {
endpointInfo.setAddress("camel://direct:Producer");
CamelConduit conduit = setupCamelConduit(endpointInfo, true, false);
MockEndpoint endpoint = getMockEndpoint("mock:EndpointA");
endpoint.expectedMessageCount(1);
Message message = new MessageImpl();
// set the isOneWay to be false
sendoutMessage(conduit, message, false, "HelloWorld");
// verify the endpoint get the response
assertMockEndpointsSatisfied();
verifyReceivedMessage("HelloWorld");
}
Aggregations