### Install Python Pulsar Client Library Source: https://docs.streamnative.io/cloud/get-started/quickstart-console This command installs the official `pulsar-client` Python library using pip, which is essential for interacting with Apache Pulsar clusters from Python applications. It's a prerequisite for developing both producers and consumers. ```bash pip3 install pulsar-client ``` -------------------------------- ### Install Pulsar Python Client Source: https://docs.streamnative.io/cloud/get-started/quickstart-console This command installs the Apache Pulsar client library for Python using pip. It is a prerequisite for interacting with Pulsar clusters programmatically from a Python environment. ```Python python -m pip install pulsar-client ``` -------------------------------- ### pfSQL Info Command Output Example Source: https://docs.streamnative.io/cloud/process/pfsql/pfsql-work-with-cli An example JSON output returned by the `pfsql info` command, illustrating the status of the pfSQL gateway, its runtimes (e.g., Pulsar Function), version, and the authenticated user's identity. ```JSON { "status": "RUNNING", "runtimes": { "pulsar_function": "RUNNING" }, "version": "v0.18.0", "whoAmI": "test@streamnative.dev" } ``` -------------------------------- ### Install Pulsar Python Client Source: https://docs.streamnative.io/cloud/get-started/quickstart-byoc This snippet provides the command to install the Pulsar Python client library using pip, which is a prerequisite for interacting with Pulsar clusters programmatically from Python. ```Python python -m pip install pulsar-client ``` -------------------------------- ### Install pfSQL CLI via Homebrew Source: https://docs.streamnative.io/cloud/process/pfsql/pfsql-work-with-cli Installs the pfSQL command-line interface using Homebrew, first tapping the StreamNative repository to access the necessary formula. ```Shell brew tap streamnative/streamnative brew install pfsql-cli ``` -------------------------------- ### Install Python Pulsar Client Library Source: https://docs.streamnative.io/cloud/get-started/quickstart-byoc This command installs the `pulsar-client` library for Python using `pip3`. This library is essential for developing applications that interact with Apache Pulsar, enabling functionalities like message production and consumption. ```bash pip3 install pulsar-client ``` -------------------------------- ### Example Output of pfsql info Command Source: https://docs.streamnative.io/cloud/process/pfsql/pfsql-work-with-cli This JSON snippet shows the typical output returned when executing the `pfsql info` command, providing status, runtime details, version, and user identity. ```json { "status": "RUNNING", "runtimes": { "pulsar_function": "RUNNING" }, "version": "v0.18.0", "whoAmI": "test@streamnative.dev" } ``` -------------------------------- ### Install Confluent Kafka Go Client Source: https://docs.streamnative.io/cloud/build/kafka-clients/quick-starts/cloud-connect-kafka-go This command installs the Confluent Kafka Go client library using `go get`. It fetches the specified version from GitHub, making it available for use in Go projects that interact with Kafka. ```Go go get -u github.com/confluentinc/confluent-kafka-go/v2/kafka ``` -------------------------------- ### Start ClickHouse Server Source: https://docs.streamnative.io/connect/connectors/jdbc-clickhouse-sink/current/jdbc-sink This command downloads and starts a single-node ClickHouse server instance, which is a prerequisite for setting up the JDBC ClickHouse sink connector. It fetches the ClickHouse installation script and then launches the server. ```Bash curl https://clickhouse.com/ | sh ./clickhouse server ``` -------------------------------- ### Run Pulsar Consumer Script Source: https://docs.streamnative.io/cloud/get-started/quickstart-console Execute this command in a terminal to start the Python consumer script. The consumer will listen for messages on the configured Pulsar topic and print them to the console as they are received. It should be run before the producer. ```bash python3 consumer.py ``` -------------------------------- ### Example Pulsar Consumer Output Source: https://docs.streamnative.io/cloud/get-started/quickstart-byoc This block shows the expected output from the `consumer.py` script, indicating that messages have been successfully received. Each line displays the content of a message (e.g., 'Hello-0') and its unique message ID, confirming the consumer's operation. ```text Received message 'Hello-0' id='' Received message 'Hello-1' id='' Received message 'Hello-2' id='' Received message 'Hello-3' id='' Received message 'Hello-4' id='' Received message 'Hello-5' id='' Received message 'Hello-6' id='' Received message 'Hello-7' id='' Received message 'Hello-8' id='' Received message 'Hello-9' id='' ``` -------------------------------- ### Start KSQL Server Source: https://docs.streamnative.io/cloud/process/kafka-streams-and-ksql/cloud-connect-ksql Executes the `ksql-server-start` script to launch the KSQL server. This command initializes the server using the configuration defined in the specified properties file, making it ready to accept KSQL queries and commands. ```bash bin/ksql-server-start etc/ksqldb/ksql-server.properties ``` -------------------------------- ### Build Java Project with Maven Source: https://docs.streamnative.io/cloud/get-started/quickstart-ursa This command executes the Maven build lifecycle. The `clean` goal removes the target directory and any previously compiled artifacts, ensuring a fresh build. The `install` goal then compiles the source code, runs tests, packages the compiled code into a JAR, and installs it into the local Maven repository, making it available for other projects. ```Shell mvn clean install ``` -------------------------------- ### Pulsar Consumer Message Output Example Source: https://docs.streamnative.io/private-cloud/v1/quick-start/platform-quickstart An example of the output received by a Pulsar consumer when it successfully processes a message from a topic. ```text ----- got message ----- message-for-both-pulsar-and-kafka-client ``` -------------------------------- ### Start Kafka Console Consumer Source: https://docs.streamnative.io/private-cloud/v1/operating-streamnative-platform/network/istio This command starts a Kafka console consumer, enabling the consumption of messages from a specified Kafka topic. It connects to the Kafka broker using the provided bootstrap server address and utilizes the `client.properties` file for secure SSL communication. ```bash bin/kafka-console-consumer.sh \ --bootstrap-server \ --topic \ --consumer.config client.properties ``` -------------------------------- ### Verify StreamNative Operator Pods Source: https://docs.streamnative.io/private-cloud/v2/quick-start/private-cloud-quickstart This command lists all resources (pods, services, deployments, etc.) within the 'operators' Kubernetes namespace. It is used to verify that the StreamNative Operator pods have been successfully deployed and are running after installation. ```bash kubectl get all -n operators ``` -------------------------------- ### Run Pulsar Producer Script Source: https://docs.streamnative.io/cloud/get-started/quickstart-console Use this command in a separate terminal to start the Python producer script. The producer will send messages to the configured Pulsar topic, which can then be consumed by the running consumer. This demonstrates the message publishing capability. ```bash python3 producer.py ``` -------------------------------- ### Start KSQL CLI Tool Source: https://docs.streamnative.io/cloud/process/kafka-streams-and-ksql/cloud-connect-ksql Launches the KSQL command-line interface, connecting to the running KSQL server. It also sets a log directory for the CLI, allowing users to interact with KSQL streams and tables. ```bash LOG_DIR=./ksql_logs bin/ksql http://localhost:8088 ``` -------------------------------- ### Provision Pulsar Cluster Source: https://docs.streamnative.io/private-cloud/v2/quick-start/private-cloud-quickstart This command applies a YAML configuration file directly from a GitHub URL to provision a Pulsar cluster. The StreamNative Operator, which was previously installed, will read this configuration and deploy the Pulsar components into the 'pulsar' namespace. ```bash kubectl apply -f https://raw.githubusercontent.com/streamnative/private-cloud/main/quick-start/pulsar-cluster.yaml ``` -------------------------------- ### Verify pulsarctl CLI Installation Source: https://docs.streamnative.io/tools/cli/pulsarctl/pulsarctl-overview This command checks the installed version of the `pulsarctl` command-line tool. It is used to confirm that the installation was successful and that the tool is accessible in the system's PATH. ```Bash pulsarctl --version ``` -------------------------------- ### Create and navigate to tutorial directory Source: https://docs.streamnative.io/tools/cli/streamnative-cli-tutorial This command creates a new directory named `snctl-getting-started` and then changes the current working directory into it, preparing the environment for the StreamNative CLI tutorial. ```bash mkdir snctl-getting-started && cd snctl-getting-started ``` -------------------------------- ### Install pulsarctl CLI using Homebrew on macOS Source: https://docs.streamnative.io/tools/cli/pulsarctl/pulsarctl-overview These commands add the StreamNative Homebrew tap and then install the `pulsarctl` command-line tool using Homebrew, a package manager for macOS. This is an alternative installation method for Mac users. ```Bash brew tap streamnative/streamnative ``` ```Bash brew install pulsarctl ``` -------------------------------- ### Create Terraform Project Directory Source: https://docs.streamnative.io/tools/terraform/terraform-provider-tutorial This shell command creates a new directory named `terraform-getting-started` to house the Terraform project files and then navigates into this newly created directory. This is the initial setup step for organizing the project. ```Shell mkdir terraform-getting-started && cd terraform-getting-started ``` -------------------------------- ### Install pulsarctl CLI via curl script on Linux and macOS Source: https://docs.streamnative.io/tools/cli/pulsarctl/pulsarctl-overview This command downloads and executes an installation script from the StreamNative GitHub repository to install the `pulsarctl` command-line tool. It is applicable for both Linux and macOS operating systems. ```Bash sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/streamnative/pulsarctl/master/install.sh)" ``` -------------------------------- ### Initialize Go Module and Download Pulsar Client Dependencies Source: https://docs.streamnative.io/clients/pulsar-clients/go/tutorial/pulsar-go-create-project These Go commands initialize a new Go module for the project and download the necessary Apache Pulsar Go client libraries, including the main client, authentication package, and core Pulsar package. This prepares the project for Go development with Pulsar, ensuring all required dependencies are available. ```Go go mod init pulsar-go-getting-started go get github.com/apache/pulsar-client-go go get github.com/apache/pulsar-client-go/pulsar/auth go get github.com/apache/pulsar-client-go/pulsar ``` -------------------------------- ### pfSQL CLI General Usage Syntax Source: https://docs.streamnative.io/cloud/process/pfsql/pfsql-work-with-cli Provides the general command-line syntax for using the pfSQL CLI, indicating required options and subcommands. ```APIDOC pfsql [OPTIONS] -b Parameters: [OPTIONS]: Optional flags or arguments. -b : Required. The HTTP service URL of your Pulsar Cluster. : The specific command to execute (e.g., 'info', 'query'). ``` -------------------------------- ### Create Project Directory for Kafka C Client Source: https://docs.streamnative.io/clients/kafka-clients/c-and-c++/tutorial/kafka-c-create-project This shell command creates a new directory named `kafka-c-getting-started` and then navigates into it. This is the foundational step for organizing the project files. ```Shell mkdir kafka-c-getting-started && cd kafka-c-getting-started ``` -------------------------------- ### Install Latest StreamNative CLI (snctl) with Curl Source: https://docs.streamnative.io/tools/cli/snctl/snctl-overview This command downloads and executes the installation script for the latest version of the StreamNative CLI (snctl) on Linux or macOS systems. It uses `curl` to fetch the script from StreamNative's storage and `bash` to run it, providing a convenient way to get started with the CLI. ```bash bash -c "$(curl -fsSL https://storage.googleapis.com/downloads.streamnative.cloud/snctl/install.sh)" ``` -------------------------------- ### Create and Navigate to Go Project Directory Source: https://docs.streamnative.io/clients/kafka-clients/go/tutorial/kafka-go-create-project This shell command creates a new directory named `kafka-go-getting-started` for the Go Kafka project and then changes the current working directory into it. This is the first step in setting up the project environment. ```Shell mkdir kafka-go-getting-started && cd kafka-go-getting-started ``` -------------------------------- ### Synchronously Send Kafka Message in Java Source: https://docs.streamnative.io/clients/kafka-clients/java/kafka-java-client-guide This example demonstrates how to perform a synchronous send operation by blocking until the `Future` returned by `producer.send()` completes. Calling `get()` on the future ensures the message is sent and acknowledged before proceeding. ```Java Future future = producer.send(record); RecordMetadata metadata = future.get(); ``` -------------------------------- ### Produce Messages with Pulsar Client Source: https://docs.streamnative.io/private-cloud/v2/quick-start/private-cloud-quickstart Uses the `pulsar-client` command-line tool to produce 10 messages, each with the content 'sn-private-cloud', to the 'private-cloud' topic. This demonstrates basic message production functionality. ```bash bin/pulsar-client produce private-cloud -m "sn-private-cloud" -n 10 ``` -------------------------------- ### Configure Multi-Cluster Pulsar Geo-Replication with Terraform Source: https://docs.streamnative.io/cloud/clusters/cloud-geo-replication This Terraform configuration defines a StreamNative Pulsar instance and two Pulsar clusters (`us-east-cluster` and `us-west-cluster`) under that instance. It demonstrates how to declare `streamnative_pulsar_instance` and `streamnative_pulsar_cluster` resources, linking clusters to the instance using `instance_name` and ensuring deployment order with `depends_on` for geo-replication setup. ```Terraform resource "streamnative_pulsar_instance" "geo-instance" { organization = "sndev" name = "geo-instance" availability_mode = "regional" pool_name = "shared-aws" pool_namespace = "streamnative" } resource "streamnative_pulsar_cluster" "us-east-cluster" { organization = "sndev" name = "us-east-cluster" instance_name = streamnative_pulsar_instance.geo-instance.name location = "us-east-2" release_channel = "rapid" bookie_replicas = 3 broker_replicas = 2 compute_unit = 0.3 storage_unit = 0.3 } resource "streamnative_pulsar_cluster" "us-west-cluster" { depends_on = [ streamnative_pulsar_cluster.us-east-cluster ] organization = "sndev" name = "us-west-cluster" instance_name = streamnative_pulsar_instance.geo-instance.name location = "us-east-2" release_channel = "rapid" bookie_replicas = 3 broker_replicas = 2 compute_unit = 0.3 storage_unit = 0.3 } ``` -------------------------------- ### Install Pulsar Cluster with Helm Source: https://docs.streamnative.io/private-cloud/v1/operating-streamnative-platform/deploy/sn-deploy This Helm command installs a Pulsar cluster using a specified configuration file and the `streamnative/sn-platform` chart. The `--set initialize=true` flag ensures initial setup, and the installation targets a specific Kubernetes namespace. ```bash helm install -f /path/to/pulsar/file.yaml streamnative/sn-platform --set initialize=true -n ``` -------------------------------- ### RabbitMQ Source Connector YAML Configuration Example Source: https://docs.streamnative.io/connect/connectors/rabbitmq-source/current/rabbitmq-source An example YAML configuration file demonstrating how to set up the RabbitMQ source connector with common parameters, mirroring the JSON example. This format is often preferred for its readability. ```YAML configs: host: "localhost" port: 5672 virtualHost: "/" username: "guest" password: "guest" queueName: "test-queue" connectionName: "test-connection" requestedChannelMax: 0 requestedFrameMax: 0 connectionTimeout: 60000 handshakeTimeout: 10000 requestedHeartbeat: 60 prefetchCount: 0 prefetchGlobal: "false" ``` -------------------------------- ### Initialize Go Module and Install Confluent Kafka Dependency Source: https://docs.streamnative.io/clients/kafka-clients/go/tutorial/kafka-go-create-project These Go commands initialize a new Go module named `kafka-go-getting-started` for dependency management. Following that, it downloads and installs the `confluent-kafka-go/v2/kafka` library, which is the official Go client for Apache Kafka by Confluent, enabling Kafka interactions within the project. ```Go go mod init kafka-go-getting-started go get github.com/confluentinc/confluent-kafka-go/v2/kafka ``` -------------------------------- ### Kafka Consumer Message Output Example Source: https://docs.streamnative.io/private-cloud/v1/quick-start/platform-quickstart An example of the output received by a Kafka consumer when it successfully processes a message from a topic. ```text > message-for-both-pulsar-and-kafka-client ``` -------------------------------- ### RabbitMQ Source Connector JSON Configuration Example Source: https://docs.streamnative.io/connect/connectors/rabbitmq-source/current/rabbitmq-source An example JSON configuration file demonstrating how to set up the RabbitMQ source connector with common parameters like host, port, credentials, and queue name. This file can be used to deploy the connector. ```JSON { "host": "localhost", "port": "5672", "virtualHost": "/", "username": "guest", "password": "guest", "queueName": "test-queue", "connectionName": "test-connection", "requestedChannelMax": "0", "requestedFrameMax": "0", "connectionTimeout": "60000", "handshakeTimeout": "10000", "requestedHeartbeat": "60", "prefetchCount": "0", "prefetchGlobal": "false" } ``` -------------------------------- ### Install Prometheus Community Chart Source: https://docs.streamnative.io/private-cloud/v2/operate-private-cloud/observability/private-cloud-monitor This command installs the Prometheus monitoring system using its community Helm chart into the 'monitor' Kubernetes namespace. It specifically disables Alertmanager, kube-state-metrics, and Prometheus Pushgateway to streamline the installation for this monitoring setup. ```shell helm install prometheus prometheus-community/prometheus -n monitor --set alertmanager.enabled=false --set kube-state-metrics.enabled=false --set prometheus-pushgateway.enabled=false ``` -------------------------------- ### Create Project Directory for Pulsar Go Client Source: https://docs.streamnative.io/clients/pulsar-clients/go/tutorial/pulsar-go-create-project This shell command creates a new directory named `pulsar-go-getting-started` and then navigates into it. This is the initial step for setting up the project workspace for a Go application interacting with Apache Pulsar. ```Shell mkdir pulsar-go-getting-started && cd pulsar-go-getting-started ``` -------------------------------- ### Start Pulsar in Standalone Mode Source: https://docs.streamnative.io/connect/connectors/activemq-sink/current/io-activemq-sink This command initializes and starts the Apache Pulsar broker in standalone mode. This setup is ideal for local development and testing, providing a self-contained Pulsar environment. ```shell $PULSAR_HOME/bin/pulsar standalone ``` -------------------------------- ### List Pulsar Topics with Pulsarctl Source: https://docs.streamnative.io/private-cloud/v2/quick-start/private-cloud-quickstart Utilizes the `pulsarctl` command-line tool to list all topics available under the `public/default` namespace. This command is useful for verifying topic creation and existence. ```bash bin/pulsarctl topics list public/default ``` -------------------------------- ### Example StreamNative Pulsar Serverless Instance Status Output Source: https://docs.streamnative.io/tools/cli/streamnative-cli-tutorial This YAML block shows an example status output for a StreamNative Pulsar serverless instance. It includes authentication details (OAuth2) and a list of conditions indicating the instance's readiness, such as `SubscriptionReady`, `ResourceServerReady`, `ServiceAccountReady`, and `Ready`. ```yaml status: auth: oauth2: audience: urn:sn:pulsar:: issuerURL: https://auth.streamnative.cloud/ type: oauth2 conditions: - lastTransitionTime: '...' message: a payment method is not required because discount is active reason: HasActiveDiscount status: 'True' type: SubscriptionReady - lastTransitionTime: '...' reason: Created status: 'True' type: ResourceServerReady - lastTransitionTime: '...' reason: Created status: 'True' type: ServiceAccountReady - lastTransitionTime: '...' reason: AllConditionStatusTrue status: 'True' type: Ready ``` -------------------------------- ### Create Project Directory for Kafka Python Source: https://docs.streamnative.io/clients/kafka-clients/python/tutorial/kafka-python-create-project This command creates a new directory named `kafka-python-getting-started` for the project and then changes the current working directory into it. This is the foundational step for organizing all project-related files. ```Shell mkdir kafka-python-getting-started && cd kafka-python-getting-started ``` -------------------------------- ### Start Kafka Console Consumer with SASL_PLAINTEXT Source: https://docs.streamnative.io/private-cloud/v1/quick-start/platform-quickstart Starts a Kafka console consumer to receive messages from a specified topic. It configures security using SASL_PLAINTEXT and PLAIN mechanism, authenticating with a username (TENANT/NAMESPACE) and a token-based password against the StreamNative broker. ```bash kafka-console-consumer.sh \ --consumer-property security.protocol=SASL_PLAINTEXT \ --consumer-property sasl.mechanism=PLAIN \ --consumer-property 'sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="TENANT/NAMESPACE" password="token:'YOUR_TOKEN'";' \ --bootstrap-server sn-platform-broker:9092 --topic ``` -------------------------------- ### Example Terraform Apply Output Source: https://docs.streamnative.io/tools/terraform/terraform-provider-tutorial This snippet shows an example of the output after successfully running `terraform apply`. It includes the generated API key, a `pulsarctl` command for quick access, and the various service URLs for Kafka and Pulsar. ```Shell apikey = "<...>" pulsarctl_command = "pulsarctl context set -s --token sl-clu && pulsarctl topics get sl-app-tenant/sl-app-ns/sl-app-topic" service_urls = { "kafka_bootstrap_url" = "..." "pulsar_broker_service_url" = "..." "pulsar_web_service_url" = "..." } ``` -------------------------------- ### Initialize Terraform Working Directory Source: https://docs.streamnative.io/tools/terraform/terraform-provider-tutorial This command initializes the Terraform working directory, downloading necessary providers and modules. It must be run before any other Terraform commands to prepare the environment. ```Shell terraform init ``` -------------------------------- ### Quickstart Property Bundled Schema Options Source: https://docs.streamnative.io/connect/connectors/kafka-connect-datagen/current/kafka-connect-datagen-source This section details the available values for the `quickstart` property, which allows users to generate various types of bundled schema data for quick setup and testing. Each value corresponds to a specific data generation profile. ```APIDOC The `quickstart` property can be set to one of the following values: `quickstart` property values: - `clickstream_codes`: Generates clickstream codes data - `clickstream`: Generates clickstream data - `clickstream_users`: Generates clickstream users data - `orders`: Generates order data - `ratings`: Generates ratings data - `users`: Generates user data - `users_`: Generates alternative user data - `pageviews`: Generates pageview data - `stock_trades`: Generates stock trade data - `inventory`: Generates inventory data - `product`: Generates product data - `purchases`: Generates purchase data - `transactions`: Generates transaction data - `stores`: Generates store data - `creadit_cards`: Generates credit card data - `campaign_finance`: Generates campaign finance data - `fleet_mgmt_description`: Generates fleet management description data - `fleet_mgmt_location`: Generates fleet management location data - `fleet_mgmt_sensors`: Generates fleet management sensor data - `pizza_orders`: Generates pizza order data - `pizza_orders_completed`: Generates completed pizza order data - `pizza_orders_cancelled`: Generates cancelled pizza order data - `insurance_offers`: Generates insurance offer data - `insurance_customers`: Generates insurance customer data - `insurance_customer_activity`: Generates insurance customer activity data - `gaming_games`: Generates gaming game data - `gaming_players`: Generates gaming player data - `gaming_player_activity`: Generates gaming player activity data - `payroll_employee`: Generates payroll employee data - `payroll_empolyee_location`: Generates payroll employee location data - `payroll_bonus`: Generates payroll bonus data - `syslog_logs`: Generates syslog log data - `device_information`: Generates device information data - `siem_logs`: Generates SIEM log data - `shoes`: Generates shoe data - `shoe_customers`: Generates shoe customer data - `shoe_orders`: Generates shoe order data - `shoe_clickstream`: Generates shoe clickstream data ``` -------------------------------- ### Canal Source Connector Configuration Examples Source: https://docs.streamnative.io/connect/connectors/canal-source/current/canal-source Example configuration files for the Canal source connector, demonstrating how to set properties like Zookeeper servers, batch size, destination, authentication, and Canal server host/port in both JSON and YAML formats. ```JSON { "zkServers": "127.0.0.1:2181", "batchSize": "5120", "destination": "example", "username": "", "password": "", "cluster": false, "singleHostname": "127.0.0.1", "singlePort": "11111" } ``` ```YAML configs: zkServers: "127.0.0.1:2181" batchSize: 5120 destination: "example" username: "" password: "" cluster: false singleHostname: "127.0.0.1" singlePort: 11111 ``` -------------------------------- ### SQL Example: Inserting Data into Google BigQuery Table Source: https://docs.streamnative.io/connect/connectors/google-bigquery-source/current/google-bigquery-source An example SQL `INSERT` statement to populate a Google BigQuery table with sample data. This data will be synchronized by the BigQuery Source Connector when it starts, as the connector performs a snapshot of existing data. ```SQL INSERT INTO `{{Your dataset name}}.{{Your table name}}` (message, info) VALUES ("message-1", "This is a message-1."), ("message-2", "This is a message-2."), ("message-3", "This is a message-3."), ("message-4", "This is a message-4."), ("message-5", "This is a message-5."), ("message-6", "This is a message-6."), ("message-7", "This is a message-7."), ("message-8", "This is a message-8."), ("message-9", "This is a message-9."), ("message-10", "This is a message-10."); ``` -------------------------------- ### Apply Full Terraform Resource Provisioning Source: https://docs.streamnative.io/tools/terraform/terraform-provider-tutorial This command applies the execution plan for all resources defined in the Terraform configuration, provisioning all StreamNative and Pulsar resources. This completes the infrastructure setup. ```Shell terraform apply ``` -------------------------------- ### Pulsar Consumer Output for Pulsar Producer Message Source: https://docs.streamnative.io/private-cloud/v1/quick-start/platform-quickstart Example output from a Pulsar consumer, showing a message originally sent by a Pulsar producer. ```text ----- got message ----- message-from-pulsar-producer ``` -------------------------------- ### Launch DuckDB CLI Source: https://docs.streamnative.io/cloud/get-started/quickstart-ursa This command launches the DuckDB command-line interface, providing an interactive environment to execute SQL queries and manage data. ```Shell duckdb ``` -------------------------------- ### Java: Kafka Producer and Pulsar Key-Shared Consumer Example Source: https://docs.streamnative.io/cloud/build/kafka-clients/advanced-features/interoperability-between-kafka-and-pulsar A comprehensive Java example demonstrating how to produce messages to a Kafka-compatible Pulsar topic using `KafkaProducer` and consume them using a Pulsar `Consumer` with a `Key_Shared` subscription. The code includes setup for both Kafka and Pulsar clients, authentication, and basic message flow logic. ```Java import org.apache.kafka.clients.CommonClientConfigs; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.StringSerializer; import org.apache.pulsar.client.api.Consumer; import org.apache.pulsar.client.api.Message; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.SubscriptionType; import org.apache.pulsar.client.api.AuthenticationFactory; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; public class PulsarFormatKafkaProducePulsarKeySharedSubscriptionConsume { private static final int NUM_CONSUMERS = 3; private static final int NUM_MESSAGES = 100; private static final int NUM_KEYS = 10; // Replace these configs with your actual cluster settings private static final String pulsarServiceUrl = ""; private static final String kafkaServiceUrl = ""; private static final String jwtToken = ""; private static final String namespace = "public/default"; public static void main(String[] args) throws Exception { final String topic = "topic-with-pulsar-non-batched-format"; final String subscription = "test-key-shared-subscription-group"; PulsarClient client = PulsarClient.builder() .serviceUrl(pulsarServiceUrl) .authentication(AuthenticationFactory.token(jwtToken)) .build(); // Create kafka producer Properties props = new Properties(); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaServiceUrl); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); // Add authentication if needed props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SASL_SSL"); props.put("sasl.mechanism", "PLAIN"); props.put("sasl.jaas.config", String.format( "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"%s\" password=\"%s\";", namespace, "token:" + jwtToken)); final KafkaProducer kafkaProducer = new KafkaProducer<>(props); // Create multiple pulsar consumers with Key_Shared subscription List> consumers = new ArrayList<>(); for (int i = 0; i < NUM_CONSUMERS; i++) { Consumer consumer = client.newConsumer() .topic(topic) .subscriptionName(subscription) .subscriptionType(SubscriptionType.Key_Shared) .subscribe(); consumers.add(consumer); } // Maps to track message distribution Map keyToConsumerMap = new ConcurrentHashMap<>(); Map> consumerToKeysMap = new HashMap<>(); for (int i = 0; i < NUM_CONSUMERS; i++) { consumerToKeysMap.put(i, new HashSet<>()); } // Atomic counter to track processed messages AtomicInteger processedMessages = new AtomicInteger(0); // Create consumer futures List> futures = new ArrayList<>(); ``` -------------------------------- ### Kafka Consumer Output for Pulsar Producer Message Source: https://docs.streamnative.io/private-cloud/v1/quick-start/platform-quickstart Example output from a Kafka consumer, demonstrating its ability to receive a message originally sent by a Pulsar producer, highlighting interoperability. ```text > message-from-pulsar-producer ``` -------------------------------- ### Output of snctl get pulsarinstance Source: https://docs.streamnative.io/tools/cli/snctl/snctl-tutorials Example output displaying a list of Pulsar instances, their names, and the time they were created. This helps in quickly identifying and managing multiple instances. ```shell NAME CREATED AT instance-test 2020-08-13T14:14:43Z neo 2020-08-11T07:37:49Z test-orga-a 2020-08-12T05:32:33Z ``` -------------------------------- ### Create Pulsar Consumer Source: https://docs.streamnative.io/private-cloud/v1/quick-start/platform-quickstart Starts a Pulsar consumer to subscribe to a specified topic with a given subscription name. The '-n 0' flag indicates that the consumer should consume all available messages from the topic. ```bash pulsar-client consume -s -n 0 ``` -------------------------------- ### Initialize Node.js Kafka Project Directory Source: https://docs.streamnative.io/clients/kafka-clients/node.js/tutorial/kafka-js-create-project This command sequence creates a new directory for the Kafka Node.js project and immediately navigates into it. This is the foundational step for organizing project files. ```Shell mkdir kafka-nodejs-getting-started && cd kafka-nodejs-getting-started ``` -------------------------------- ### Verify current pulsarctl context Source: https://docs.streamnative.io/tools/cli/pulsarctl/pulsarctl-overview This command displays the currently active `pulsarctl` context. It is used to confirm that the `pulsarctl` configuration has been successfully updated and is now pointing to the intended StreamNative Cloud cluster. ```bash pulsarctl context current ``` -------------------------------- ### Start Kafka Console Producer Source: https://docs.streamnative.io/private-cloud/v1/operating-streamnative-platform/network/istio This command initiates a Kafka console producer, allowing messages to be sent to a specified Kafka topic. It connects to the Kafka broker via the provided broker list and uses the `client.properties` file for SSL configuration, enabling secure message production. ```bash bin/kafka-console-producer.sh \ --broker-list \ --topic \ --producer.config client.properties ``` -------------------------------- ### Verify Pulsar Consumer Output Source: https://docs.streamnative.io/cloud/get-started/quickstart-console This snippet shows the expected output from the consumer script after the producer has sent messages. It confirms that the consumer successfully received and processed the messages, displaying their content and message IDs. ```text Received message 'Hello-0' id='' Received message 'Hello-1' id='' Received message 'Hello-2' id='' Received message 'Hello-3' id='' Received message 'Hello-4' id='' Received message 'Hello-5' id='' Received message 'Hello-6' id='' Received message 'Hello-7' id='' Received message 'Hello-8' id='' Received message 'Hello-9' id='' ``` -------------------------------- ### Create and Navigate to Kafka Java Project Directory Source: https://docs.streamnative.io/clients/kafka-clients/java/tutorial/kafka-java-create-project This command-line snippet demonstrates how to create a new directory named 'kafka-java-getting-started' for the project and then immediately change the current working directory into the newly created one. ```Shell mkdir kafka-java-getting-started && cd kafka-java-getting-started ``` -------------------------------- ### Run Pulsar Producer Script Source: https://docs.streamnative.io/cloud/get-started/quickstart-byoc This command executes the `producer.py` Python script, which is responsible for sending messages to a Pulsar topic. It should be run in a separate terminal window from the consumer to demonstrate the end-to-end message flow. ```bash python3 producer.py ```