Code Monkey home page Code Monkey logo

koper's Introduction

Koper

Koper is a MQ-based and event-driven distributed programming framework. [中文README]

Concept

  • Core architecture: Message Architeture, Event Driven Architecture(EDA)
  • Core concept: producer, consumer, message, Message Queue(MQ), topic, subscribe
  • Core component: MessageSender, MessageListener, DataEventListener.
  • High-level concept: consumer group, message partition

Feature

  • Simplified MQ-based listener model and API.
  • Simplified Data Event model and API.
  • MQ provider independent.
    • Koper supports Kafka by default, but also supports other message queue as provider, e.g. RabbitMQ, RocketMQ.
  • High performance and throughput.
  • High scalability based on MQ.
  • High-level feature: time spot recording, message tracking.

Programming Demo

1. Listener Model

Member signup example. When a member signs up, a message is sent to MQ by messageSender.

   messageSender.send("koper.memberSignup", "Signed up successfully! " + member.getPhoneNo());

On the other hand, a consumer subscribes the topic and handle the message, e.g. send a SMS to notify member.

@Component
@Listen(topic = "koper.memberSignup")
public class MemberSignupListener  {

   @Autowired
   private SmsService smsService;
   
   public void onMessage(String msg) {
       smsService.sendSms(msg);
   }
   
}

2. Data Event & Data Listener Model

Order example.

Koper support EDA programming. The Data Event machanism can intercept method invocation of object(such as DAO) and send it to MQ as data event.

orderDao.insertOrder( order);
orderDao.updateOrder( order);

DataListener responds to the event.

@Component
@DataListener(dataObject = "koper.message.demo.dataevent.dao.impl.OrderDaoImpl")
public class OrderListener {
   // data event: onInsertOrder
   public void onInsertOrder(Order order) {
       System.out.println("orderNo : " + order.getOrderNo());
       System.out.println("create time : " + order.getCreatedTime());
       // do some other operations
   }
   //data event: onUpdateOrder
   public void onUpdateOrder(Order order) {
       System.out.println("orderNo : " + order.getOrderNo());
       // do some other operations such as cache refresh
   }
  //data event: exception on updateOrder
   public void onUpdateOrder_X(Order order, DataEvent event) {
      String ex = event.getException();
      System.out.println("onUpdateOrder exception :" +ex);
   }
}

What can we do with Koper?

Koper is designed to support distributed asynchornous programming based on Message Queue and Event Driven Ahchitecture. It's suitable for scenarios such as Web Application, Business Monitor, Data statistics or Big Data etc.

In a large-scale application, the system architecture and event driven architecture look like something below.

Typical use cases

  • Asynchronous Business Process
  • Distributed Data Update or Cache Update
  • Data Log
  • Business Monitor and Alarm

Refer to Async Scenarios and examples for more demos.

Contribute

1 Fix bug or enhance Koper

Feel free to Fork the source code and commit bug fix or enhancement. And then make a pull request to us.

2 Contribute other MQ provider

Koper provides a Kafka provider implementation by default, but also provides high extensibility. You can implement other MQ provider easily, such as RabbitMQ, RocketMQ, ActiveMQ etc.

Refer to Developer Guide for details.

koper's People

Contributors

raymondhekk avatar atterlab avatar johnsoncaii avatar

Watchers

yinhuiyao 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.