Suchen

Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

9.3. Message Composition

download PDF

9.3.1. Message Composers

A MessageComposer composes or decomposes a native binding message to or from SwitchYard's canonical message. It does so in three steps:
  1. Construct a new target message instance.
  2. Copy the content of the message.
  3. Delegate the header/property mapping to a ContextMapper.
A SOAPMessageComposer and CamelMessageComposer are included with SwitchYard. These implementations are used by their associated bindings but you can override these with your own implementations.

9.3.2. Create a Custom Message Composer

Procedure 9.2. Create a Custom Message Composer

  1. Implement the org.switchyard.component.common.composer.MessageComposer interface:
    public interface MessageComposer<T> {
        ContextMapper<T> getContextMapper();
        MessageComposer<T> setContextMapper(ContextMapper<T> contextMapper);
        Message compose(T source, Exchange exchange, boolean create) throws Exception;
        public T decompose(Exchange exchange, T target) throws Exception;
    }
    
  2. Specify your implementation in your switchyard.xml file:
    <binding.xyz ...>
        <messageComposer class="com.example.MyMessageComposer"/>
    </binding.xyz>
    
    

9.3.3. Custom Message Composer Properties

  • The getContextMapper() and setContextMapper() methods are bean properties. If you extend BaseMessageComposer, both properties are implemented for you.
  • Your compose() method needs to take the data from the passed-in source native message and compose a SwitchYard Message based on the specified Exchange. The create parameter determines whether or not we ask the Exchange to create a new Message, or use the existing one.
  • Your decompose() method needs to take the data from the SwitchYard Message in the specified Exchange and "decompose it" into the target native message.
Red Hat logoGithubRedditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

© 2024 Red Hat, Inc.