Interface MessageHandler

  • All Known Implementing Classes:
    DummyMessageHandler

    public interface MessageHandler
    Interface that a MQ message handler should implement in order to send and recieve messages directly.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addListener​(MessageListener listener)
      Method to add a listener to this Message Handler, this method should be called before a connection.
      void addSender​(MessageSender sender)
      Method to add a sender to this Message Handler, this method should be called before a connection.
      void close()
      Method called by service if the MessageHandler should disconnect from the MessageQueue server.
      void connect()
      Method called by service if the MessageHandler should connect to the MessageQueue server and start processing incoming calls.
      java.lang.Object getConnectionFactory()
      Method returning the connection factory used to set-up the message queues.
      MessageListener getMessageListener​(java.lang.String name)
      Method to retrieved a message listener given it's name.
      MessageSender getMessageSender​(java.lang.String name)
      Method to retrieved a message sender given it's name.
      void init​(java.util.Properties config)
      Method called after instantiation and should check configuration and prepare everything for connection with the message queue server.
      boolean isConnected()
      Method returning if the handler is currently connected to the JMS broker.
      void sendMessage​(java.lang.String componentName, java.lang.String messageId, byte[] message, java.util.Map<java.lang.String,​java.lang.String> messageAttributes)
      Method to send a message to the MQ server out queue.
    • Method Detail

      • init

        void init​(java.util.Properties config)
           throws MessageProcessingException
        Method called after instantiation and should check configuration and prepare everything for connection with the message queue server.
        Parameters:
        config - the configuration.
        Throws:
        MessageProcessingException - if configuration problems or other internal problems occurred.
      • getConnectionFactory

        java.lang.Object getConnectionFactory()
                                       throws MessageProcessingException,
                                              java.io.IOException
        Method returning the connection factory used to set-up the message queues. Used only for special purposes when not extending the implementing class. Required method for extending classes to provide the connection factory to use when connecting to the message server.
        Returns:
        a connection factory to use to set up the message processing environment, never null.
        Throws:
        MessageProcessingException - if internal error or configuration problems occurred.
        java.io.IOException - if communication problems occurred with the message service.
      • addSender

        void addSender​(MessageSender sender)
        Method to add a sender to this Message Handler, this method should be called before a connection.
        Parameters:
        sender - a MessageSender implementation.
      • addListener

        void addListener​(MessageListener listener)
        Method to add a listener to this Message Handler, this method should be called before a connection.
        Parameters:
        listener - a MessageListener implementation.
      • connect

        void connect()
              throws MessageProcessingException,
                     java.io.IOException
        Method called by service if the MessageHandler should connect to the MessageQueue server and start processing incoming calls.
        Throws:
        MessageProcessingException - if configuration problems or other internal problems occurred connecting to the MQ server.
        java.io.IOException - if communication problems occurred connecting from the message server.
      • sendMessage

        void sendMessage​(java.lang.String componentName,
                         java.lang.String messageId,
                         byte[] message,
                         java.util.Map<java.lang.String,​java.lang.String> messageAttributes)
                  throws MessageProcessingException,
                         java.io.IOException
        Method to send a message to the MQ server out queue.
        Parameters:
        componentName - the componentName to use for sending.
        messageId - the id of the message
        message - the message data to send
        messageAttributes - meta data related to the message such as reply-to queues or correlation id etc if underlying implementation supports it. use null if no related message attributes exists.
        Throws:
        MessageProcessingException - if configuration problems or other internal problems occurred connecting to the MQ server.
        java.io.IOException - if communication problems occurred connecting and sending to the message server.
      • isConnected

        boolean isConnected()
        Method returning if the handler is currently connected to the JMS broker.
        Returns:
        true if connected.
      • close

        void close()
            throws java.io.IOException
        Method called by service if the MessageHandler should disconnect from the MessageQueue server.
        Throws:
        java.io.IOException - if communication problems occurred disconnecting from the message server.