Class MessageUtils


  • public class MessageUtils
    extends java.lang.Object
    Contains utilities for accessing the Enterprise Service Bus functionality.
    • Constructor Detail

      • MessageUtils

        public MessageUtils()
    • Method Detail

      • dispatch

        public static void dispatch​(PlatformMessage msg,
                                    java.lang.String endpointName)
                             throws AttivioException
        Sends the message to the endpointName asynchronously.
        Parameters:
        msg - the message to send
        endpointName - a local avm queue name or a valid URI
        Throws:
        AttivioException - if endpointName is not a valid endpoint or if an exception is encountered while delivering the message
      • send

        public static PlatformMessage send​(PlatformMessage msg,
                                           java.lang.String endpointName)
                                    throws AttivioException
        Sends a message to the endpointName synchronously.
        Parameters:
        msg - the message to send
        endpointName - a local avm queue name or a valid uri.
        Returns:
        the platform message
        Throws:
        AttivioException - if endpointName is not a valid endpoint, or if the result is not an PlatformMessage, or if an exception is encountered while delivering the message
      • send

        public static PlatformMessage send​(PlatformMessage msg,
                                           java.lang.String endpointName,
                                           boolean allowNullResponse)
                                    throws AttivioException
        Sends a message to the endpointName synchronously.
        Parameters:
        msg - the message to send
        endpointName - a local avm queue name or a valid uri.
        allowNullResponse - if false, exception will be thrown if a null response is received
        Returns:
        the platform message
        Throws:
        AttivioException - if endpointName is not a valid endpoint, or if the result is not an PlatformMessage, or if an exception is encountered while delivering the message
      • send

        public static PlatformMessage send​(PlatformMessage msg,
                                           java.lang.String endpointName,
                                           int maxRetries,
                                           long retryWaitTime)
                                    throws AttivioException
        Sends a message to endpointName synchronously, retrying on transport error.
        Parameters:
        msg - the message to send
        endpointName - a local avm queue name or a valid uri.
        maxRetries - maximum number of times to resend (unlimited = -1)
        retryWaitTime - how long to wait before retrying (in milliseconds)
        Returns:
        the platform message returned in response
        Throws:
        AttivioException - if endpointName is not a valid endpoint, or if the result is not an PlatformMessage, or if an exception is encountered while delivering the message
      • send

        public static PlatformMessage send​(PlatformMessage msg,
                                           java.lang.String endpointName,
                                           boolean allowNullResponse,
                                           int maxRetries,
                                           long retryWaitTime)
                                    throws AttivioException
        Sends a message to endpointName synchronously, retrying on transport error.
        Parameters:
        msg - the message to send
        endpointName - a local avm queue name or a valid uri.
        maxRetries - maximum number of times to resend (unlimited = -1)
        retryWaitTime - how long to wait before retrying (in milliseconds)
        Returns:
        the platform message returned in response
        Throws:
        AttivioException - if endpointName is not a valid endpoint, or if the result is not an PlatformMessage, or if an exception is encountered while delivering the message
      • rawSend

        public static PlatformMessage rawSend​(PlatformMessage msg,
                                              java.lang.String endpointName,
                                              boolean synchronous)
                                       throws AttivioException
        Sends a message to the endpointName. Does not check for null or ExceptionResponse responses.
        Parameters:
        msg - the message to send
        endpointName - a local avm queue name or a valid uri.
        synchronous - indicates whether or not message should be sent synchronously
        Returns:
        the platform message
        Throws:
        AttivioException - if endpointName is not a valid endpoint or if the result is not an PlatformMessage
      • getNumberOfRetries

        public static long getNumberOfRetries()
        Returns:
        the number of times messages have been retried.
      • rawSendWithRetry

        public static PlatformMessage rawSendWithRetry​(PlatformMessage msg,
                                                       java.lang.String endpointName,
                                                       boolean synchronous)
                                                throws AttivioException
        Sends a message to the endpointName. Does not check for null or ExceptionResponse responses.

        If it is not possible to connect to the intended destination, the connection will be retried the number of times specified by the ENDPOINT_RETRY_MAX_PROPNAME property. If set to -1, there will be no limit to the number of retries. The time in between each retry is controlled by the ENDPOINT_RETRY_WAIT_TIME_PROPNAME property.

        Parameters:
        msg - the message to send
        endpointName - a local avm queue name or a valid uri.
        synchronous - indicates whether or not message should be sent synchronously
        Returns:
        the platform message
        Throws:
        AttivioException - if endpointName is not a valid endpoint or if the result is not an PlatformMessage
      • hasVisitedComponent

        public static boolean hasVisitedComponent​(PlatformMessage msg,
                                                  java.lang.String componentName)
        Parameters:
        msg -
        componentName -
        Returns:
        true if msg has ever been processed by the component.
      • getQueueURI

        public static java.lang.String getQueueURI​(java.lang.String name,
                                                   java.lang.String protocol)
        Returns the URI for the provided name using the configured vm queue implementation for the protocol if no protocol already set.
        Parameters:
        name - the name
        Returns:
        the URI
      • removeProtocolPrefix

        public static java.lang.String removeProtocolPrefix​(java.lang.String name)
      • getNodeURI

        public static java.lang.String getNodeURI​(java.lang.String name)
        Returns the URI for the provided name using the configured "node://" implementation for the protocol if no protocol already set.
        Parameters:
        name - the name
        Returns:
        the URI
      • isDefaultTransportQueuePresent

        public static boolean isDefaultTransportQueuePresent​(java.lang.String name)
        Call method usesDefaultTransport(String) first to validate uri to avoid IllegalArgumentException
        Parameters:
        name -
        Returns:
        true if the local queue is present on this node
        Throws:
        java.lang.IllegalArgumentException - if the uri is not a local queue
      • usesDefaultTransport

        public static boolean usesDefaultTransport​(java.lang.String uri)
        Parameters:
        uri -
        Returns:
        true if the destination uri will use the default transport protocol
      • setDefaultTransportProtocol

        public static void setDefaultTransportProtocol​(java.lang.String protocol)
        Sets the default protocol to be prepended to uris with no specified protocol.
        Parameters:
        protocol -
      • getDefaultTransportProtocol

        public static java.lang.String getDefaultTransportProtocol()
      • usesAieTransportProtocol

        public static boolean usesAieTransportProtocol​(java.lang.String workflowName)
        Parameters:
        workflowName -
        Returns:
        true if this workflow name uses the default transport protocol or node:
      • getMessageLogger

        public static AttivioLogger getMessageLogger​(java.lang.String workflowName,
                                                     java.lang.String componentName)
        Parameters:
        componentName -
        Returns:
        a logger used for logging internal message processing events