Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Streaming API Exercises

Sumit Rawal answered on May 11, 2023 Popularity 2/10 Helpfulness 1/10

Contents


More Related Answers

  • api testing challenges
  • rest api best practices
  • How to improve API performance?
  • stream api coding questions
  • Streaming API
  • 3. Use case of streaming API?
  • Streaming API Benefits
  • Core Streaming API
  • RESTful API Exercises
  • Long Tasks API

  • Streaming API Exercises

    0

    Consuming Events

    For this exercise we will be supplying two different methods you can consume events from

    Kafka:

    1. kcat

    Use Kcat to connect to our Streaming APIs, for the purpose of these exercises. Kcat

    (formerly kafkacat) is a command-line utility that you can use to test and debug

    Apache Kafka deployments. You can use kcat to produce, consume, and list topic and

    partition information for Kafka.

    Follow the kcat installation here. To start consuming events, you would kcat

    commands in the following format:

    kcat -b -X security.protocol=ssl -t

    -C -o end

    Which would look similar to this:

    kcat -b -X security.protocol=ssl -t

    vault.api.v1.customers.customer.created -C -o end

    The kafka_broker can be found in the Developer Starter Pack. You can refer to this

    kcat documentation for more information.

    2. KafkaConsumer in Python (Filtering allowed)

    A Python file is provided that allows you to consume from a specified kafka topic and

    server. Enter the Kafka topic in the KafkaTopic variable and the Kafka Server in the

    KafkaServer Variable.

    The following prerequisite installations are required:

    Classification | Confidential 4 ©2023 Thought Machine

    ● Python 3

    ● Python-snappy module (pip3 install python-snappy)

    ● Kafka-Python (pip3 install kafka-python)

    To set up, navigate to api_tutorials directory and run the following command:

    pip3 install -r requirements.txt

    This simple Python script accepts five arguments:

    ● [topic] e.g. vault.core_api.v1.accounts.account.events

    ● [server] e.g.

    bootstrap.kafka.partner-shared-sandbox.tmachine.io:443

    ● [security_protocol] SSL or Plaintext

    ● [headers] True or leave empty/false

    ● [filter] e.g. chris

    Example: python kafka-consume-filter.py

    vault.core_api.v1.accounts.account.events

    bootstrap.kafka.partner-shared-sandbox.tmachine.io:443 Plaintext  

    Popularity 2/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on May 11 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.