@Override
  public void addedDistributedSystem(int remoteDsId) {
    cache = CacheFactory.getAnyInstance();

    // When a site with distributed-system-id = 2 joins, create a region and a gatewaysender with
    // remoteDsId = 2
    if (remoteDsId == 2) {
      if (cache != null) {
        GatewaySender serialSender =
            cache.createGatewaySenderFactory().setManualStart(true).setPersistenceEnabled(false)
                .setDiskStoreName("LN_" + remoteDsId).create("LN_" + remoteDsId, remoteDsId);
        System.out.println("Sender Created : " + serialSender.getId());

        Region region = cache.createRegionFactory()
            // .addSerialGatewaySenderId("LN_" + remoteDsId)
            .create("MyRegion");
        System.out.println("Created Region : " + region.getName());

        try {
          serialSender.start();
          System.out.println("Sender Started: " + serialSender.getId());
        } catch (Exception e) {
          e.printStackTrace();
        }
      } else {
        throw new CacheClosedException("Cache is not initialized here");
      }
    } else { // When a site with distributed-system-id = 1 joins, create a region and a
             // gatewayReceiver with
      if (cache != null) {
        Region region = cache.createRegionFactory().create("MyRegion");
        System.out.println("Created Region :" + region.getName());

        GatewayReceiver receiver =
            cache.createGatewayReceiverFactory().setStartPort(12345).setManualStart(true).create();
        System.out.println("Created GatewayReceiver : " + receiver);
        try {
          receiver.start();
          System.out.println("GatewayReceiver Started.");
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
Please note that dynamic addition of the sender id to region is not yet available.
geode-core/src/test/java/com/main/MyDistributedSystemListener.java