Committing Cursors
POST /subscriptions/{subscriptionId}/cursors
Request
Cursors can be committed by making a POST request to the subscription's cursor resource /subscriptions/{subscriptionId}/cursors:
Please be aware that the X-Mambu-StreamId header is required when committing a cursor. The value should be the same as the X-Mambu-StreamId header you receive when opening a stream of events. Also, each client can only commit batches that it has received.
Sample Request
curl -v -X POST "https://TENANT_NAME.mambu.com/api/v1/subscriptions/0691160a-b519-4595-b85c-a400fc73e963/cursors"\
-H "X-Mambu-StreamId: 93ae5174-b863-4f8f-ba33-d274854d1f3d" \
-H "Content-type: application/json" \
-d
Body Parameter
{
"items": [
{
"partition": "1",
"offset": "001-0001-000000000000000000",
"event_type": "mrn.event.demo_tenant.streamingapi.client_approved",
"cursor_token": "db4b4c27-f880-4406-a382-b057acf432cd"
} ]
}
Response
The possible successful responses for a commit are:
204: Cursors were successfully committed and offset was increased.200: Cursors were committed but at least one of the cursors didn’t increase the offset, since it was less than or equal to the already committed one. The response body will also include json with a list of cursors and the results of their commits.
The timeout for commit is 60 seconds. If you open the stream, read data, and don’t commit anything for 60 seconds - the stream connection will be closed from the Mambu side. Please note that if there are no events available to send and you get only empty batches - there is no need to commit; Mambu will close the connection only if there is some uncommitted data and no commits happened for 60 seconds.
If the connection is closed for any reason, the client still has 60 seconds to commit the events it received from the moment the events were sent. After that, the session will be considered closed and it will no longer be possible to commit with that X-Mambu-StreamId. If the commit was not made - then the next time you start reading from a subscription you will get data from the last point of your commit, you will receive the events you haven’t committed again and will need to deduplicate.