public static boolean hasOutMessage(MessageExchange mex) { if (mex instanceof InOut) { return ((InOut) mex).getOutMessage() != null; } return false; }
private static Node getOutMessage(MessageExchange mex) throws TransformerConfigurationException { Source s = null; if (mex instanceof InOut) { NormalizedMessage nm = ((InOut)mex).getOutMessage(); if (nm != null) { s = nm.getContent(); } } if (s == null) { return null; } Transformer t = null; try { t = TransformerPool.get().retrieve(); DOMResult dr = new DOMResult(); t.transform(s, dr); return dr.getNode(); } catch (TransformerConfigurationException ex) { return null; } catch (TransformerException ex) { return null; } finally { if (t != null) { TransformerPool.get().relinquish(t); } } }
/** * sends the given DOMSource as message to the given service (inOut) * * @param service * the service name to send the message to * @param source * the source to put in the in message content * @return the DOMSource of the out message or null * @throws MessagingException * on any messaging exception */ public Source sendRequest(QName service, Source source) throws MessagingException { InOut inOut = getChannel().createExchangeFactoryForService(service).createInOutExchange(); NormalizedMessage msg = inOut.createMessage(); msg.setContent(source); inOut.setInMessage(msg); if (getChannel().sendSync(inOut)) { try { Source result = sourceTransformer.toDOMSource(inOut.getOutMessage().getContent()); done(inOut); return result; } catch (Exception ex) { ex.printStackTrace(); return null; } } else { return null; } }
mapper.toODE(response, jbiMex.getOutMessage(), pmex.getOperation().getOutput().getMessage()); pmex.reply(response);
if (!isOneWay) { channel.sendSync(xchng); NormalizedMessage outMsg = ((InOut)xchng).getOutMessage(); Source content = null; Set normalizedMessageProps = null;
if (!isOneWay) { channel.sendSync(xchng); NormalizedMessage outMsg = ((InOut)xchng).getOutMessage(); Source content = null; Set normalizedMessageProps = null;
sendSync(exchange); return; } else if (me.getOutMessage() == null) { throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE + " but has no Out nor Fault message");
public Object request(org.apache.servicemix.jbi.api.EndpointResolver resolver, Map exchangeProperties, Map inMessageProperties, Object content) throws JBIException { InOut exchange = createInOutExchange(resolver); populateMessage(exchange, exchangeProperties, inMessageProperties, content); boolean answer = sendSync(exchange); if (!answer) { throw new JBIException("Exchange aborted"); } Exception error = exchange.getError(); if (error != null) { throw new JBIException(error); } if (exchange.getFault() != null) { done(exchange); throw FaultException.newInstance(exchange); } NormalizedMessage outMessage = exchange.getOutMessage(); if (outMessage == null) { throw new NoOutMessageAvailableException(exchange); } Object result = getMarshaler().unmarshal(exchange, outMessage); done(exchange); return result; }
public Object request(EndpointResolver resolver, Map exchangeProperties, Map inMessageProperties, Object content) throws JBIException { InOut exchange = createInOutExchange(resolver); populateMessage(exchange, exchangeProperties, inMessageProperties, content); boolean answer = sendSync(exchange); if (!answer) { throw new JBIException("Exchange aborted"); } Exception error = exchange.getError(); if (error != null) { throw new JBIException(error); } if (exchange.getFault() != null) { done(exchange); throw FaultException.newInstance(exchange); } NormalizedMessage outMessage = exchange.getOutMessage(); if (outMessage == null) { throw new NoOutMessageAvailableException(exchange); } Object result = getMarshaler().unmarshal(exchange, outMessage); done(exchange); return result; }
public Object request(EndpointResolver resolver, Map exchangeProperties, Map inMessageProperties, Object content) throws JBIException { InOut exchange = createInOutExchange(resolver); populateMessage(exchange, exchangeProperties, inMessageProperties, content); boolean answer = sendSync(exchange); if (!answer) { throw new JBIException("Exchange aborted"); } Exception error = exchange.getError(); if (error != null) { throw new JBIException(error); } if (exchange.getFault() != null) { done(exchange); throw FaultException.newInstance(exchange); } NormalizedMessage outMessage = exchange.getOutMessage(); if (outMessage == null) { throw new NoOutMessageAvailableException(exchange); } Object result = getMarshaler().unmarshal(exchange, outMessage); done(exchange); return result; }
processFault(exchange, tme); } else if (tme.getOutMessage() == null) { throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE + " but has no correlation set");
public void onMessageExchange(MessageExchange exchange) throws MessagingException { // Skip done exchanges if (exchange.getStatus() == ExchangeStatus.DONE) { return; // Handle error exchanges } else if (exchange.getStatus() == ExchangeStatus.ERROR) { return; } // lets create an endpoint DeliveryChannel deliveryChannel = getDeliveryChannel(); MessageExchangeFactory rpcFactory = deliveryChannel.createExchangeFactory(requestResponseEndpoint); InOut rpc = rpcFactory.createInOutExchange(); rpc.setInMessage(exchange.getMessage("in")); boolean answer = deliveryChannel.sendSync(rpc); MessageExchangeFactory outputFactory = deliveryChannel.createExchangeFactory(outputEndpoint); InOnly inOnly = outputFactory.createInOnlyExchange(); if (answer) { inOnly.setInMessage(rpc.getOutMessage()); deliveryChannel.send(inOnly); done(exchange); } else if (!(exchange instanceof InOnly)) { inOnly.setError(rpc.getError()); Fault fault = rpc.getFault(); fail(exchange, fault); } else { // terminate the exchange done(exchange); } done(rpc); }
NormalizedMessage out = exchange.getOutMessage(); exchange.setStatus(ExchangeStatus.DONE); getDeliveryChannel().send(exchange);