GithubHelp home page GithubHelp logo

todor-kolev / example-provider-java-kafka Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pactflow/example-provider-java-kafka

0.0 0.0 0.0 192 KB

Example Java Kafka Producer

License: MIT License

Java 66.36% Makefile 33.64%

example-provider-java-kafka's Introduction

Example Java Kafka Producer

Build

Can I deploy Status

Pact Status (latest pact)

Pact Status (latest pact)

Pact Status (master/master pact)

Pact Status (master/master pact)

This is an example of a Java Spring Boot Kafka Producer that uses Pact, PactFlow and GitHub Actions to ensure that it is compatible with the expectations its consumers have of it.

See the canonical provider example here: https://github.com/pactflow/example-provider See also the full PactFlow CI/CD Workshop for which this can be substituted in as the "provider".

In the following diagram, we'll be testing the "Event API", a service that publishes product events to a Kafka stream on the product topic.

Kafka Architecture

Pre-requisites

Software:

Environment variables

To be able to run some of the commands locally, you will need to export the following environment variables into your shell:

  • PACT_BROKER_TOKEN: a valid API token for PactFlow
  • PACT_BROKER_BASE_URL: a fully qualified domain name with protocol to your pact broker e.g. https://dius.pactflow.io
  • PACT_BROKER_HOST: a fully qualified domain name without protocol to your pact broker e.g. dius.pactflow.io

Usage

  • Running tests: ./gradlew clean test

  • Start a Kafka cluster, and setup the producer endpoint (enables POST to localhost:8081/products): make start

  • Create a new event (manually):

    curl -X POST -H"Content-Type: application/json" localhost:8081/products -d '{
      "id": "7e54c13c-e28e-41fc-b34d-99de62db4666",
      "name": "Unbranded Plastic Tuna",
      "type": "BACON",
      "event": "UPDATED",
      "version": "v1"
    }'
    

To disable test data generation that puts random events onto product topic, prefix with SEND_TEST_EVENTS=false. e.g. SEND_TEST_EVENTS=false make start

example-provider-java-kafka's People

Contributors

you54f avatar mefellows avatar devflow-tools avatar tinexw avatar mend-for-github-com[bot] 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.