Consuming Using Rest Client

Creating A REST Consumer

When you have completed this step, you will start consuming data from the stream configured in step 2 in Avro format.

Prerequisites

  • Tool that is able to send and receive HTTP messages, such as curl or http

  • A running instance of Rest Proxy (in the examples below it is accessible on the url https://192.168.99.100:18100, if you are using the SaaS Trial environment, the url you need to use can be found in the README.txt file within the care package)

Consuming data via REST

In the following example we will use the /streams endpoint to consume. For the following steps, we’re going to use curl tool to consume data.

curl --request GET \
    --url "https://192.168.99.100:18100/stream/example/applicationlogevents" \
    --header "axual-application-id: io.axual.example.client.avro.consumer" \
    --header "axual-application-version: 0.0.1" \
    --header "axual-consumer-uuid: log-consumer1" \
    --header "axual-key-type: AVRO" \
    --header "axual-value-type: AVRO" \
    --header "axual-commit-strategy: AFTER_READ" \
    --header "axual-polling-timeout-ms: 10000" \
    --header "Content-Type: application/json" \
    --key ../client-cert/local-config/security/applications/example-consumer/pem/example_consumer.key \
    --cert ../client-cert/local-config/security/applications/example-consumer/cer/example_consumer.cer \
    --cacert ../client-cert/local-config/security/applications/common-truststore/cachain/tenant-root-ca.cert.pem
Check your care package for the key, cert and cacert parameter values, see also Step 3.

When you execute above command, this will return response that will look like this:

{
   "cluster":"local",
   "messages":[
      {
         "messageId":"bf4ea734-4cd5-49e8-8b76-67bd63311d5d",
         "produceTimestamp":1585904295792,
         "partition":0,
         "offset":10,
         "produceCluster":"local",
         "consumeCluster":"local",
         "headers":{
            "Axual-Producer-Version":[
               "MC4wLjE="
            ],
            "Axual-Message-Id":[
               "v06nNEzVSeiLdme9YzEdXQ=="
            ],
            "Axual-Tenant":[
               "ZGVtbw=="
            ],
            "Axual-Serialization-Time":[
               "AAABcT9DCmk="
            ],
            "Axual-Environment":[
               "ZXhhbXBsZQ=="
            ],
            "Axual-Deserialization-Time":[
               "AAABcT9DWhQ="
            ],
            "Axual-Intermediate-Version":[
               "MC4wLjE="
            ],
            "Axual-System":[
               "ZGVtby1zeXN0ZW0="
            ],
            "Axual-Intermediate-Id":[
               "aW8uYXh1YWwuZXhhbXBsZS5jbGllbnQuYXZyby5jb25zdW1lcg=="
            ],
            "Axual-Cluster":[
               "bG9jYWw="
            ],
            "Axual-Instance":[
               "bG9jYWw="
            ],
            "Axual-Producer-Id":[
               "aW8uYXh1YWwuZXhhbXBsZS5jbGllbnQuYXZyby5wcm9kdWNlcg=="
            ]
         },
         "keyMessage":{
            "type":"AVRO",
            "schema":null,
            "schemaId":null,
            "message":"{\"name\": \"app_0\", \"version\": \"1.9.9\", \"owner\": \"none\"}"
         },
         "valueMessage":{
            "type":"AVRO",
            "schema":null,
            "schemaId":null,
            "message":"{\"timestamp\": 1000, \"source\": {\"name\": \"logeventproducer\", \"version\": \"0.0.1\", \"owner\": \"Team Log\"}, \"context\": {\"Some key\": \"Some Value\"}, \"level\": \"INFO\", \"message\": \"Message 0\"}"
         }
      }
   ]
}

For more details, please refer Rest-Proxy Consume Service

Wrapping up

You have concluded the getting started section by preparing your stream & applications, requesting access to the stream and actually producing and consuming some data. If you are going to deploy your application in another environment, it is advised to enable monitoring.

You can also use the menu on the left to find information about other platform features, that might not have been touched in this Getting Started.