Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wu-sheng/datacarrier
DataCarrier is a light, embed, high-throughput, publish-subscribe MQ.
https://github.com/wu-sheng/datacarrier
Last synced: about 2 months ago
JSON representation
DataCarrier is a light, embed, high-throughput, publish-subscribe MQ.
- Host: GitHub
- URL: https://github.com/wu-sheng/datacarrier
- Owner: wu-sheng
- License: apache-2.0
- Created: 2016-10-25T06:19:45.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-03-24T06:07:36.000Z (almost 5 years ago)
- Last Synced: 2024-10-04T09:51:33.283Z (3 months ago)
- Language: Java
- Homepage:
- Size: 48.8 KB
- Stars: 55
- Watchers: 9
- Forks: 21
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DataCarrier
DataCarrier is a light, embed, high-throughput, publish-subscribe MQ.**This project has been included and donated into Apache software foundation, as a part of [Apache SkyWalking](https://github.com/apache/incubator-skywalking).**
[Sky-Walking APM](https://github.com/wu-sheng/sky-walking) uses **DataCarrier** in sky-walking agaent, one implementation version is used in OneAPM Ai commercial edition. See [skywalking version](https://github.com/wu-sheng/sky-walking/tree/master/apm-commons/apm-datacarrier).
[![Coverage Status](https://coveralls.io/repos/github/wu-sheng/DataCarrier/badge.svg?branch=master&q=2)](https://coveralls.io/github/wu-sheng/DataCarrier?branch=master&q=3)
[ ![Download](https://api.bintray.com/packages/wu-sheng/DataCarrier/com.a.eye.data-carrier/images/download.svg) ](https://bintray.com/wu-sheng/DataCarrier/com.a.eye.data-carrier/_latestVersion)## Why need DataCarrier
- Publish-Subscribe In-Memory MQ. Support multi Producers and Consumer.
- Light and Embed. A mini java lib, less than 20k, no other dependences.
- High-throughput. Used in [Sky-Walking APM](https://github.com/wu-sheng/sky-walking).
- Easy to use. Simple API
- Only need jdk1.6## Download
- [Download](https://bintray.com/wu-sheng/DataCarrier/com.a.eye.data-carrier/_latestVersion) latest version
- Use Maven, Gradle, Ivy, SBT, etc. [set JCenter Center Repository](https://bintray.com/bintray/jcenter?filterByPkgName=com.a.eye.data-carrier)
- maven
```xml
false
central
bintray
http://jcenter.bintray.com
false
central
bintray-plugins
http://jcenter.bintray.com
bintray
bintray
```
```com.a.eye
data-carrier
x.x```
## How to use
- create a new DataCarrier instance
```java
/**
* channelSize = 5, bufferSize per channel = 5000
*/
DataCarrier carrier = new DataCarrier(5, 5000);
```- set message buffer strategy (optional)
```java
/**
* default is BLOCKING
* BLOCKING, waiting to set value to buffer, return when finished.
* OVERRIDE, force to set value to buffer, return true forever.
* IF_POSSIBLE, try to set value to buffer, return true when set successfully.
*/
carrier.setBufferStrategy(BufferStrategy.IF_POSSIBLE);
```- set partitioner (optional)
```java
/**
* default is SimpleRollingPartitioner
* provided: ProducerThreadPartitioner, SimpleRollingPartitioner
* you can create any partitioner, only need to implements IDataPartitioner interface
*/
carrier.setPartitioner(new ProducerThreadPartitioner());
```
ref to [partitioner implements](src/main/java/com/a/eye/datacarrier/partition)- set consumer and start to consume data
```java
/**
* set consumers to this Carrier.
* consumer begin to run when {@link DataCarrier#produce(T)} begin to work.
*
* @param consumerClass class of consumer
* @param num number of consumer threads
*/
carrier.consume(SampleConsumer.class, 10);or
/**
* set consumers to this Carrier.
* consumer begin to run when {@link DataCarrier#produce(T)} begin to work.
*
* @param consumer single instance of consumer, all consumer threads will all use this instance.
* @param num number of consumer threads
* @return
*/
carrier.consume(consumer, 10);
```- create a consumer (sample)
```java
public class SampleConsumer implements IConsumer {
public int i = 1;@Override
public void init() {}
@Override
public void consume(List data) {
for(SampleData one : data) {
one.setIntValue(this.hashCode());
ConsumerTest.buffer.offer(one);
}
}@Override
public void onError(List data, Throwable t) {}
@Override
public void onExit() {}
}
```- produce messages as you need (sample)
```java
for (int i = 0; i < 200; i++) {
carrier.produce(new SampleData());
}
```## Doc
[(中文)SkyWalking子项目--DataCarrier 1.0 解读 ](http://wu-sheng.iteye.com/blog/2334404)