Introduction to Red Hat AMQ Streams

Basic Red Hat AMQ Streams:

Prerequisite

Basic Start with Zookeeper

  • go to lab folder 1-introduction-amq-streams

    cd ~/amq-streams-2022/1-introduction-amq-streams
  • see detail of amq streams installation folder (you can install amq streams by download zip file from red hatarrow-up-right and unzip to your path )

    tree -L 1 kafka

    example result

    kafka
    ├── LICENSE  
    ├── NOTICE
    ├── bin         --> kafka command line folder
    ├── config      --> kafka configuration folder
    ├── libs        --> kafka java libraries folder
    └── licenses
  • review zookkeper.propertiesarrow-up-right in kafka/config, see detail of zookeeper configuration. we will use this file for config zookeeper.

    # the directory where the snapshot is stored.
    dataDir=/tmp/zookeeper
    # the port at which the clients will connect
    clientPort=2181
    # disable the per-ip limit on the number of connections since this is a non-production config
    maxClientCnxns=0
    # Disable the adminserver by default to avoid port conflicts.
    # Set the port to something non-conflicting if choosing to enable this
    admin.enableServer=false
    # admin.serverPort=8080
  • First before we start Kafka, we have to start ZooKeeper, start zookeeper with command line (For testing, we start only 1 server.)

    ./kafka/bin/zookeeper-server-start.sh ./kafka/config/zookeeper.properties
  • wait until zookeeper start complete

    ...
    [2022-11-10 06:36:46,300] INFO Using checkIntervalMs=60000 maxPerMinute=10000 maxNeverUsedIntervalMs=0 (org.apache.zookeeper.server.ContainerManager)
    [2022-11-10 06:36:46,302] INFO ZooKeeper audit is disabled. (org.apache.zookeeper.audit.ZKAuditProvider)
  • zookeeper terminal

Basic Start Kafka Broker

  • review server.propertiesarrow-up-right in kafka/config, see detail of server configuration. we will use this file for start kafka.

  • Next we can start Kafka Broker, open new terminal by repeat step in Connect to RHPDS VM Lab and run command (For testing, we start only 1 server.)

  • wait unti kafka start complete

  • kafka broker terminal

  • open new terminal and check zookeeper and kafka process

    example result

    • process "QuorumPeerMain" is zookeeper

    • process "Kafka" is kafka broker

Basic Create Kafka Topic

  • List the topics using Kafka, open new terminal and run command

  • no topic show in terminal

  • create sample new topic which we will use

    result of create topic command

  • List the topics again to see it was created.

  • Describe the topic to see more details:

  • example output

Basic Consuming and producing messages

  • Start the console producer for create and send message to topic

  • Wait until it is ready (it should show >).

  • Next we can consume the messages, open new terminal and run command

  • Once ready, back to producer terminal and send some message by typing the message payload and pressing enter to send. such as

  • see output in consumer terminal:

    example result in terminal

  • exit from producer console by type ctrl+c in producer console terminal

  • You can also check the consumer groups:

    example result

  • exit from consumer console by type ctrl+c in consumer console terminal

  • check the consumer groups again:

    example result

Stop Zookeeper & Kafka Broker

  • run stop server command in another terminal

  • or type ctrl + c in kafka terminal and zookeeper terminal

  • check with jps command again (if stop complete, kafka and QuorumPeerMain will disappear)

Last updated