Class AbstractSequencingTaskGenerator

    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • DEFAULT_ACK_TIMEOUT

        private static final long DEFAULT_ACK_TIMEOUT
        Default timeout for the acknowledgement.
        See Also:
        Constant Field Values
      • ackTimeout

        private long ackTimeout
        Timeout for the acknowledgement.
      • seqTaskId

        private String seqTaskId
        Id of the task the generator is waiting for an acknowledgement.
      • taskIdMutex

        private Semaphore taskIdMutex
        Semaphore used to wait for the acknowledgement.
      • ackChannel

        protected com.rabbitmq.client.Channel ackChannel
        Channel on which the acknowledgments are received.
    • Constructor Detail

      • AbstractSequencingTaskGenerator

        public AbstractSequencingTaskGenerator()
    • Method Detail

      • handleAck

        protected void handleAck​(byte[] body)
        Handles the acknowledgement messages.
        Parameters:
        body - the body of the acknowledgement message
      • sendTaskToSystemAdapter

        protected void sendTaskToSystemAdapter​(String taskIdString,
                                               byte[] data)
                                        throws IOException
        Sends the given task with the given task id and data to the system and blocks until an acknowledgement has been received for the task or the timeout has been reached. If an information is needed which of these two cases happened sendTaskToSystemAdapterInSequence(String, byte[]) should be used.
        Overrides:
        sendTaskToSystemAdapter in class AbstractTaskGenerator
        Parameters:
        taskIdString - the id of the task
        data - the data of the task
        Throws:
        IOException - if there is an error during the sending
      • sendTaskToSystemAdapterInSequence

        protected boolean sendTaskToSystemAdapterInSequence​(String taskIdString,
                                                            byte[] data)
                                                     throws IOException
        Sends the given task with the given task id and data to the system and blocks until an acknowledgement has been received for the task or the timeout has been reached. The return value shows which of these two cases happened.
        Parameters:
        taskIdString - the task id
        data - the data of the task
        Returns:
        true if the acknowledgement has been received, false if the timeout has been reached or the method has been interrupted.
        Throws:
        IOException - if there is an error during the sending
      • setTaskIdToWaitFor

        @Deprecated
        protected void setTaskIdToWaitFor​(String taskId)
        Deprecated.
        It is not necessary anymore since its usage has been integrated into the sendTaskToSystemAdapterInSequence(String, byte[]) method.
        Method to set the task id for which the task generator will wait when calling waitForAck().
        Parameters:
        taskId - id of the task for which the acknowledgement should be received
      • waitForAck

        private boolean waitForAck()
        Method to wait for the acknowledgement of a task with the given Id.
        Returns:
        true if the acknowledgement has been received, false if the timeout has been reached or the method has been interrupted.
      • setAckTimeout

        public void setAckTimeout​(long ackTimeout)
        Setter for the maximum time the task generator waits for an acknowledgement.
        Parameters:
        ackTimeout - the new timeout in milliseconds