Request

Path Method Description
/rest/consume GET Consume one or more messages from MigratoryData or MigratoryData KE

Request Parameters

The following request parameters can be used when sending a consume request. They correspond to the message attributes detailed in the Concepts section.

Name Type Required? Description
subject string yes subject of the messages
token string yes auth token of the client
history integer no number of historical messages to retrieve
epoch integer no the epoch from where to retrieve messages
seq integer no the sequence from where to retrieve messages

Example

In order to get the snapshot message of the subject /crm/qa, provided that your auth token for subscription is u123, from the MigratoryData or MigratoryData KE deployed at the address https://example.com, use the following HTTP request:

curl -X GET \
'https://example.com/rest/consume?token=u123&subject=/crm/qa'

Response

Response Schema

The response to a consume request is a JSON string with the following schema:

{
    "subject": "string",
    "messages": [
        {
            "message_type": "SNAPSHOT|HISTORICAL|RECOVERED",
            "content": "string",
            "closure": "string",
            "retained": true|false,
            "compressed": true|false,
            "epoch": int,
            "seq": int
        },
        ...
    ]
}

Examples

Get a snapshot message

To consume a snapshot message of the subject /crm/qa, provided that your auth token for subscription is u123, from MigratoryData or MigratoryData KE deployed at the address https://example.com, use the following HTTP request:

curl -X GET \
'https://example.com/rest/consume?token=u123&subject=/crm/qa'

The response might be as follows:

{
    "subject": "/crm/qa",
    "messages": [
        {
            "message_type": "SNAPSHOT",
            "content": "Hello there",
            "closure": null,
            "retained": true,
            "compressed": false,
            "epoch": 0,
            "seq": 0,
        }
    ]
}

Retrieve historical messages by number

To attempt to consume up to the last ten messages of the subject /crm/qa, provided that your auth token for subscription is u123, from MigratoryData or MigratoryData KE deployed at the address https://example.com, use the following HTTP request:

curl -X GET \
'https://example.com/rest/consume?token=u123&subject=/crm/qa&history=10'

Supposing that at the moment of the request, MigratoryData or MigratoryData KE got only three messages for the subject /crm/qa, the response might be as follows:

{
    "subject": "/crm/qa",
    "messages": [
        {
            "message_type": "HISTORICAL",
            "content": "some-data-1",
            "closure": "1613638064334",
            "retained": true,
            "compressed": false,
            "epoch": 8,
            "seq": 1
        }, 
        {
            "message_type": "HISTORICAL",
            "content": "some-data-2",
            "closure": "1613638071287",
            "retained": true,
            "compressed": false,
            "epoch": 8,
            "seq": 2
        }, 
        {
            "message_type": "HISTORICAL",
            "content": "some-data-3",
            "closure": "1613638075663",
            "retained": true,
            "compressed": false,
            "epoch": 8,
            "seq": 3
        }
    ]
}

Retrieve historical messages by epoch and seq

To attempt to consume up to the last messages from a given epoch 8, starting with a given sequence 2 of the subject /crm/qa, provided that your auth token for subscription is u123, from MigratoryData or MigratoryData KE deployed at the address https://example.com, use the following HTTP request:

curl -X GET \
'https://example.com/rest/consume?token=u123&subject=/crm/qa&seq=2&epoch=8'

The response might be as follows:

{
    "subject": "/crm/qa",
    "messages": [
        {
            "message_type": "HISTORICAL",
            "content": "some-data-2",
            "closure": "1613638071287",
            "retained": true,
            "compressed": false,
            "epoch": 8,
            "seq": 2
        }, 
        {
            "message_type": "HISTORICAL",
            "content": "some-data-3",
            "closure": "1613638075663",
            "retained": true,
            "compressed": false,
            "epoch": 8,
            "seq": 3
        }
    ]
}