/** * A helper method to indicate that the message exchange should be * continued with the given response and send the message * on the delivery channel. * * @param exchange * @throws MessagingException */ public void answer(MessageExchange exchange, NormalizedMessage answer) throws MessagingException { exchange.setMessage(answer, "out"); getDeliveryChannel().send(exchange); }
/** * A helper method to indicate that the message exchange should be * continued with the given response and send the message * on the delivery channel. * * @param exchange * @throws MessagingException */ public void answer(MessageExchange exchange, NormalizedMessage answer) throws MessagingException { exchange.setMessage(answer, "out"); getDeliveryChannel().send(exchange); }
public static void transferTo(NormalizedMessage sourceMsg, MessageExchange dest, String name) throws MessagingException { NormalizedMessage destMsg = (sourceMsg instanceof Fault) ? dest.createFault() : dest.createMessage(); transfer(sourceMsg, destMsg); dest.setMessage(destMsg, name); }
public static void transferTo(NormalizedMessage sourceMsg, MessageExchange dest, String name) throws MessagingException { NormalizedMessage destMsg = (sourceMsg instanceof Fault) ? dest.createFault() : dest.createMessage(); transfer(sourceMsg, destMsg); dest.setMessage(destMsg, name); }
public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception { MessageExchange me = context.getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep()); NormalizedMessage in = me.createMessage(); in.setContent(new StreamSource(getRequestEncodingStream(request.getHeader(HttpHeaders.CONTENT_ENCODING), request.getInputStream()))); me.setMessage(in, "in"); return me; }
public void copyFromCamelToJbi(Exchange exchange, MessageExchange messageExchange) throws MessagingException { // add Exchange properties to the MessageExchange without overwriting any existing properties copyPropertiesFromCamelToJbi(exchange, messageExchange); NormalizedMessage in = messageExchange.getMessage("in"); for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) { in.setProperty(entry.getKey(), entry.getValue()); } if (isOutCapable(messageExchange)) { if (exchange.hasOut()) { NormalizedMessage out = messageExchange.createMessage(); copyFromCamelToJbi(exchange.getOut(), out); messageExchange.setMessage(out, "out"); } else { //JBI MEP requires a reply and the Camel exchange failed to produce one -- echoing back the request NormalizedMessage out = messageExchange.createMessage(); copyFromCamelToJbi(exchange.getIn(), out); messageExchange.setMessage(out, "out"); } } }
public MessageExchange makeJbiMessageExchange(Exchange camelExchange, MessageExchangeFactory exchangeFactory, String defaultMep) throws MessagingException, URISyntaxException { MessageExchange jbiExchange = createJbiMessageExchange(camelExchange, exchangeFactory, defaultMep); copyPropertiesFromCamelToJbi(camelExchange, jbiExchange); NormalizedMessage normalizedMessage = jbiExchange.getMessage("in"); if (normalizedMessage == null) { normalizedMessage = jbiExchange.createMessage(); jbiExchange.setMessage(normalizedMessage, "in"); } copyFromCamelToJbi(camelExchange.getIn(), normalizedMessage); return jbiExchange; }
public WrappedStatusFromConsumerMessage(ServiceConfiguration serviceConfiguration, QName operation, URI mep, InputStream outMessageContentStream, FlowAttributes flowAttributes, ExchangeStatus status) { super(serviceConfiguration, operation, mep, flowAttributes); try { setRole(Role.PROVIDER); NormalizedMessage outNm = this.messageExchange.createMessage(); outNm.setContent(new StreamSource(outMessageContentStream)); this.messageExchange.setMessage(outNm, Exchange.OUT_MESSAGE_NAME); closeExchangeAsConsumer(status); } catch (MessagingException e) { throw new UncheckedException("Impossible to create a message exchange", e); } }
public WrappedRequestToProviderMessage(ServiceConfiguration serviceConfiguration, QName operation, URI mep, InputStream inMessageContentStream, FlowAttributes flowAttributes) { super(serviceConfiguration, operation, mep, flowAttributes); try { setRole(Role.CONSUMER); NormalizedMessage inNm = this.messageExchange.createMessage(); inNm.setContent(new StreamSource(inMessageContentStream)); this.messageExchange.setMessage(inNm, Exchange.IN_MESSAGE_NAME); setRole(Role.PROVIDER); } catch (MessagingException e) { throw new UncheckedException("Impossible to create a message exchange", e); } }
public static void transferTo(MessageExchange source, MessageExchange dest, String name) throws MessagingException { NormalizedMessage sourceMsg = source.getMessage(name); NormalizedMessage destMsg = (sourceMsg instanceof Fault) ? dest.createFault() : dest.createMessage(); transfer(sourceMsg, destMsg); dest.setMessage(destMsg, name); }
public static void transferTo(MessageExchange source, MessageExchange dest, String name) throws MessagingException { NormalizedMessage sourceMsg = source.getMessage(name); NormalizedMessage destMsg = (sourceMsg instanceof Fault) ? dest.createFault() : dest.createMessage(); transfer(sourceMsg, destMsg); dest.setMessage(destMsg, name); }
protected MessageExchange createPart(URI pattern, NormalizedMessage srcMessage, Source content) throws Exception { MessageExchange me = getExchangeFactory().createExchange(pattern); NormalizedMessage in = me.createMessage(); in.setContent(content); me.setMessage(in, "in"); if (forwardAttachments) { Set names = srcMessage.getAttachmentNames(); for (Iterator iter = names.iterator(); iter.hasNext();) { String name = (String) iter.next(); in.addAttachment(name, srcMessage.getAttachment(name)); } } if (forwardProperties) { Set names = srcMessage.getPropertyNames(); for (Iterator iter = names.iterator(); iter.hasNext();) { String name = (String) iter.next(); in.setProperty(name, srcMessage.getProperty(name)); } } return me; }
public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception { MessageExchange me = context.getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep()); NormalizedMessage in = me.createMessage(); in.setContent(marshal(request.getInputStream())); me.setMessage(in, "in"); return me; }
if (fake.getMessage(Convert.IN_MSG) != null) { if (concrete.getMessage(Convert.IN_MSG) == null) { concrete.setMessage( Convert.convertFakeToConcreteNormalizedMessage( concrete, concrete.setMessage( Convert.convertFakeToConcreteNormalizedMessage( concrete,
public MessageExchange createExchange(JmsContext jmsContext, ComponentContext jbiContext) throws Exception { Context ctx = (Context) jmsContext; MessageExchange exchange = jbiContext.getDeliveryChannel().createExchangeFactory().createExchange(mep); NormalizedMessage inMessage = exchange.createMessage(); populateMessage(ctx.message, inMessage); if (isCopyProperties()) { copyPropertiesFromJMS(ctx.message, inMessage); } exchange.setMessage(inMessage, "in"); return exchange; }
httpExchange.getResponseFields().getStringField(HttpHeaders.CONTENT_ENCODING), httpExchange.getResponseStream()))); exchange.setMessage(msg, "out"); } else if (exchange instanceof InOptionalOut) { InputStream is = httpExchange.getResponseStream(); httpExchange.getResponseFields().getStringField(HttpHeaders.CONTENT_ENCODING), is))); exchange.setMessage(msg, "out"); } else { exchange.setStatus(ExchangeStatus.DONE);
public void dispatch(MessageExchange exchange) { // create a Message from the message exhange and send it to the // listener... if (getListener() == null) { return; } // TODO : Check faults and errors... if (exchange != null && exchange.getMessage("in") != null) { Message message = Adapter.transform(exchange.getMessage("in")); Message out = getListener().onMessage(message); if (out != null) { // set the out message in the exchange try { exchange.setMessage(Adapter.transform(out), "out"); } catch (MessagingException e) { e.printStackTrace(); } } } } }
exchange.setMessage(nm, "in"); message.setContent(MessageExchange.class, exchange); } else { if (nm == null) { nm = exchange.createMessage(); exchange.setMessage(nm, "out");
MessageExchange me = client.getExchangeFactory().createExchange(URI.create(mep)); NormalizedMessage nm = me.createMessage(); me.setMessage(nm, "in"); nm.setContent(new StringSource(content)); me.setEndpoint(endpoint);
out.setContent(new DOMSource(document)); outExchange.setMessage(out, "in");