Giter Site home page Giter Site logo

koltinpulsar's Introduction

Some Experiments of using Kotlin and Apache Pulsar

This is a collection of experiments of using Kotlin with Apache Pulsar

How to Run

To run Pulsar, the easiest way is to run straight from Docker

docker run -it --rm -p 6650:6650 -p 8080:8080 -v data:/pulsar/data apachepulsar/pulsar:2.6.0 bin/pulsar standalone

And then, simply execute one of the Kotlin main classes.

  • KotlinPulsar.kt - This file contains both a Producer and a Consumer, running in seperate coroutines (lightweight threads)
  • KotlinPulsarProducer.kt - This file contains a standalone producer, that will publish messages to Pulsar
  • KotlinPulsarConsumers.kt - This file contains a standalone consumer, which takes an ID as a parameter, to allow multiple consumers to read the same topic

The easiest way to execute the main classes is to use the maven exec command

  1. Combined Producer / Consumer (KotlinPulsar.kt)

    mvn exec:java -Dexec.mainClass=KotlinPulsarKt

  2. Standalone Producer

    mvn exec:java -Dexec.mainClass=KotlinPulsarProducerKt

  3. Standalone Consumer(s)

    mvn exec:java -Dexec.mainClass=KotlinPulsarConsumersKt -Dexec.args=1

Note: On the standalone consumers, it takes an argument (in the example below, a 1). This appends to the consumer name. If you start multiple consumers with the same argument, the consumption will be Shared (based on the strategy specified in the code). If you start multiple consumers with different arguments, each consumer will consume all messages.

koltinpulsar's People

Contributors

codemwnci avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.