# kafka-reconsume

> Tiny messages reconsumer based on kafkajs

Latest version **0.1.5** (published 2023-06-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install kafka-reconsume
pnpm add kafka-reconsume
yarn add kafka-reconsume
bun add kafka-reconsume
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2023-06-06 |
| First published | 2023-06-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | twoojoo |
| Maintainers | twoojoo |
| Keywords | kafka, consume, messages, reconsume, offset, timestamp, date |

## Links

- npm: https://www.npmjs.com/package/kafka-reconsume
- npm.io page: https://npm.io/package/kafka-reconsume

## Dependencies (1)

- [kafkajs](https://npm.io/package/kafkajs.md) ^2.2.4

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2023-06-06
- 0.1.4 — 2023-06-06
- 0.1.3 — 2023-06-06
- 0.1.2 — 2023-06-06
- 0.1.1 — 2023-06-06
- 0.1.0 — 2023-06-06
- 0.0.5 — 2023-06-06
- 0.0.4 — 2023-06-06
- 0.0.3 — 2023-06-06
- 0.0.2 — 2023-06-06
- 0.0.1 — 2023-06-06

## README

# Kafka Reconsume

A tiny messages reconsumer based on [kafkajs](https://github.com/tulios/kafkajs)

## Basic usage

```bash
npm install kafka-reconsume
```

This will reconsume messages from a specific topic, starting from the given timestamp:

```typescript
import { kafkaReconsume } from "kafka-reconsume"
import { Kafka } from "kafkajs"

const kafka = new Kafka({ brokers: ["localhost:9092"] }), 

(async function () { 
	const result = await kafkaReconsume(
		kafka,
		"my-topic",
		1202301233, //timestamp
		async (item) => {
			const message = item.message.value!.toString()
			console.log(item.topic, "==>", message)
		}
	)

	for (const partition in result) {
		console.log(
			"partition:", partition,
			"messages:", result[partition]
		)
	}
})()
```

- returns the **number of reconsumed messages for each partition**.
- **Autocommit** is always set to **false**, to ensure programmatic reconsume.
- By default a **randomly generated consumer group id** will be used, but it can be set proividing the whole consumer config as last optional argument.

## Other utilities

Just two little wrappers around the main function:

```typescript

await kafkaReconsumeByMillisecOffset(
	kafka,
	"my-topic",
	10000, //starts from 10 seconds ago
	async (item) => { /*....*/}
)

await kafkaReconsumeFromLocalDateTime(
	kafka,
	"my-topic",
	new Date("2023-06-06 00:00:00")
	async (item) => { /*....*/}
)
```

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