is there any best practice to handle concurrency on publish side?? assume that we have a client that wants to handle 1 Million concurrent requests, these requests must send to the Aeron server-side via publication offer. now we have a singleton expandable array buffer that overwrites and is corrupted by concurrency.
CodePudding user response:
From the description of the problem, you should benefit from using https://github.com/real-logic/agrona/blob/master/agrona/src/main/java/org/agrona/concurrent/ringbuffer/ManyToOneRingBuffer.java and then implement the MessageHandler that makes use of io.aeron.ExclusivePublication#offer
.
CodePudding user response:
It depends on how the Publication
is being created, i.e. the io.aeron.Aeron#addPublication
returns an instance of the ConcurrentPublication
class which as the name suggest can be used by multiple threads concurrently. The io.aeron.Aeron#addExclusivePublication
on the other hand returns an ExclusivePublication
instance which can only be used by a single thread.
@mohamadreza: Why would you use a single shared expandable array buffer?