Skip to content

Commit

Permalink
[Java] Fix Basic Client and Server Samples
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-adaptive committed Jul 24, 2024
1 parent be61f2e commit 09b8b13
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand Down Expand Up @@ -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";
}

0 comments on commit 09b8b13

Please sign in to comment.