Home

Awesome

disruptor-proxy

Java CI with Gradle License

The disruptor-proxy is a tool for creating thread-safe proxies to your existing business code.

Utilising the power of the Disruptor, disruptor-proxy will provide a high-performance, low-latency multi-threaded interface to your single-threaded components.

This in turn allows users to exploit the single-writer principle for maximum straight-line performance.

implementation diagram

Maintainer

LMAX Development Team

Examples


// Basic usage

final RingBufferProxyGeneratorFactory generatorFactory = new RingBufferProxyGeneratorFactory();

final T tImpl = new ConcreteT();

final RingBufferProxyGenerator generator = generatorFactory.newProxy(GeneratorType.BYTECODE_GENERATION);

final T proxy = generator.createRingBufferProxy(T.class, disruptor, OverflowStrategy.DROP, tImpl);

disruptor.start();

// Get notified of end-of-batch events

final RingBufferProxyGeneratorFactory generatorFactory = new RingBufferProxyGeneratorFactory();

final T tImpl = new ConcreteT();
final BatchListener batchListener = (BatchListener) tImpl; // implement BatchListener in your component

final RingBufferProxyGenerator generator = generatorFactory.newProxy(GeneratorType.BYTECODE_GENERATION);

final T proxy = generator.createRingBufferProxy(T.class, disruptor, OverflowStrategy.DROP, tImpl);

disruptor.start();

// Get notified of buffer-overflow events

final RingBufferProxyGeneratorFactory generatorFactory = new RingBufferProxyGeneratorFactory();

final T tImpl = new ConcreteT();
final DropListener dropListener = new MyDropListener(); // handle drop events

final RingBufferProxyGenerator generator =
        generatorFactory.newProxy(GeneratorType.BYTECODE_GENERATION,
        new ConfigurableValidator(true, true),
        dropListener);

final T proxy = generator.createRingBufferProxy(T.class, disruptor, OverflowStrategy.DROP, tImpl);

disruptor.start();

GeneratorType

Dependencies

Minimal dependency is the Disruptor JAR.

If you are using byte-code generation for the proxy class (specified by GeneratorType), you'll also need the Javassist JAR.