Coder Social home page Coder Social logo

first-nestjs's Introduction

Ein Kafka Producer und Consumer mit NestJS

Ausprobieren in Visual Studio Code

git clone <project>
cd first-nestjs
code .

Open in Devcontainer ! Terminal-zweiteilen

Dann

  1. falls nicht sichtbar, ein Terminal (Menü Terminal/New Terminal) öffnen,

  2. die Docker Container starten

    docker compose up -d
  3. das Terminal teilen (zwei Terminals)

    Terminal-zweiteilen

  4. Bauen und ausprobieren Terminal-zweiteilen

    • linkes Terminal:

      npm install
      npm run start:dev
      #
      #> [email protected] start
      #> nest start
      #
      #[Nest] 1892  - 08/01/2022, 10:31:45 AM     LOG [NestFactory] #Starting Nest application...
    • rechtes Terminal:

      curl localhost:3000 
      # Hello World!%                    
      curl localhost:3000/kafka-test
      # [{"topicName":"medium.rocks","partition":0,"errorCode":0,"baseOffset":"0","logAppendTime":"-1","logStartOffset":"-1"}]%
      # ...
      # [main.ts] Application is running on: http://[::1]:3000            

    Durch den zweiten curl Aufruf wird ein event erzeugt und gleich auch konsumiert, im linken Terminal erscheint:

    [app.controller.ts] kafka-test emitting now
    [consumer.controller.ts] Receiving a message from topic: medium.rocks{"foo":"bar","data":"Mon Aug 01 2022 10:32:16 GMT+0000 (Coordinated Universal Time)"}

Der Code

Zum NestJS Framework:

Aufbau des Projekts:

first-nestjs's People

Watchers

 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.