From 09b8b13fb247484f16acebd3515bfe73388c46f6 Mon Sep 17 00:00:00 2001 From: marc-adaptive Date: Wed, 24 Jul 2024 09:02:00 -0400 Subject: [PATCH] [Java] Fix Basic Client and Server Samples --- .../uk/co/real_logic/artio/client/SampleClient.java | 2 ++ .../co/real_logic/artio/example_buyer/BuyerAgent.java | 7 ++++++- .../artio/example_buyer/BuyerApplication.java | 2 ++ .../artio/example_exchange/ExchangeApplication.java | 7 +++++++ .../example_fixp_exchange/FixPExchangeApplication.java | 7 +++++++ .../uk/co/real_logic/artio/server/SampleServer.java | 10 ++++++++++ 6 files changed, 34 insertions(+), 1 deletion(-) diff --git a/artio-samples/src/main/java/uk/co/real_logic/artio/client/SampleClient.java b/artio-samples/src/main/java/uk/co/real_logic/artio/client/SampleClient.java index 7dd6bfd93f..5732334385 100644 --- a/artio-samples/src/main/java/uk/co/real_logic/artio/client/SampleClient.java +++ b/artio-samples/src/main/java/uk/co/real_logic/artio/client/SampleClient.java @@ -74,6 +74,7 @@ public static void main(final String[] args) archiveContext .controlChannel(CONTROL_REQUEST_CHANNEL) + .replicationChannel(REPLICATION_CHANNEL) .recordingEventsChannel(RECORDING_EVENTS_CHANNEL); try (ArchivingMediaDriver driver = ArchivingMediaDriver.launch(context, archiveContext)) @@ -153,4 +154,5 @@ private static SessionHandler onConnect(final Session session) private static final String CONTROL_REQUEST_CHANNEL = "aeron:udp?endpoint=localhost:7010"; private static final String CONTROL_RESPONSE_CHANNEL = "aeron:udp?endpoint=localhost:7020"; private static final String RECORDING_EVENTS_CHANNEL = "aeron:udp?control-mode=dynamic|control=localhost:7030"; + private static final String REPLICATION_CHANNEL = "aeron:udp?endpoint=localhost:0"; } diff --git a/artio-samples/src/main/java/uk/co/real_logic/artio/example_buyer/BuyerAgent.java b/artio-samples/src/main/java/uk/co/real_logic/artio/example_buyer/BuyerAgent.java index 38e300d0cc..a537e35a00 100644 --- a/artio-samples/src/main/java/uk/co/real_logic/artio/example_buyer/BuyerAgent.java +++ b/artio-samples/src/main/java/uk/co/real_logic/artio/example_buyer/BuyerAgent.java @@ -7,8 +7,11 @@ import uk.co.real_logic.artio.library.FixLibrary; import uk.co.real_logic.artio.library.LibraryConfiguration; +import java.io.File; + import static io.aeron.CommonContext.IPC_CHANNEL; import static java.util.Collections.singletonList; +import static uk.co.real_logic.artio.CommonConfiguration.optimalTmpDirName; import static uk.co.real_logic.artio.example_buyer.BuyerApplication.AERON_DIRECTORY_NAME; import static uk.co.real_logic.artio.example_buyer.BuyerApplication.RECORDING_EVENTS_CHANNEL; import static uk.co.real_logic.artio.example_exchange.ExchangeApplication.cleanupOldLogFileDir; @@ -23,7 +26,9 @@ public class BuyerAgent implements Agent public void onStart() { final EngineConfiguration engineConfiguration = new EngineConfiguration() - .libraryAeronChannel(IPC_CHANNEL); + .libraryAeronChannel(IPC_CHANNEL) + .monitoringFile(optimalTmpDirName() + File.separator + "fix-buyer" + File.separator + "engineCounters") + .logFileDir("buyer-logs"); engineConfiguration .aeronContext() diff --git a/artio-samples/src/main/java/uk/co/real_logic/artio/example_buyer/BuyerApplication.java b/artio-samples/src/main/java/uk/co/real_logic/artio/example_buyer/BuyerApplication.java index 20b5deb96a..279e4843ad 100644 --- a/artio-samples/src/main/java/uk/co/real_logic/artio/example_buyer/BuyerApplication.java +++ b/artio-samples/src/main/java/uk/co/real_logic/artio/example_buyer/BuyerApplication.java @@ -21,6 +21,7 @@ import io.aeron.driver.MediaDriver; import uk.co.real_logic.artio.SampleUtil; +import static io.aeron.archive.Archive.Configuration.REPLICATION_CHANNEL_PROP_NAME; import static io.aeron.archive.client.AeronArchive.Configuration.CONTROL_CHANNEL_PROP_NAME; import static io.aeron.archive.client.AeronArchive.Configuration.CONTROL_RESPONSE_CHANNEL_PROP_NAME; import static io.aeron.driver.ThreadingMode.SHARED; @@ -37,6 +38,7 @@ public static void main(final String[] args) throws InterruptedException { System.setProperty(CONTROL_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:9010"); System.setProperty(CONTROL_RESPONSE_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:9020"); + System.setProperty(REPLICATION_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:0"); final MediaDriver.Context context = new MediaDriver.Context() .threadingMode(SHARED) diff --git a/artio-samples/src/main/java/uk/co/real_logic/artio/example_exchange/ExchangeApplication.java b/artio-samples/src/main/java/uk/co/real_logic/artio/example_exchange/ExchangeApplication.java index f421d98e42..8cd70c0d53 100644 --- a/artio-samples/src/main/java/uk/co/real_logic/artio/example_exchange/ExchangeApplication.java +++ b/artio-samples/src/main/java/uk/co/real_logic/artio/example_exchange/ExchangeApplication.java @@ -31,6 +31,9 @@ import java.util.Collections; import static io.aeron.CommonContext.IPC_CHANNEL; +import static io.aeron.archive.Archive.Configuration.REPLICATION_CHANNEL_PROP_NAME; +import static io.aeron.archive.client.AeronArchive.Configuration.CONTROL_CHANNEL_PROP_NAME; +import static io.aeron.archive.client.AeronArchive.Configuration.CONTROL_RESPONSE_CHANNEL_PROP_NAME; import static io.aeron.driver.ThreadingMode.SHARED; import static uk.co.real_logic.artio.CommonConfiguration.backoffIdleStrategy; @@ -41,6 +44,10 @@ public final class ExchangeApplication public static void main(final String[] args) throws Exception { + System.setProperty(CONTROL_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:10010"); + System.setProperty(CONTROL_RESPONSE_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:10020"); + System.setProperty(REPLICATION_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:0"); + final MessageValidationStrategy validationStrategy = MessageValidationStrategy.targetCompId(ACCEPTOR_COMP_ID) .and(MessageValidationStrategy.senderCompId(Collections.singletonList(INITIATOR_COMP_ID))); diff --git a/artio-samples/src/main/java/uk/co/real_logic/artio/example_fixp_exchange/FixPExchangeApplication.java b/artio-samples/src/main/java/uk/co/real_logic/artio/example_fixp_exchange/FixPExchangeApplication.java index 0832aa7c8e..500709566e 100644 --- a/artio-samples/src/main/java/uk/co/real_logic/artio/example_fixp_exchange/FixPExchangeApplication.java +++ b/artio-samples/src/main/java/uk/co/real_logic/artio/example_fixp_exchange/FixPExchangeApplication.java @@ -29,6 +29,9 @@ import java.io.File; import static io.aeron.CommonContext.IPC_CHANNEL; +import static io.aeron.archive.Archive.Configuration.REPLICATION_CHANNEL_PROP_NAME; +import static io.aeron.archive.client.AeronArchive.Configuration.CONTROL_CHANNEL_PROP_NAME; +import static io.aeron.archive.client.AeronArchive.Configuration.CONTROL_RESPONSE_CHANNEL_PROP_NAME; import static io.aeron.driver.ThreadingMode.SHARED; import static uk.co.real_logic.artio.CommonConfiguration.backoffIdleStrategy; @@ -40,6 +43,10 @@ public final class FixPExchangeApplication { public static void main(final String[] args) throws Exception { + System.setProperty(CONTROL_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:10010"); + System.setProperty(CONTROL_RESPONSE_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:10020"); + System.setProperty(REPLICATION_CHANNEL_PROP_NAME, "aeron:udp?endpoint=localhost:0"); + // Static configuration lasts the duration of a FIX-Gateway instance final EngineConfiguration configuration = new EngineConfiguration() .bindTo("localhost", 9999) diff --git a/artio-samples/src/main/java/uk/co/real_logic/artio/server/SampleServer.java b/artio-samples/src/main/java/uk/co/real_logic/artio/server/SampleServer.java index f96893fc82..3fe5adbe4c 100644 --- a/artio-samples/src/main/java/uk/co/real_logic/artio/server/SampleServer.java +++ b/artio-samples/src/main/java/uk/co/real_logic/artio/server/SampleServer.java @@ -63,6 +63,10 @@ public static void main(final String[] args) .libraryAeronChannel(aeronChannel); configuration.authenticationStrategy(authenticationStrategy); + configuration.aeronArchiveContext() + .controlRequestChannel(CONTROL_REQUEST_CHANNEL) + .controlResponseChannel(CONTROL_RESPONSE_CHANNEL); + cleanupOldLogFileDir(configuration); final Context context = new Context() @@ -71,6 +75,8 @@ public static void main(final String[] args) final Archive.Context archiveContext = new Archive.Context() .threadingMode(ArchiveThreadingMode.SHARED) + .controlChannel(CONTROL_REQUEST_CHANNEL) + .replicationChannel(REPLICATION_CHANNEL) .deleteArchiveOnStart(true); try (ArchivingMediaDriver driver = ArchivingMediaDriver.launch(context, archiveContext); @@ -121,4 +127,8 @@ private static SessionHandler onConnect(final Session session) return new SampleSessionHandler(session); } + + private static final String CONTROL_REQUEST_CHANNEL = "aeron:udp?endpoint=localhost:8010"; + private static final String CONTROL_RESPONSE_CHANNEL = "aeron:udp?endpoint=localhost:8020"; + private static final String REPLICATION_CHANNEL = "aeron:udp?endpoint=localhost:0"; }