java.lang.Object
org.openehealth.ipf.platform.camel.core.util.Exchanges

public class Exchanges extends Object
Utility related to Camel Exchanges.
Author:
Martin Krasser
  • Constructor Details

    • Exchanges

      public Exchanges()
  • Method Details

    • producerTemplate

      public static ProducerTemplate producerTemplate(Exchange exchange)
      Creates a ProducerTemplate from the given Exchange
      Parameters:
      exchange - message exchange.
      Returns:
      a producer template.
    • resultMessage

      public static Message resultMessage(Exchange exchange)
      Deprecated.
      Returns the message where to write results.
      Parameters:
      exchange - message exchange.
      Returns:
      result message.
    • prepareResult

      public static Message prepareResult(Exchange exchange)
      Returns the message where to write results. This method copies the in-message to the out-message if the exchange is out-capable.
      Parameters:
      exchange - message exchange.
      Returns:
      result message.
    • createExchange

      public static Exchange createExchange(Exchange source, ExchangePattern pattern)
      Creates a new Exchange instance from the given exchange. The resulting exchange's pattern is defined by pattern.
      Parameters:
      source - exchange to copy from.
      pattern - exchange pattern to set.
      Returns:
      created exchange.
    • createExchange

      public static Exchange createExchange(CamelContext context, ExchangePattern pattern)
      Creates a new Exchange instance using context. The resulting exchange's pattern is defined by pattern.
      Parameters:
      context - Camel context.
      pattern - exchange pattern.
      Returns:
      created exchange.
    • copyInput

      public static void copyInput(Exchange exchange)
      Copies the exchange's in-message to the out-message if the exchange pattern is ExchangePattern.InOut.
      Parameters:
      exchange - message exchange.
    • copyExchange

      public static void copyExchange(Exchange source, Exchange target)
      Copies the source exchange to target exchange preserving the ExchangePattern of target.
      Parameters:
      source - source exchange.
      target - target exchange.
      See Also:
    • extractException

      public static Exception extractException(Exchange exchange, boolean cleanup)
      Extracts the exception handled while processing the given exchange (if any), and optionally marks the exchange as non-failed.
      Parameters:
      exchange - Camel exchange, should be not null.
      cleanup - true iff the information about the occurred exception should be removed from the given exchange.
      Returns:
      an Exception instance, or null when no exception was handled.
    • extractException

      public static Exception extractException(Exchange exchange)
      Extracts the exception handled while processing the given exchange (if any), and marks the exchange as non-failed.

      This method corresponds to extractException(org.apache.camel.Exchange, boolean) with the second parameter set to true.

      Parameters:
      exchange - Camel exchange, should be not null.
      Returns:
      an Exception instance, or null when no exception was handled.