Benthos is a service that bridges message queues in ways that can simplify your platform or reduce development time.
A range of optional buffer strategies are available, allowing you to select a balance between latency, protection against back pressure and file based persistence, or nothing at all (direct bridge).
Currently supported input/output targets:
- ZMQ4 (PUSH, PULL, SUB, PUB)
- Nanomsg/Scalability Protocols (PUSH, PULL, SUB, PUB)
- RabbitMQ (AMQP 0.91)
- NSQ
- NATS
- NATS Streaming
- Redis Pub/Sub
- Kafka
- HTTP 1.1 POST/GET
- STDIN/STDOUT
- File
Setting up multiple outputs or inputs is done by choosing a routing strategy (fan-in, fan-out, round-robin, etc.)
For a full and up to date list of all inputs, buffer options, processors, and outputs you can find them in the docs, or print them from the binary:
# Print inputs, buffers and output options
benthos --list-inputs --list-buffers --list-outputs --list-processors | less
Mixing multiple part message protocols with single part can be done in different ways, for more guidance check out this doc.
Build with Go:
go get github.com/Jeffail/benthos/cmd/benthos
Or, pull the docker image:
docker pull jeffail/benthos
benthos -c ./config.yaml
Or, with docker:
# Send HTTP /POST data to Kafka:
docker run --rm \
-e "BENTHOS_INPUT=http_server" \
-e "BENTHOS_OUTPUT=kafka" \
-e "KAFKA_OUTPUT_BROKER_ADDRESSES=kafka-server:9092" \
-e "KAFKA_OUTPUT_TOPIC=benthos_topic" \
-p 4195:4195 \
jeffail/benthos
# Using your own config file:
docker run --rm -v /path/to/your/config.yaml:/benthos.yaml jeffail/benthos
Benthos has inputs, optional processors, an optional buffer, and outputs, which are all set in a single config file.
Check out the samples in ./config, or create a fully populated default configuration file:
benthos --print-yaml > config.yaml
benthos --print-json > config.json
The configuration file should contain a section for an input, output, and a buffer. For example, if we wanted to output to a ZMQ4 push socket our output section in a YAML config might look like this:
output:
type: zmq4
zmq4:
addresses:
- tcp://*:1234
socket_type: PUSH
There are also configuration sections for logging and metrics, if you print an example config you will see the available options.
For a list of metrics within Benthos check out this spec.
You can use environment variables to replace fields in your config files.
Benthos supports ZMQ4 for both data input and output. To add this you need to install libzmq4 and use the compile time flag when building Benthos:
go install -tags "ZMQ4" ./cmd/...
Benthos uses dep for managing dependencies. To get started make sure you have dep installed:
go get -u github.com/golang/dep/cmd/dep
And then run dep ensure
. You can decrease the size of vendor by only storing
needed files with dep prune
.
There's a multi-stage Dockerfile
for creating a Benthos docker image which
results in a minimal image from scratch. You can build it with:
make docker
Then use the image:
docker run --rm \
-v /path/to/your/benthos.yaml:/config.yaml \
-v /tmp/data:/data \
-p 4195:4195 \
benthos -c /config.yaml
There are a few examples here that show you some ways of setting up Benthos
containers using docker-compose
.