// Module included in the following assemblies:
//
// assembly-kafka-bridge-quickstart.adoc

[id='proc-bridge-seeking-offset-for-partition-{context}']
= Seeking to offsets for a partition

[role="_abstract"]
Use the xref:_seek[positions] endpoints to configure the Kafka Bridge consumer to retrieve messages for a partition from a specific offset, and then from the latest offset. This is referred to in Apache Kafka as a seek operation.

.Procedure

. Seek to a specific offset for partition 0 of the `quickstart-bridge-topic` topic:
+
[source,curl,subs=attributes+]
----
curl -X POST http://localhost:8080/consumers/bridge-quickstart-consumer-group/instances/bridge-quickstart-consumer/positions \
  -H 'content-type: application/vnd.kafka.v2+json' \
  -d '{
    "offsets": [
        {
            "topic": "bridge-quickstart-topic",
            "partition": 0,
            "offset": 2
        }
    ]
}'
----
+
If the request is successful, the Kafka Bridge returns a `204` code only.

. Submit a `GET` request to the `records` endpoint:
+
[source,curl,subs=attributes+]
----
curl -X GET http://localhost:8080/consumers/bridge-quickstart-consumer-group/instances/bridge-quickstart-consumer/records \
  -H 'accept: application/vnd.kafka.json.v2+json'
----
+
The Kafka Bridge returns messages from the offset that you seeked to.

. Restore the default message retrieval behavior by seeking to the last offset for the same partition. This time, use the xref:_seektoend[positions/end] endpoint.
+
[source,curl,subs=attributes+]
----
curl -X POST http://localhost:8080/consumers/bridge-quickstart-consumer-group/instances/bridge-quickstart-consumer/positions/end \
  -H 'content-type: application/vnd.kafka.v2+json' \
  -d '{
    "partitions": [
        {
            "topic": "bridge-quickstart-topic",
            "partition": 0
        }
    ]
}'
----
+
If the request is successful, the Kafka Bridge returns another `204` code.

NOTE: You can also use the xref:_seektobeginning[positions/beginning] endpoint to seek to the first offset for one or more partitions.

.What to do next

In this quickstart, you have used the Strimzi Kafka Bridge to perform several common operations on a Kafka cluster. You can now xref:proc-bridge-deleting-consumer-{context}[delete the Kafka Bridge consumer] that you created earlier.

[role="_additional-resources"]
.Additional resources

* xref:_seek[POST /consumers/{groupid}/instances/{name}/positions]
* xref:_seektobeginning[POST /consumers/{groupid}/instances/{name}/positions/beginning]
* xref:_seektoend[POST /consumers/{groupid}/instances/{name}/positions/end]
