GithubHelp home page GithubHelp logo

dimensional-fun / usagi Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 879 KB

๐Ÿฐ kotlin multi-platform rabbitmq/amqp client

Home Page: https://dimensional-fun.github.io/usagi

License: Apache License 2.0

Kotlin 100.00%
java jvm kotlin kotlin-coroutines kotlin-multiplatform ktor ktorio rabbitmq amqp-0-9-1 amqp

usagi's Introduction

Usagi

A kotlin multi-platform AMQP 0.9.1 client.

Warning Usagi is in Alpha, bugs may be ahead!

We are looking for contributors! If you are looking for a kotlin multiplatform AMQP client please consider opening PRs and Issues, it is very appreciated.

Installation

Requires Kotlin 1.8.20 and Java 8 if you're using the JVM artifact

๐Ÿ˜ Gradle

  • Latest Version: 1.0.0-rc.1
repositories {
    maven("https://maven.dimensional.fun/releases") // or /snapshots
}

dependencies {
    // common:
    implementation("fun.dimensional:usagi:{VERSION}")
}

Usage

Note
This API is not final, it may change in the future.

Create a Channel:

val connection = Usagi("amqp://localhost") {
    properties { connectionName = "my-service" }
}

val channel = connection.channels.create() 
    ?: error("Unable to create channel")

Using Exchanges & Queues

channel.exchange.declare { 
    exchange = "my-exchange" 
}

val queueName = channel.queue.declare()?.queue
    ?: error("Unable to declare queue")

channel.queue.bind {
    exchange = "my-exchange"
    queue = queueName
    routingKey = "my-routing-key"
}

Publishing Messages:

channel.basic.publish {
    data = "Hello, World!".encodeToByteArray()
    
    properties {
        contentType = "text/plain"
    }
    
    options {
        exchange = "my-exchange"
        routingKey = "my-routing-key"
    }
}

Consuming Messages:

val consumer = channel.basic.consume {
    queue = queueName
}

consumer.forEach { delivery ->
    println(delivery.data.decodeToString()) // >> 'Hello, World'
    delivery.ack(multiple = false)
}

Acknowledgements


Dimensional Fun

usagi's People

Contributors

viztea avatar vytskalt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

usagi's Issues

Recover channels closed by the server

RabbitMQ closes channels after a certain period of time (i think), the official rabbitmq java client has a Channel wrapper that automatically recovers it after a channel.close is received.

This is a very critical feature to have implemented.

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.