/** * A helper method to reply to a given message exchange with a given Source * * @param exchange the message exchange * @param answer the answer as an XML source * @throws MessagingException */ public void answer(MessageExchange exchange, Source answer) throws MessagingException { NormalizedMessage message = exchange.createMessage(); message.setContent(answer); answer(exchange, message); }
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); }
@Override protected void processInOnly(MessageExchange exchange, NormalizedMessage in) throws Exception { NormalizedMessage out = exchange.createMessage(); Fault fault = exchange.createFault(); this.startValidation(exchange, in, out, fault); if (fault.getContent() != null) { throw new RuntimeException(sourceTransformer.contentToString(fault)); } }
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 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 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 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; }
public void onMessageExchange(MessageExchange exchange) throws MessagingException { NormalizedMessage inMessage = getInMessage(exchange); // Copy message to avoid possible closed stream exceptions // when using StreamSource NormalizedMessage copyMessage = exchange.createMessage(); getMessageTransformer().transform(exchange, inMessage, copyMessage); messageList.addMessage(copyMessage); done(exchange); }
public void onMessageExchange(MessageExchange exchange) throws MessagingException { NormalizedMessage inMessage = getInMessage(exchange); // Copy message to avoid possible closed stream exceptions // when using StreamSource NormalizedMessage copyMessage = exchange.createMessage(); getMessageTransformer().transform(exchange, inMessage, copyMessage); messageList.addMessage(copyMessage); done(exchange); }
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; }
NormalizedMessage msg = exchange.createMessage(); msg.setContent(new StreamSource(getResponseEncodingStream( httpExchange.getResponseFields().getStringField(HttpHeaders.CONTENT_ENCODING), InputStream is = httpExchange.getResponseStream(); if (is != null) { NormalizedMessage msg = exchange.createMessage(); msg.setContent(new StreamSource(getResponseEncodingStream( httpExchange.getResponseFields().getStringField(HttpHeaders.CONTENT_ENCODING),
private boolean processInOut(MessageExchange exchange, PostMethod method, Context context, boolean txSync, boolean close) throws Exception { NormalizedMessage msg = exchange.createMessage(); SoapReader reader = soapHelper.getSoapMarshaler().createReader(); Header contentType = method.getResponseHeader(HEADER_CONTENT_TYPE); SoapMessage soapMessage = reader.read(method.getResponseBodyAsStream(), contentType != null ? contentType.getValue() : null); context.setOutMessage(soapMessage); soapHelper.onAnswer(context); if (getConfiguration().isWantHeadersFromHttpIntoExchange()) { msg.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(method)); } soapHelper.getJBIMarshaler().toNMS(msg, soapMessage); ((InOut) exchange).setOutMessage(msg); if (txSync) { channel.sendSync(exchange); } else { methods.put(exchange.getExchangeId(), method); channel.send(exchange); close = false; } return close; }
client = registry.getContainer().getClientFactory().createClient(); MessageExchange me = client.getExchangeFactory().createExchange(URI.create(mep)); NormalizedMessage nm = me.createMessage(); me.setMessage(nm, "in"); nm.setContent(new StringSource(content));
private boolean processInOptionalOut(PostMethod method, MessageExchange exchange, Context context, boolean txSync, boolean close) throws Exception { if (method.getResponseContentLength() == 0) { exchange.setStatus(ExchangeStatus.DONE); channel.send(exchange); } else { NormalizedMessage msg = exchange.createMessage(); SoapReader reader = soapHelper.getSoapMarshaler().createReader(); SoapMessage soapMessage = reader.read(method.getResponseBodyAsStream(), method.getResponseHeader(HEADER_CONTENT_TYPE).getValue()); context.setOutMessage(soapMessage); soapHelper.onAnswer(context); if (getConfiguration().isWantHeadersFromHttpIntoExchange()) { msg.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(method)); } soapHelper.getJBIMarshaler().toNMS(msg, soapMessage); ((InOptionalOut) exchange).setOutMessage(msg); if (txSync) { channel.sendSync(exchange); } else { methods.put(exchange.getExchangeId(), method); channel.send(exchange); close = false; } } return close; }