src/main/java/com/io7m/aeron_guide/take3/AeronMessagingClient.java
/**
     * Create a new client.
     *
     * @param configuration The client configuration data
     *
     * @return A new client
     *
     * @throws EchoClientCreationException On any initialization error
     */
Create a new client.
@param configuration The client configuration data

@return A new client

@throws EchoClientCreationException On any initialization error
Create a new client . @param configuration The client configuration data @return A new client @throws EchoClientCreationException On any initialization error
public static AeronMessagingClient create(
            final AeronMessagingClientConfiguration configuration)
            throws EchoClientException {
        Objects.requireNonNull(configuration, "configuration");
        final String directory
                = configuration.baseDirectory()
                        .toAbsolutePath()
                        .toString();
        final MediaDriver.Context media_context
                = new MediaDriver.Context()
                        .dirDeleteOnStart(true)
                        .publicationReservedSessionIdLow(AeronMessagingServerSessions.RESERVED_SESSION_ID_LOW)
                        .publicationReservedSessionIdHigh(AeronMessagingServerSessions.RESERVED_SESSION_ID_HIGH)
                        .aeronDirectoryName(directory);
        final Aeron.Context aeron_context
                = new Aeron.Context().aeronDirectoryName(directory);
        MediaDriver media_driver = null;
        try {
            media_driver = MediaDriver.launch(media_context);
            Aeron aeron = null;
            try {
                aeron = Aeron.connect(aeron_context);
            } catch (final Exception e) {
                closeIfNotNull(aeron);
                throw e;
            }
            return new AeronMessagingClient(media_driver, aeron, configuration);
        } catch (final Exception e) {
            try {
                closeIfNotNull(media_driver);
            } catch (final Exception c_ex) {
                e.addSuppressed(c_ex);
            }
            throw new EchoClientCreationException(e);
        }
    }
public static AeronMessagingClient create ( final AeronMessagingClientConfiguration configuration ) throws EchoClientException { Objects . requireNonNull ( configuration , "configuration" ) ; final String directory = configuration . baseDirectory ( ) . toAbsolutePath ( ) . toString ( ) ; final MediaDriver . Context media_context = new MediaDriver . Context ( ) . dirDeleteOnStart ( true ) . publicationReservedSessionIdLow ( AeronMessagingServerSessions . RESERVED_SESSION_ID_LOW ) . publicationReservedSessionIdHigh ( AeronMessagingServerSessions . RESERVED_SESSION_ID_HIGH ) . aeronDirectoryName ( directory ) ; final Aeron . Context aeron_context = new Aeron . Context ( ) . aeronDirectoryName ( directory ) ; MediaDriver media_driver = null ; try { media_driver = MediaDriver . launch ( media_context ) ; Aeron aeron = null ; try { aeron = Aeron . connect ( aeron_context ) ; } catch ( final Exception e ) { closeIfNotNull ( aeron ) ; throw e ; } return new AeronMessagingClient ( media_driver , aeron , configuration ) ; } catch ( final Exception e ) { try { closeIfNotNull ( media_driver ) ; } catch ( final Exception c_ex ) { e . addSuppressed ( c_ex ) ; } throw new EchoClientCreationException ( e ) ; } }
Create a new client.
Create a new client .