protected boolean isTransacted(MessageExchange me) { return me.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME) != null; }
/** * * @param in * echange to copy from * @param out * excahnge to copy to */ private void copyProperties(MessageExchange in, MessageExchange out) { Set propertyNames = in.getPropertyNames(); for (Iterator iter = propertyNames.iterator(); iter.hasNext();) { String name = (String) iter.next(); out.setProperty(name, in.getProperty(name)); } }
protected boolean isSynchronous(MessageExchange me) { Boolean sync = (Boolean) me.getProperty(JbiConstants.SEND_SYNC); return sync != null && sync.booleanValue(); }
private static void setProperties(final @Nullable MessageExchange from, final @Nullable MessageExchange to) { assert from != null; assert to != null; // we put all the properties from the source exchange @SuppressWarnings("unchecked") final Set<String> props = from.getPropertyNames(); for (final String prop : props) { assert prop != null; if (ignoreProperty(prop)) { // let's skip this one, we don't want to propagate it! continue; } to.setProperty(prop, from.getProperty(prop)); } }
public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException { if (exchange.getProperty(CORRELATION_ID) != null) { return exchange.getProperty(CORRELATION_ID); } return exchange.getExchangeId(); } };
private void writeMessageExchange(MessageExchange exchange) { println("-- Exchange " + exchange.getExchangeId() + " --"); writeProperty("endpoint", exchange.getEndpoint()); writeProperty("MEP", exchange.getPattern()); for (Object key : exchange.getPropertyNames()) { writeProperty(key, exchange.getProperty(key.toString())); } }
public static FlowAttributes getFlowAttributes(final MessageExchange messageExchange, final String prefix) { final String mexPrefix = prefix + messageExchange.getExchangeId() + "."; final Object oI = messageExchange.getProperty(mexPrefix + FLOW_INSTANCE_ID); final Object oS = messageExchange.getProperty(mexPrefix + FLOW_STEP_ID); if (oS instanceof String && oI instanceof String) { return new FlowAttributes((String) oI, (String) oS); } else { return null; } }
public String getMessageTrackingId() { final String trId = (String)me.getProperty(MessageExchangeTracker.TRACKING_ID); return (trId == null) ? me.getExchangeId() : trId; }
private boolean isSynchronous(MessageExchange exchange) { return isSynchronous() || (exchange.isTransacted() && Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC))); }
private void copyPropertiesFromCamelToJbi(Exchange exchange, MessageExchange messageExchange) { for (String key : exchange.getProperties().keySet()) { if (messageExchange.getProperty(key) == null) { Object value = exchange.getProperty(key); if (!MESSAGE_EXCHANGE.equals(key) && value != null && !strategies.applyFilterToCamelHeaders(key, value, exchange)) { messageExchange.setProperty(key, value); } } } }
private void doSend(MessageExchange exchange) throws MessagingException { boolean txSync = exchange.isTransacted() && Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC)); if (txSync && ExchangeStatus.ACTIVE.equals(exchange.getStatus())) { sendSync(exchange); } else { send(exchange); } }
public void process(MessageExchange exchange) throws Exception { JmsContext context; if (stateless) { context = (JmsContext) exchange.getProperty(PROP_JMS_CONTEXT); } else { context = (JmsContext) store.load(exchange.getExchangeId()); } processExchange(exchange, null, context); }
protected void processAsync(MessageExchange exchange) throws Exception { // The exchange comes from the consumer if (exchange.getRole() == MessageExchange.Role.PROVIDER) { processAsyncProvider(exchange); // If the exchange comes from the transformer } else if (Boolean.TRUE.equals(exchange.getProperty(TRANSFORMER))) { processAsyncTransformerResponse(exchange); // The exchange comes from the target } else { processAsyncTargetResponse(exchange); } }
public void populateMessage(Message message, MessageExchange exchange, NormalizedMessage normalizedMessage) throws Exception { org.apache.servicemix.soap.api.Message req = (org.apache.servicemix.soap.api.Message) exchange.getProperty(Message.class.getName()); exchange.setProperty(org.apache.servicemix.soap.api.Message.class.getName(), null); org.apache.servicemix.soap.api.Message msg = binding.createMessage(req); msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper); msg.setContent(MessageExchange.class, exchange); msg.setContent(NormalizedMessage.class, normalizedMessage); String str = ((TextMessage) message).getText(); msg.setContent(InputStream.class, new ByteArrayInputStream(str.getBytes())); InterceptorChain phaseIn = getChain(Phase.ClientIn); phaseIn.doIntercept(msg); }
protected void handleException(SmxHttpExchange httpExchange, MessageExchange exchange, Throwable ex) { try { marshaler.handleException(exchange, httpExchange, ex); boolean txSync = exchange.getStatus() == ExchangeStatus.ACTIVE && exchange.isTransacted() && Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC)); if (txSync) { sendSync(exchange); } else { send(exchange); } } catch (Exception e) { logger.warn("Unable to send back exchange in error", e); } }
public void process(MessageExchange exchange) throws Exception { boolean txSync = exchange.isTransacted() && Boolean.TRUE.equals(exchange.getProperty(JbiConstants.SEND_SYNC)); if (txSync && exchange.getRole() == Role.PROVIDER && exchange.getStatus() == ExchangeStatus.ACTIVE) { processSync(exchange); } else { processAsync(exchange); } }
public void onMessageExchange(MessageExchange exchange) throws MessagingException { // Handle consumer exchanges && non-active RobustInOnly provider exchanges if (exchange.getRole() == MessageExchange.Role.CONSUMER || exchange.getProperty(correlation) != null) { processOngoingExchange(exchange); } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) { processFirstExchange(exchange); } }
public void onMessageExchange(MessageExchange exchange) { if (!container.handleTransactions()) { final Transaction tx = (Transaction) exchange.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME); if (tx != null) { processExchangeInTx(exchange, tx); } else { processExchangeWithoutTx(exchange); } } else { processExchangeWithoutTx(exchange); } }
public void onMessageExchange(MessageExchange exchange) throws MessagingException { // Handle consumer exchanges && non-active RobustInOnly provider exchanges if (exchange.getRole() == MessageExchange.Role.CONSUMER || exchange.getProperty(correlation) != null) { processOngoingExchange(exchange); } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) { processFirstExchange(exchange); } }
public void handleResponse(MessageExchange exchange, SmxHttpExchange httpExchange) throws Exception { Message req = (Message) exchange.getProperty(Message.class.getName()); exchange.setProperty(Message.class.getName(), null); Message msg = binding.createMessage(req); msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper); msg.setContent(MessageExchange.class, exchange); msg.setContent(InputStream.class, getResponseEncodingStream( httpExchange.getResponseFields().getStringField(HttpHeaders.CONTENT_ENCODING), httpExchange.getResponseStream())); msg.put(StaxInInterceptor.ENCODING, httpExchange.getResponseEncoding()); InterceptorChain phaseOut = getChain(Phase.ClientIn); phaseOut.doIntercept(msg); // TODO: Retrieve headers ? }