Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
41.4. The ExchangeHelper Class
Overview 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The
org.apache.camel.util.ExchangeHelper
class is a Apache Camel utility class that provides methods that are useful when implementing a processor.
Resolve an endpoint 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The static
resolveEndpoint()
method is one of the most useful methods in the ExchangeHelper
class. You use it inside a processor to create new Endpoint
instances on the fly.
Example 41.6. The resolveEndpoint()
Method
The first argument to
resolveEndpoint()
is an exchange instance, and the second argument is usually an endpoint URI string. Example 41.7, “Creating a File Endpoint” shows how to create a new file endpoint from an exchange instance exchange
Example 41.7. Creating a File Endpoint
Endpoint file_endp = ExchangeHelper.resolveEndpoint(exchange, "file://tmp/messages/in.xml");
Endpoint file_endp = ExchangeHelper.resolveEndpoint(exchange, "file://tmp/messages/in.xml");
Wrapping the exchange accessors 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The
ExchangeHelper
class provides several static methods of the form getMandatoryBeanProperty()
, which wrap the corresponding getBeanProperty()
methods on the Exchange
class. The difference between them is that the original getBeanProperty()
accessors return null
, if the corresponding property is unavailable, and the getMandatoryBeanProperty()
wrapper methods throw a Java exception. The following wrapper methods are implemented in the ExchangeHelper
class:
Testing the exchange pattern 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Several different exchange patterns are compatible with holding an In message. Several different exchange patterns are also compatible with holding an Out message. To provide a quick way of checking whether or not an exchange object is capable of holding an In message or an Out message, the
ExchangeHelper
class provides the following methods:
Get the In message's MIME content type 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
If you want to find out the MIME content type of the exchange's In message, you can access it by calling the
ExchangeHelper.getContentType(exchange)
method. To implement this, the ExchangeHelper
object looks up the value of the In message's Content-Type
header—this method relies on the underlying component to populate the header value).