Skip to content

lob-software/aeronic

Repository files navigation

Java CI with Gradle License

aeronic

Usage:

repositories {
    mavenCentral()
    maven {
        setUrl("https://dl.cloudsmith.io/public/lob-software/aeronic/maven/")
    }
}

dependencies {
    annotationProcessor("io.aeronic:aeronic:0.0.16")
    implementation("io.aeronic:aeronic:0.0.16")
}

Quickstart

Aeronic allows for flexible usage of Aeron by way of proxy generation for subscriptions and publications. Use @Aeronic to make the compiler generate subscriber and publisher proxies:

@Aeronic
public interface TradeEvents
{
    void onTrade(long price);
}

A subscriber, containing business logic can then be defined by implementing the interface:

public class TradeEventsImpl implements TradeEvents
{

    private long lastPrice;

    @Override
    public void onTrade(final long price)
    {
        this.lastPrice = price;
    }

    public long getLastPrice()
    {
        return lastPrice;
    }
}

AeronicWizard can then be used to create a publisher of type TradeEvents and bind a subscriber implemented above. The two will communicate via a given Aeron channel / stream ID:

final Aeron aeron = Aeron.connect(aeronCtx);
final AeronicImpl aeronic = new AeronicImpl(aeron);

final TradeEvents eventsPublisher = aeronic.createPublisher(TradeEvents.class, "aeron:ipc", 10);
final TradeEventsImpl subscriberImpl = new TradeEventsImpl();
aeronic.registerSubscriber(TradeEvents.class, subscriberImpl, "aeron:ipc", 10);

publisher.onTrade(123L);
subscriberImpl.getLastPrice(); // 123L