use of io.aeron.Subscription in project Aeron by real-logic.
the class FileReceiver method main.
/**
* Main method for launching the process.
*
* @param args passed to the process.
*/
public static void main(final String[] args) {
final File storageDir;
if (args.length > 1) {
storageDir = new File(args[0]);
if (!storageDir.isDirectory()) {
System.out.println(args[0] + " is not a directory");
System.exit(1);
}
} else {
storageDir = new File(SystemUtil.tmpDirName());
}
System.out.println("Files stored to " + storageDir.getAbsolutePath());
final IdleStrategy idleStrategy = new SleepingMillisIdleStrategy(1);
final AtomicBoolean running = new AtomicBoolean(true);
SigInt.register(() -> running.set(false));
try (MediaDriver mediaDriver = MediaDriver.launch();
Aeron aeron = Aeron.connect(new Aeron.Context().aeronDirectoryName(mediaDriver.aeronDirectoryName()));
Subscription subscription = aeron.addSubscription(CHANNEL, STREAM_ID)) {
System.out.println("Receiving from " + CHANNEL + " on stream id " + STREAM_ID);
final FileReceiver fileReceiver = new FileReceiver(storageDir, subscription);
while (running.get()) {
idleStrategy.idle(fileReceiver.doWork());
}
}
}
use of io.aeron.Subscription in project Aeron by real-logic.
the class IngressAdapter method close.
public void close() {
final Subscription subscription = this.subscription;
this.subscription = null;
fragmentAssembler.clear();
if (null != subscription) {
subscription.close();
}
}
Aggregations