Class JDBCMessageStore

    • Constructor Detail

      • JDBCMessageStore

        public JDBCMessageStore()
    • Method Detail

      • getProducer

        public MessageProducer getProducer()
        Description copied from interface: MessageStore
        Returns a Message Producer for this message store.
        Returns:
        A non-null message producer that can produce messages to this message store.
        See Also:
        MessageStore.getProducer()
      • getConsumer

        public MessageConsumer getConsumer()
        Description copied from interface: MessageStore
        Returns a Message Consumer for this message store.
        Returns:
        A non-null message consumer that can read messages from this message store.
        See Also:
        MessageStore.getConsumer()
      • getProcessedRows

        protected List<Map> getProcessedRows​(Statement statement)
        Will return the list of processed message rows.
        Parameters:
        statement - the statement executed in the DB.
        Returns:
        the rows which contains the column data wrapped inside a map.
      • deserializeMessage

        protected MessageContext deserializeMessage​(byte[] msgObj)
        Will convert the byte[] message to store-able message.
        Parameters:
        msgObj - serialized message read from the database.
        Returns:
        converted message context.
      • store

        public boolean store​(MessageContext messageContext)
                      throws SynapseException
        Add a message to the end of the table. If fetching success return true else false
        Parameters:
        messageContext - message to insert
        Returns:
        - success/failure of fetching
        Throws:
        SynapseException
      • getStoreMessageStatement

        protected Statement getStoreMessageStatement​(MessageContext messageContext,
                                                     Long sequenceId)
                                              throws StoreException

        Generates the statement to store message in database.

        If the sequence id is specified the corresponding sequence id will be stored, sequence id will be specified if re-sequence message store is being used. In other times this value will be null.

        Parameters:
        messageContext - the content of the message.
        sequenceId - the sequence id of the message (optional).
        Returns:
        SQL statement for insertion of value to store.
        Throws:
        StoreException - at an event there's an exception when generating the statement.
        See Also:
        ResequenceMessageStore
      • removeMessageStatement

        protected List<Statement> removeMessageStatement​(String msgId)
        Statement to remove the message once a response is received.
        Parameters:
        msgId - message id of the statement which should be removed.
        Returns:
        the sql remove message statement.
      • clear

        public void clear()
        Delete all entries from table
      • get

        public MessageContext get​(int position)
        Get the message at given position Only can be done with MYSQL, and no use-case in current implementation
        Parameters:
        position - - position of the message , starting value is 0
        Returns:
        Message Context of position th row or if failed return null
      • getAll

        public List<MessageContext> getAll()
        Get all messages in the table
        Returns:
        - List containing all message contexts in the store
      • get

        public MessageContext get​(String msgId)
        Return the first element with given msg_id
        Parameters:
        msgId - - Message ID
        Returns:
        - returns the first result found else null
      • messageContentResultSet

        protected List<Map> messageContentResultSet​(ResultSet resultSet,
                                                    String statement)
                                             throws SQLException

        Return the messages corresponding to the provided statement.

        Parameters:
        resultSet - the result-set obtained from the statement.
        statement - the SQL statement results are obtained for.
        Returns:
        the content of the messages.
        Throws:
        SQLException - during an error encountered when accessing the database.