Can I have 2 different Egress from AeronCluster?

244 Views Asked by At

Can I have 2 different Egress from AeronCluster?

1

There are 1 best solutions below

2
On

Aeron Cluster can only have a single ingress and egress channel. However, you can create additional publications within a ClusteredService, e.g:

public class FooService implements ClusteredService
{
    private Publication publication;
    private DirectBuffer someMessage;

    public void onStart(final Cluster cluster, final Image snapshotImage)
    {
        publication = cluster.aeron().addPublication("aeron:udp?endpoint=somewhere.com:2020", 10001);
    }

    public void onSessionMessage(
        final ClientSession session,
        final long timestamp,
        final DirectBuffer buffer,
        final int offset,
        final int length,
        final Header header)
    {
        publication.offer(someMessage);
    }

However, when doing this you need to decide if you want only the leader to publish or all nodes and how you would potentially deal with duplicated messages.