javafiberquasar

Passing Messages Between Fibers Quasar


I am using a quasar fiber to listen to and process messages on a QueueObjectChannel. I am not sure what Object I am supposed to use as the message queue between fibers. The problem I am having is I don't understand what is supposed to be passed into the QueueObjectChannel Constructor. According to the javadoc the constructor is supposed to take QueueObjectChannel(co.paralleluniverse.strands.queues.BasicQueue<Message> queue, Channels.OverflowPolicy policy, boolean singleProducer, boolean singleConsumer) but that seems counterintuitive because I am trying to build something that implements BasicQueue.

Am I supposed to implement the interface?

Is my understanding of inter fiber communication completely off?


Solution

  • Usually one wants to (and should) use the channels API, not the backing queues. For example different queue implementations can only work and/or are only optimal with some data types, with threads and/or fibers, with a specific buffer configuration, when there's a single consumer etc.

    As explained here just use the static Channels.new*Channel methods passing in the properties you need and you'll get a channel backed by a queue that is tailor-suited to your use case.