Influent is a library to implement a Fluentd's forward server on the JVM.
influent.forward.ForwardServer
is almost compatible with Forward Protocol Specification v1.
This is the protocol for Fluentd's forward plugin.
Influent is a server implementation, so behaves as like in_forward
.
There are some features that Influent does not support now.
See also the TODO
section.
There are some reasons why Influent is developed.
Influent enables users to handle Fluentd's events by Java. This means that they can use directly their domain logic written in Java or Java client APIs for some middleware.
JVM has high performance and Java has good thread API and IO API. Influent makes it possible to upgrade performance for some applications.
- handshake phase implementation
- CompressedPackedForward mode implementation
- TLS support
- load test and performance improvement
- Scala API
<dependency>
<groupId>com.okumin</groupId>
<artifactId>influent-java</artifactId>
<version>0.3.0</version>
</dependency>
Give ForwardServer
the callback function that receives EventStream
.
If you want to write EventStreams
to stdout,
// The callback function
ForwardCallback callback = ForwardCallback.ofSyncConsumer(
stream -> System.out.println(stream),
Executors.newFixedThreadPool(1)
);
// Constructs a new server
int port = 24224;
ForwardServer server = new ForwardServer
.Builder(callback)
.localAddress(port)
.build();
// Starts the server on a new thread
server.start();
Thread.sleep(60 * 1000);
// ForwardServer#shutdown returns a CompletableFuture
CompletableFuture<Void> stopping = server.shutdown();
// The future will be completed when the server is terminated
stopping.get();
Execute the above code, and send a message by fluent-cat
command.
$ echo '{"foo": "bar", "scores": [33, 4]}' | fluent-cat mofu
The received EventStream
is written to stdout.
EventStream(Tag(mofu), [EventEntry(2016-11-13T13:10:59Z,{"foo":"bar","scores":[33,4]})])