• Stars
    star
    343
  • Rank 123,371 (Top 3 %)
  • Language
    Java
  • License
    Other
  • Created over 10 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Websocket server interface for Kafka distributed message broker

kafka-websocket

kafka-websocket is a simple websocket server interface to the kafka distributed message broker. It supports clients subscribing to topics, including multiple topics at once, and sending messages to topics. Messages may be either text or binary, the format for each is described below.

A client may produce and consume messages on the same connection.

Consuming from topics

Clients subscribe to topics by specifying them in a query parameter when connecting to kafka-websocket:

/v2/broker/?topics=my_topic,my_other_topic

If no topics are given, the client will not receive messages. The format of messages sent to clients is determined by the subprotocol negotiated: kafka-text or kafka-binary. If no subprotocol is specified, kafka-text is used.

By default, a new, unique group.id is generated per session. The group.id for a consumer can be controlled by passing a group.id as an additional query parameter: ?group.id=my_group_id

Producing to topics

Clients publish to topics by connecting to /v2/broker/ and sending either text or binary messages that include a topic and a message. Text messages may optionally include a key to influence the mapping of messages to partitions. A client need not subscribe to a topic to publish to it.

Message transforms

By default, kafka-websocket will pass messages to and from kafka as is. If your application requires altering messages in transit, for example to add a timestamp field to the body, you can implement a custom transform class. Transforms extend us.b3k.kafka.ws.transforms.Transform and can override the initialize methods, or the transform methods for text and binary messages.

Transforms can be applied to messages received from clients before they are sent to kafka (inputTransform) or to messages received from kafka before they are sent to clients (outputTransform). See conf/server.properties for an example of configuring the transform class.

Binary messages

Binary messages are formatted as:

[topic name length byte][topic name bytes (UTF-8)][message bytes]

Text messages

Text messages are JSON objects with two mandatory attributes: topic and message. They may also include an optional key attribute:

{ "topic" : "my_topic", "message" : "my amazing message" }

{ "topic" : "my_topic", "key" : "my_key123", "message" : "my amazing message" }

Configuration

See property files in conf/

TLS/SSL Transport

kafka-websocket can be configured to support TLS transport between client and server (not from kafka-websocket to kafka). Client certificates can also be used, if desired. Client auth can be set to none, optional, or required, each being, I hope, self-explanatory. See conf/server.properties for various configuration options.

Docker

Build a Docker image using the source code in the working directory:

docker build -t kafka-websocket .

After the Docker image is finished building, run it with:

docker run -it -p 7080:7080 kafka-websocket

License

kafka-websocket is copyright 2014 Benjamin Black, and distributed under the Apache License 2.0.

More Repositories

1

statsd_spec

A quixotic quest to coordinate StatsD implementations
140
star
2

libdtw

Fast dynamic time warping library based on the UCR Suite http://www.cs.ucr.edu/~eamonn/UCRsuite.html
C
36
star
3

sha3

SHA-3 (KECCAK) Erlang NIFs (based on NIST reference C implementation)
C
22
star
4

bertrem

BERTREM is a Ruby EventMachine BERT-RPC client and server library.
Ruby
19
star
5

rack-geoip

Rack middleware to perform IP to geo lookups on HTTP client IP addresses.
Ruby
18
star
6

libusbcan

Pure C API for ViewTool Ginkgo USB-CAN interfaces
C
16
star
7

tlscollect

TLS server configuration collection and reporting. Derived from the TLS Report.
Ruby
12
star
8

hex

Hex string/binary conversion utilities for Erlang
Erlang
11
star
9

LatticeCrypto

MSR LatticeCrypto library http://research.microsoft.com/en-us/projects/latticecrypto/
C
10
star
10

wm_basic_auth

Webmachine HTTP Basic auth
Erlang
7
star
11

opscode-agent

Agent for Opscode clients
Ruby
6
star
12

ION

Interplanetary Overlay Network (ION) implementation of Delay-Tolerant Networking protocols.
C
6
star
13

poly1305aes

Poly1305-AES Erlang NIFs
Assembly
5
star
14

chevre

Chevre is virtualization/hypervisor support for Chef. Chef + Virtualization -> Chevre. I slay me.
Ruby
5
star
15

retards

Erlang
5
star
16

hancock

hancock is an OpenID based Single Sign On provider written in Sinatra.
Ruby
3
star
17

openid-store-couchdb

A CouchDB association/nonce store for OpenID
Ruby
3
star
18

digest_auth

Erlang
3
star
19

openssl-darwin-universal

A shell script to build a quad-fat openssl package (sans MacPorts)
3
star
20

ruby-jsonrpc

Simple JSON-RPC client for Ruby
2
star
21

skerl

Erlang NIF for the Skein hash function
C
2
star
22

jpast

PAST, but Java
1
star
23

amqp_client

RabbitMQ Erlang Client (rabbit-erlang-client)
Erlang
1
star
24

project-cassandra

Cassandra distributed key/value store (my branches)
Java
1
star
25

3dmodels

OpenSCAD
1
star
26

www.tlsinsight.com

1
star
27

b.github.com

HTML
1
star
28

bertem

BERTEM has been renamed to BERTREM for the lulz
1
star