psdi.iface.jms

Class MessageErrorHandler

  • java.lang.Object
    • psdi.iface.jms.MessageErrorHandler


  • public class MessageErrorHandler
    extends java.lang.Object
    This is the class for handling the error processing logic in MEA. This will take the error message as input and will be able to generate an error file in the error folder. The file name will be based on the unique id property set on the message by the producer. This will also have APIs to get the corrected message from the "retry" folder. Since a JMS Message is in "readOnly" state after receive - the error message and the error count for a failure scenario has to be stored in the "CONTROLAREA" block in the error xml file.
    • Constructor Summary

      Constructors 
      Constructor and Description
      MessageErrorHandler(java.lang.String queue)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int canProcess(java.util.Map properties)
      Select status and deleteflag to process message
      int canProcess(java.util.Map properties, java.lang.String status, int deleteFlag, int tryCount)
      Select status and deleteflag to process message
      protected void deleteErrorTable(java.lang.String messageID, java.sql.Connection conn)
      Delete data from error message tables
      void emailError(java.lang.Throwable t, java.lang.String uniqueId)
      Email the incoming error having error file name info in the email.
      boolean emailToBeSent(java.util.Map msgProperties)
      Check if email needs to go out or it's already been sent depending upon if error record exists for a given queue or not
      JMSData getCorrectedFile(JMSData data)
      Return the appropriate data for the given incoming data.
      JMSData getErrorMsgForSeqQueue(java.lang.String queueName) 
      JMSData getJMSData(java.util.Map msgProperties)
      Take in incoming file name and return back it's relevant JMS Data object for further processing.
      boolean handleError(java.lang.Throwable t, java.util.Map msgProperties)
      Do whatever is needed to handle the error occure while processing the message.
      void initializeEmailInfo()
      Initialize the email information for a given queue.
      protected boolean insertErrorTable(java.util.Map msgProperties, java.lang.String errorMessage, java.lang.String msgId, java.sql.Connection conn, java.lang.String personId, java.sql.Timestamp currDate, byte[] extErrorData, byte[] intErrorData)
      Insert data to error message tables
      void setMaxTryCount(int newMaxTryCount)
      Called on refresh of MaxQueueCache to reset try count
      void success(JMSData data)
      Perform necessary actions upon successful processing of the message.
      protected boolean updateToJMSError(java.lang.String messageId, java.sql.Connection conn, java.lang.String personId, java.sql.Timestamp currDate)
      Update data in error message tables
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MessageErrorHandler

        public MessageErrorHandler(java.lang.String queue)
        Constructor
        Parameters:
        queue - Name of the queue that is the handler is associate with
    • Method Detail

      • initializeEmailInfo

        public void initializeEmailInfo()
        Initialize the email information for a given queue.
      • canProcess

        public int canProcess(java.util.Map properties)
                       throws MXException
        Select status and deleteflag to process message
        Parameters:
        proprties - map of all message properties
        Returns:
        0 for process 1 for delete 2 for rollback
        Throws:
        MXException - MAXIMO exception
      • canProcess

        public int canProcess(java.util.Map properties,
                              java.lang.String status,
                              int deleteFlag,
                              int tryCount)
                       throws MXException,
                              java.rmi.RemoteException
        Select status and deleteflag to process message
        Parameters:
        proprties - map of all message properties
        Returns:
        0 for process 1 for delete 2 for rollback
        Throws:
        MXException - MAXIMO exception
        java.rmi.RemoteException
      • handleError

        public boolean handleError(java.lang.Throwable t,
                                   java.util.Map msgProperties)
        Do whatever is needed to handle the error occure while processing the message.
        Parameters:
        t - exception
        properties - map of all message properties
        Returns:
        0 for sucess 1 error
      • getCorrectedFile

        public JMSData getCorrectedFile(JMSData data)
        Return the appropriate data for the given incoming data. It could be either the retry file or error file or original data depending upon error-retry situation that is existing
        Parameters:
        data - data from the queue
        Returns:
        data from the error file or original data from the queue
      • success

        public void success(JMSData data)
        Perform necessary actions upon successful processing of the message. These actions would include error/retry file cleanup tasks.
        Parameters:
        data - data from the queue
      • getJMSData

        public JMSData getJMSData(java.util.Map msgProperties)
                           throws MXException
        Take in incoming file name and return back it's relevant JMS Data object for further processing.
        Parameters:
        properties - map of all message properties
        filename - name of the file
        Returns:
        data from the error file or original data from the queue
        Throws:
        MXException - MAXIMO exception
      • emailError

        public void emailError(java.lang.Throwable t,
                               java.lang.String uniqueId)
        Email the incoming error having error file name info in the email.
        Parameters:
        t - exception from the processing
        errorFileName - error file name
      • emailToBeSent

        public boolean emailToBeSent(java.util.Map msgProperties)
                              throws MXException,
                                     java.rmi.RemoteException
        Check if email needs to go out or it's already been sent depending upon if error record exists for a given queue or not
        Parameters:
        msgProperties - map of all message properties
        Returns:
        0 for success 1 error
        Throws:
        java.rmi.RemoteException - Remote exception
        MXException
      • insertErrorTable

        protected boolean insertErrorTable(java.util.Map msgProperties,
                                           java.lang.String errorMessage,
                                           java.lang.String msgId,
                                           java.sql.Connection conn,
                                           java.lang.String personId,
                                           java.sql.Timestamp currDate,
                                           byte[] extErrorData,
                                           byte[] intErrorData)
                                    throws MXException
        Insert data to error message tables
        Parameters:
        msgProperties - message properties
        errorMessage - error message
        conn - database connection to execute statement
        personId - id of a person who initiated transaction
        currDate - current data and time
        Throws:
        MXException - MAXIMO exception
      • deleteErrorTable

        protected void deleteErrorTable(java.lang.String messageID,
                                        java.sql.Connection conn)
                                 throws MXException
        Delete data from error message tables
        Parameters:
        messagID - unique ID of the message
        conn - database connection to excute statement
        Throws:
        MXException - MAXIMO exception
      • setMaxTryCount

        public void setMaxTryCount(int newMaxTryCount)
        Called on refresh of MaxQueueCache to reset try count
        Parameters:
        newMaxTryCount - new try count configured for the queue
      • updateToJMSError

        protected boolean updateToJMSError(java.lang.String messageId,
                                           java.sql.Connection conn,
                                           java.lang.String personId,
                                           java.sql.Timestamp currDate)
                                    throws MXException
        Update data in error message tables
        Parameters:
        msgProperties - message properties
        errorMessage - error message
        conn - database connection to execute statement
        personId - id of a person who initiated transaction
        currDate - current data and time
        Throws:
        MXException - MAXIMO exception