Code Monkey home page Code Monkey logo

neobus's Introduction

NeoBus

NeoBus is a powerful library that enables you to send commands, queries, and events using the CQRS pattern in .NET. It simplifies the implementation of distributed systems and event-driven architectures by seamlessly integrating with Kafka. If you find NeoBus helpful, please consider giving it a star ⭐ to show your support.

Installation

You can easily install NeoBus via NuGet Package Manager:

> Install-Package NeoBus

Configuration

To configure NeoBus, add the following settings to your appsettings.json file and specify your Kafka server address:

"NeoBus": {
    "Kafka": {
        "Servers": ["localhost:9092"]
    }
}

Registration

Incorporate NeoBus into your project by registering it in the Startup.cs file within the ConfigureServices method:

services.AddNeoBus(Assembly.GetExecutingAssembly());

Distributed Events (Kafka)

For distributed events using Kafka, register the necessary services as follows:

services.AddHostedService<KafkaEventSubscriberService<ProductAddedEventOnKafka, ProductAddedEventOnKafkaHandler>>();
services.AddSingleton<ProductAddedEventOnKafkaHandler>();

If you are using a version lower than 1.2.0, use the following code to register and manually register commands and queries:

services.AddNeoBus();

Registering Commands, Queries, and In-Memory Events

To register commands and queries, follow these steps:

Command and Query Handlers:

services.AddScoped<IRequestHandler<ProductAddCommand, CommandResult>, ProductAddCommandHandler>();
services.AddScoped<IRequestHandler<GetProductQuery, CommandResult>, GetProductQueryHandler>();

In-Memory Event Handlers:

services.AddScoped<INotificationHandler<ProductAddedEvent>, ProductAddedEventHandler>();

Sample Project

Explore a sample project that demonstrates how to use NeoBus:

Sample For Use NeoBus

Setting Up Kafka with Docker Compose

To run Kafka locally, follow these instructions:

  1. Install Docker on your local machine.
  2. Download the docker-compose-kafka.yml file from within the project solution.
  3. Open your Terminal as an administrator.
  4. Navigate to the directory containing the docker-compose-kafka.yml file.
  5. Run the following command:
docker-compose -f docker-compose-kafka.yml up

Now Kafka is up and running in a Docker container.

Learn More

For more information about NeoBus and its applications, consider reading the following articles:

  1. EventBus Application and Introduction of NeoBus Package
  2. کاربرد EventBus و معرفی پکیج NeoBus (Persian)

Feel free to explore these resources to enhance your understanding of NeoBus and its capabilities.

neobus's People

Contributors

omid-ahmadpour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bubdm

neobus's Issues

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.