Giter Site home page Giter Site logo

dart_amqp's Introduction

dart_ampq

Build Status codecov

Dart AMQP client implementing protocol version 0.9.1

Main features:

  • asynchronous API based on Futures and Streams
  • supports PLAIN and AMQPLAIN authentication providers while other authentication schemes can be plugged in by implementing the appropriate interface.
  • implements the entire 0.9.1 protocol specification (except basic get and recover-async)

Things not working yet:

  • the driver does not currently support recovering client topologies when re-establishing connections. This feature may be implemented in a future version.
  • heartbeats.

Quick start

Listening to a queue:

import "package:dart_amqp/dart_amqp.dart";

void main() {
  Client client = new Client();

  client
  .channel() // auto-connect to localhost:5672 using guest credentials
  .then((Channel channel) => channel.queue("hello"))
  .then((Queue queue) => queue.consume())
  .then((Consumer consumer) => consumer.listen((AmqpMessage message) {
    // Get the payload as a string
    print(" [x] Received string: ${message.payloadAsString}");

    // Or unserialize to json
    print(" [x] Received json: ${message.payloadAsJson}");

    // Or just get the raw data as a Uint8List
    print(" [x] Received raw: ${message.payload}");
    
    // The message object contains helper methods for 
    // replying, ack-ing and rejecting
    message.reply("world");
  }));
}

Sending messages via an exchange:

import "package:dart_amqp/dart_amqp.dart";

void main() {
  
  // You can provide a settings object to override the
  // default connection settings
  ConnectionSettings settings = new ConnectionSettings(
      host : "remote.amqp.server.com",
      authProvider : new PlainAuthenticator("user", "pass")
  );
  Client client = new Client(settings : settings);
  
  client
  .channel()
  .then((Channel channel) => channel.exchange("logs", ExchangeType.FANOUT))
  .then((Exchange exchange) {
    // We dont care about the routing key as our exchange type is FANOUT
    exchange.publish("Testing 1-2-3", null);
    return client.close();
  });
}

Api

See the Api documentation.

RPC calls over AMQP

This example illustrates how to get a basic RPC server/client up and running using just the provided api calls.

The driver does not provide any helper classes for easily performing RPC calls over AMQP as not everyone needs this functionality. If you need RPC support for your application you may want to consider using the dart_amqp_rpc package.

Examples

The example folder contains implementations of the six RabbitMQ getting started tutorials.

Contributing

See the Contributing Guide.

License

dart_amqp is distributed under the MIT license.

dart_amqp's People

Contributors

rajmaniar avatar achilleasa avatar faisalabid avatar

Watchers

Ron Lobo 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.