Class SplittingXmlPayloadTranslator

  • All Implemented Interfaces:
    ComponentLifecycle, ComponentLifecycleExtension, ResultSetTranslator

    public class SplittingXmlPayloadTranslator
    extends XmlPayloadTranslatorImpl
    Translate the ResultSet contents into some number of XML messages.

    The format of the output messages is as follows:

     
     <Results>
       <Row>
         <column1>...</column1>
         <column2>...</column2>
         ...
       </Row>
       <Row> ... </Row>
     </Results>
     
     

    Note that column1, column2, etc. is replaced by the actual column name as returned in the query. As such, the column name must be a valid XML element name. If the actual name (in the database table definition) is not valid, the query should specify an alias name in the query. E.g: SELECT "col 1" AS "col1" FROM mytable;

    The output messages will be constructed by the same MessageFactory as the incoming message. If a MessageFactory has been configured then that one will be used instead (useful in case the incoming message is file-backed, for example).

    If you want to see how many rows were processed you can set one/both of the following;

    Item Description Value
    result-count-metadata-itemIf set to a String metadata item name will specify the metadata item to contain the number of rows returned by your queryMetadata item name
    update-count-metadata-itemIf set to a String metadata item name will specify the metadata item to contain the number of rows updated by your SQL statementMetadata item name

    In the adapter configuration file this class is aliased as jdbc-splitting-xml-payload-translator which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • SplittingXmlPayloadTranslator

        public SplittingXmlPayloadTranslator()
    • Method Detail

      • start

        public void start()
                   throws CoreException
        Description copied from interface: ComponentLifecycle
        Starts the component.

        Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer, calling start will begin message delivery.

        Throws:
        CoreException - wrapping any underlying Exceptions
      • stop

        public void stop()
        Description copied from interface: ComponentLifecycle
        Stop the component

        A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer, calling stop will pause message delivery. Throwing a RuntimeException may cause unintended consequences

      • close

        public void close()
        Description copied from interface: ComponentLifecycle
        Closes the component.

        A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException may cause unintended consequences

        Specified by:
        close in interface ComponentLifecycle
        Overrides:
        close in class XmlPayloadTranslatorImpl
      • getMaxRowsPerMessage

        public java.lang.Integer getMaxRowsPerMessage()
      • setMaxRowsPerMessage

        public void setMaxRowsPerMessage​(java.lang.Integer maxRowsPerMessage)
      • setConnection

        public void setConnection​(AdaptrisConnection conn)

        Sets the AdaptrisConnection to use for producing split messages.

        Parameters:
        conn - the AdaptrisConnection to use for producing split messages, may not be null
      • getConnection

        public AdaptrisConnection getConnection()

        Returns the AdaptrisConnection to use for producing split messages.

        Returns:
        the AdaptrisConnection to use for producing split messages
      • setProducer

        public void setProducer​(AdaptrisMessageProducer prod)

        Sets the AdaptrisMessageProducer to use for producing split messages.

        Parameters:
        prod - the AdaptrisMessageProducer to use for producing split messages, may not be null
      • getProducer

        public AdaptrisMessageProducer getProducer()

        Returns the AdaptrisMessageProducer to use for producing split messages.

        Returns:
        the AdaptrisMessageProducer to use for producing split messages
      • setCopyMetadata

        public void setCopyMetadata​(java.lang.Boolean b)
        Whether to copy metadata from the original message to the split messages.

        Note that object metadata is never copied since the nested action is to produce the message somewhere.

        Parameters:
        b - whether to copy metadata from the original message to the split messages (default true)
      • getCopyMetadata

        public java.lang.Boolean getCopyMetadata()