Class ConcurrentMessageProcessor

  • All Implemented Interfaces:
    java.lang.Runnable

    public class ConcurrentMessageProcessor
    extends java.lang.Object
    implements java.lang.Runnable
    This class connects a message producer with a message consumer by listening for new messages in a dedicated thread.
    • Method Detail

      • startProcessing

        @Deprecated
        public static java.util.concurrent.Future<java.lang.Void> startProcessing​(MessageProducer messageProducer,
                                                                                  MessageConsumer messageConsumer,
                                                                                  java.util.concurrent.ExecutorService executorService)
        Deprecated.
        Start a thread that listens for messages in the message producer and forwards them to the message consumer.
        Parameters:
        messageProducer - - produces messages, e.g. by reading from an input channel
        messageConsumer - - processes messages and potentially forwards them to other consumers
        executorService - - the thread is started using this service
        Returns:
        a future that is resolved when the started thread is terminated, e.g. by closing a stream
      • wrapFuture

        public static java.util.concurrent.Future<java.lang.Void> wrapFuture​(java.util.concurrent.Future<?> result,
                                                                             MessageProducer messageProducer)
      • beginProcessing

        public java.util.concurrent.Future<java.lang.Void> beginProcessing​(java.util.concurrent.ExecutorService executorService)
        Start a thread that listens for messages in the message producer and forwards them to the message consumer.
        Parameters:
        executorService - - the thread is started using this service
        Returns:
        a future that is resolved when the started thread is terminated, e.g. by closing a stream
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • processingStarted

        protected void processingStarted()
      • processingEnded

        protected void processingEnded()