Skip to content

Commit

Permalink
[kafka][doc][skip ci] Add docs on how to change offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Jan 4, 2018
1 parent eded88e commit 3c1fd49
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/transport/kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The transport uses [Kafka](https://kafka.apache.org/) streaming platform as a MQ
* [Send message to queue](#send-message-to-queue)
* [Consume message](#consume-message)
* [Serialize message](#serialize-message)
* [Chnage offset](#change-offset)

## Installation

Expand Down Expand Up @@ -84,6 +85,9 @@ $fooQueue = $psrContext->createQueue('foo');

$consumer = $psrContext->createConsumer($fooQueue);

// Enable async commit to gain better performance.
//$consumer->setCommitAsync(true);

$message = $consumer->receive();

// process a message
Expand Down Expand Up @@ -115,4 +119,21 @@ class FooSerializer implements Serializer
$psrContext->setSerializer(new FooSerializer());
```

## Change offset

By default consumers starts from the beginning of the topic and updates the offset while you are processing messages.
There is an ability to change the current offset.

```php
<?php
/** @var \Enqueue\RdKafka\RdKafkaContext $psrContext */

$fooQueue = $psrContext->createQueue('foo');

$consumer = $psrContext->createConsumer($fooQueue);
$consumer->setOffset(123);

$message = $consumer->receive(2000);
```

[back to index](index.md)

0 comments on commit 3c1fd49

Please sign in to comment.