Skip to content
James Baker edited this page Apr 27, 2017 · 2 revisions

Whilst Baleen is generally used as a standalone server, it is possible to embed Baleen pipelines within other applications. The following shows a very simple instance of this, although it is possible to control and configure Baleen to a much greater extent than shown. For full details of how to use each class, refer to the JavaDoc

This code demonstrates running Baleen from a Java application:

public class EmbeddedPipeline{

	public static void main(String[] args) throws Exception {
		String yaml = new String(Files.readAllBytes(Paths.get(args[0])));
		
		PipelineBuilder builder = new PipelineBuilder("My Embedded Pipeline", yaml);
		BaleenPipeline pipeline = builder.createNewPipeline();
		
		pipeline.run();
	}

}

The pipeline will continue running until pipeline.destroy() is called - note that you may need to do this from a different thread.