public void dispatch(MessageExchange exchange) throws IOException {
QName opName = exchange.getOperation();
getLogger().fine("dispatch method: " + opName);
NormalizedMessage nm = exchange.getMessage("in");
try {
MessageImpl inMessage = new MessageImpl();
Set normalizedMessageProps = nm.getPropertyNames();
for (Object name : normalizedMessageProps) {
inMessage.put((String)name, nm.getProperty((String)name));
}
inMessage.put(MessageExchange.class, exchange);
final InputStream in = JBIMessageHelper.convertMessageToInputStream(nm.getContent());
inMessage.setContent(InputStream.class, in);
//dispatch to correct destination in case of multiple endpoint
inMessage.setDestination(((JBITransportFactory)conduitInitiator).
getDestination(exchange.getService().toString()
+ exchange.getInterfaceName().toString()));
((JBITransportFactory)conduitInitiator).
getDestination(exchange.getService().toString()
+ exchange.getInterfaceName().toString()).
getMessageObserver().onMessage(inMessage);
} catch (Exception ex) {
getLogger().log(Level.SEVERE, new org.apache.cxf.common.i18n.Message(
"ERROR.PREPARE.MESSAGE", getLogger()).toString(), ex);
throw new IOException(ex.getMessage());
}
}
|