# kafka-replay-service

> A simple service to play (publish) a sequence of messages to a Kafka topic.

Latest version **0.2.2** (published 2018-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install kafka-replay-service
pnpm add kafka-replay-service
yarn add kafka-replay-service
bun add kafka-replay-service
```

Provides the command `kafka-replay-service`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2018-09-20 |
| First published | 2018-03-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 5.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Erik Vullings |
| Maintainers | erikvullings |
| Keywords | Apache, Kafka, play, publish, produce, replay, node, vue |

## Links

- npm: https://www.npmjs.com/package/kafka-replay-service
- Repository: https://github.com/DRIVER-EU/kafka-replay-service
- Homepage: https://github.com/DRIVER-EU/kafka-replay-service#readme
- Issues: https://github.com/DRIVER-EU/kafka-replay-service/issues
- npm.io page: https://npm.io/package/kafka-replay-service

## Dependencies (9)

- [cors](https://npm.io/package/cors.md) ^2.8.4
- [express](https://npm.io/package/express.md) ^4.16.3
- [chokidar](https://npm.io/package/chokidar.md) ^2.0.4
- [xml2json](https://npm.io/package/xml2json.md) ^0.11.2
- [socket.io](https://npm.io/package/socket.io.md) ^2.1.1
- [command-line-args](https://npm.io/package/command-line-args.md) ^5.0.2
- [command-line-usage](https://npm.io/package/command-line-usage.md) ^5.0.5
- [swagger-ui-express](https://npm.io/package/swagger-ui-express.md) ^4.0.1
- [node-test-bed-adapter](https://npm.io/package/node-test-bed-adapter.md) ^0.5.4

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2018-09-20
- 0.2.1 — 2018-09-19
- 0.2.0 — 2018-09-15
- 0.1.5 — 2018-07-23
- 0.1.4 — 2018-07-23
- 0.1.3 — 2018-07-23
- 0.1.1 — 2018-06-17
- 0.1.0 — 2018-05-23
- 0.0.10 — 2018-04-13
- 0.0.9 — 2018-04-13
- 0.0.8 — 2018-04-13
- 0.0.7 — 2018-04-04
- 0.0.6 — 2018-03-16
- 0.0.5 — 2018-03-12
- 0.0.4 — 2018-03-12
- … 3 more at https://npm.io/package/kafka-replay-service/versions

## README

# Kafka-Replay-Service

A simple REST (+websockets) service to play (publish) a sequence of messages to a Kafka topic. The messages you can play are based on their location in a folder (following the convention over configuration principle). The folder is actively watched, and new files will be automatically available.

Replay logged messages that are stored inside a, potentially mounted, folder. The folder layout is using the following convention, so you can either write your own message, one message per file, or, alternatively, use a log file from Landoop's Kafka TOPICS UI:

ROOT
- logs
  - SESSION_NAME
    - TOPIC_NAME
      - TIMESTAMP_FILENAME
  - SESSION_NAME2
    - [Kafka TOPICS UI log file].json

Messages that belong to each other are added to the same session. The topic name is the name of the topic to publish the messages to. When a TIMESTAMP (a number in msec) is set, it is used to send the message after TIMESTAMP msec.

The REST API is documented using OpenAPI/Swagger at [http://[HOST]:[PORT]/api-docs/](http://localhost:8200/api-docs).

The GUI is available at [http://[HOST]:[PORT]/api-docs/](http://localhost:8200).

Via websockets, your client may receive a `session_update` notification that something has changed, after which you should GET all session data again.

## Filename convention for single messages
The message file's filename convention informs us when to send it:
- It is just a name: you can publish them step-by-step or all in one go
- It is in the format 12345... (only numbers, or, in Regex /d+): it represents the offset in msec since you pressed play
- Optionally, the previous format may be augmented by a textual description, such as 0001_Init_msg, in which case the 'Init msg' is used as the label of the message in the GUI.

## Extension
Finally, the message file's extension informs us how to read it. We support the following inputs:
- .xml, for XML messages
- .json or .geojson for JSON and GeoJSON messages, respectively.

## Use cases (TO BE DONE)

### Playback step-by-step

The user can select a `session_name` from the GUI, and either send messages by selecting them, and pressing play, or by sending them one after another (batch mode).
In case we are dealing with multiple topics, the user can unselect specific topics in batch mode.

### Playback scenario-based

Finally, if there is a time message signal on the test-bed, playback messages based on the external clock. The scenario duration is used to determine when to send a message.

## Build instructions

From the command prompt, install all dependencies using `npm i`. Under Windows, using Node v9, you may run into an installation error when installing `node-expat`. In that case, you can try the following:
```
npm i -g node-gyp
cd node_modules\node-expat
node-gyp rebuild
```
Optionally, you may also need to install the npm production tools, from an admin prompt: `npm install --global --production windows-build-tools`.

Next, run `npm start` to compile the TypeScript code to JavaScript.

---
_Source: https://npm.io/package/kafka-replay-service · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
