dart_amqp 0.1.1

  • README.md
  • Installing
  • Versions
  • 73

dart_ampq #

Build Status Coverage Status

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();

  .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

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);
  .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.

Changelog #

0.1.1 #

  • Merged #19 to improve support for HEADER exchanges.

0.1.0 #

  • Migrate to Dart 2

0.0.9 #

  • Merged #14 and #15 to fix some type errors reported by dartanalyzer when running with Dart2/Flutter.

0.0.6 #

0.0.5 #

  • Fixes #6 (stack overflow when processing large TCP packets)

0.0.4 #

  • Merged Faisal Abid's PR that forces the client to request a 0 heartbeat timeout

0.0.3 #

  • Merged Raj Maniar's PR that allows users to register a listener for exceptions caught by the client

0.0.2 #

  • Merged Raj Maniar's PR that adds support for handling basicReturn messages

0.0.1 #

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dart_amqp: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dart_amqp/dart_amqp.dart';
Version Uploaded Documentation Archive
0.1.1 Dec 12, 2018 Go to the documentation of dart_amqp 0.1.1 Download dart_amqp 0.1.1 archive
0.1.0 Aug 14, 2018 Go to the documentation of dart_amqp 0.1.0 Download dart_amqp 0.1.0 archive
0.0.9 Jun 14, 2018 Go to the documentation of dart_amqp 0.0.9 Download dart_amqp 0.0.9 archive
0.0.8 Aug 20, 2017 Go to the documentation of dart_amqp 0.0.8 Download dart_amqp 0.0.8 archive
0.0.6 Jun 7, 2016 Go to the documentation of dart_amqp 0.0.6 Download dart_amqp 0.0.6 archive
0.0.5 Apr 21, 2016 Go to the documentation of dart_amqp 0.0.5 Download dart_amqp 0.0.5 archive
0.0.4 Jan 6, 2016 Go to the documentation of dart_amqp 0.0.4 Download dart_amqp 0.0.4 archive
0.0.3 Oct 31, 2015 Go to the documentation of dart_amqp 0.0.3 Download dart_amqp 0.0.3 archive
0.0.2 Oct 2, 2015 Go to the documentation of dart_amqp 0.0.2 Download dart_amqp 0.0.2 archive
0.0.1 May 10, 2015 Go to the documentation of dart_amqp 0.0.1 Download dart_amqp 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13


Detected platforms: Flutter, other

Primary library: package:dart_amqp/dart_amqp.dart with components: io.

Health suggestions

Fix lib/src/client/impl/channel_impl.dart. (-6.78 points)

Analysis of lib/src/client/impl/channel_impl.dart reported 14 hints, including:

line 90 col 13: Use contains instead of indexOf

line 166 col 79: Use = to separate a named parameter from its default value.

line 166 col 97: Use = to separate a named parameter from its default value.

line 419 col 50: Use = to separate a named parameter from its default value.

line 419 col 72: Use = to separate a named parameter from its default value.

Fix lib/src/client/impl/queue_impl.dart. (-5.36 points)

Analysis of lib/src/client/impl/queue_impl.dart reported 11 hints, including:

line 17 col 39: Use = to separate a named parameter from its default value.

line 17 col 61: Use = to separate a named parameter from its default value.

line 17 col 82: Use = to separate a named parameter from its default value.

line 30 col 36: Use = to separate a named parameter from its default value.

line 92 col 79: Use = to separate a named parameter from its default value.

Fix lib/src/client/channel.dart. (-4.89 points)

Analysis of lib/src/client/channel.dart reported 10 hints, including:

line 27 col 50: Use = to separate a named parameter from its default value.

line 27 col 72: Use = to separate a named parameter from its default value.

line 27 col 96: Use = to separate a named parameter from its default value.

line 27 col 121: Use = to separate a named parameter from its default value.

line 27 col 142: Use = to separate a named parameter from its default value.

Fix additional 51 files with analysis or formatting issues. (-17.81 points)

Additional issues in the following files:

  • lib/src/client/queue.dart (10 hints)
  • lib/src/client/connection_settings.dart (6 hints)
  • lib/src/client/exchange.dart (5 hints)
  • lib/src/client/impl/exchange_impl.dart (5 hints)
  • lib/src/client/amqp_message.dart (2 hints)
  • lib/src/client/impl/amqp_message_impl.dart (2 hints)
  • lib/src/protocol/stream/type_encoder.dart (2 hints)
  • lib/src/client/consumer.dart (1 hint)
  • lib/src/client/impl/client_impl.dart (1 hint)
  • lib/src/client/impl/consumer_impl.dart (1 hint)
  • lib/src/protocol/stream/type_decoder.dart (1 hint)
  • lib/dart_amqp.dart (Run dartfmt to format lib/dart_amqp.dart.)
  • lib/src/authentication.dart (Run dartfmt to format lib/src/authentication.dart.)
  • lib/src/authentication/amq_plain_authenticator.dart (Run dartfmt to format lib/src/authentication/amq_plain_authenticator.dart.)
  • lib/src/authentication/authenticator.dart (Run dartfmt to format lib/src/authentication/authenticator.dart.)
  • lib/src/authentication/plain_authenticator.dart (Run dartfmt to format lib/src/authentication/plain_authenticator.dart.)
  • lib/src/client/basicreturn_message.dart (Run dartfmt to format lib/src/client/basicreturn_message.dart.)
  • lib/src/client/client.dart (Run dartfmt to format lib/src/client/client.dart.)
  • lib/src/client/impl/basic_return_message_impl.dart (Run dartfmt to format lib/src/client/impl/basic_return_message_impl.dart.)
  • lib/src/enums/delivery_mode.dart (Run dartfmt to format lib/src/enums/delivery_mode.dart.)
  • lib/src/enums/enum.dart (Run dartfmt to format lib/src/enums/enum.dart.)
  • lib/src/enums/error_type.dart (Run dartfmt to format lib/src/enums/error_type.dart.)
  • lib/src/enums/exchange_type.dart (Run dartfmt to format lib/src/enums/exchange_type.dart.)
  • lib/src/enums/field_type.dart (Run dartfmt to format lib/src/enums/field_type.dart.)
  • lib/src/enums/frame_type.dart (Run dartfmt to format lib/src/enums/frame_type.dart.)
  • lib/src/exceptions/channel_exception.dart (Run dartfmt to format lib/src/exceptions/channel_exception.dart.)
  • lib/src/exceptions/connection_exception.dart (Run dartfmt to format lib/src/exceptions/connection_exception.dart.)
  • lib/src/exceptions/exchange_not_found_exception.dart (Run dartfmt to format lib/src/exceptions/exchange_not_found_exception.dart.)
  • lib/src/exceptions/queue_not_found_exception.dart (Run dartfmt to format lib/src/exceptions/queue_not_found_exception.dart.)
  • lib/src/logging.dart (Run dartfmt to format lib/src/logging.dart.)
  • lib/src/protocol/frame/decoded_message.dart (Run dartfmt to format lib/src/protocol/frame/decoded_message.dart.)
  • lib/src/protocol/frame/impl/decoded_message_impl.dart (Run dartfmt to format lib/src/protocol/frame/impl/decoded_message_impl.dart.)
  • lib/src/protocol/frame/impl/heartbeat_frame_impl.dart (Run dartfmt to format lib/src/protocol/frame/impl/heartbeat_frame_impl.dart.)
  • lib/src/protocol/frame/raw_frame.dart (Run dartfmt to format lib/src/protocol/frame/raw_frame.dart.)
  • lib/src/protocol/headers/content_header.dart (Run dartfmt to format lib/src/protocol/headers/content_header.dart.)
  • lib/src/protocol/headers/frame_header.dart (Run dartfmt to format lib/src/protocol/headers/frame_header.dart.)
  • lib/src/protocol/headers/header.dart (Run dartfmt to format lib/src/protocol/headers/header.dart.)
  • lib/src/protocol/headers/protocol_header.dart (Run dartfmt to format lib/src/protocol/headers/protocol_header.dart.)
  • lib/src/protocol/io/amqp_message_decoder.dart (Run dartfmt to format lib/src/protocol/io/amqp_message_decoder.dart.)
  • lib/src/protocol/io/frame_writer.dart (Run dartfmt to format lib/src/protocol/io/frame_writer.dart.)
  • lib/src/protocol/io/tuning_settings.dart (Run dartfmt to format lib/src/protocol/io/tuning_settings.dart.)
  • lib/src/protocol/messages/bindings/basic.dart (Run dartfmt to format lib/src/protocol/messages/bindings/basic.dart.)
  • lib/src/protocol/messages/bindings/channel.dart (Run dartfmt to format lib/src/protocol/messages/bindings/channel.dart.)
  • lib/src/protocol/messages/bindings/connection.dart (Run dartfmt to format lib/src/protocol/messages/bindings/connection.dart.)
  • lib/src/protocol/messages/bindings/exchange.dart (Run dartfmt to format lib/src/protocol/messages/bindings/exchange.dart.)
  • lib/src/protocol/messages/bindings/queue.dart (Run dartfmt to format lib/src/protocol/messages/bindings/queue.dart.)
  • lib/src/protocol/messages/bindings/tx.dart (Run dartfmt to format lib/src/protocol/messages/bindings/tx.dart.)
  • lib/src/protocol/messages/message.dart (Run dartfmt to format lib/src/protocol/messages/message.dart.)
  • lib/src/protocol/messages/message_properties.dart (Run dartfmt to format lib/src/protocol/messages/message_properties.dart.)
  • lib/src/protocol/stream/chunked_input_reader.dart (Run dartfmt to format lib/src/protocol/stream/chunked_input_reader.dart.)
  • lib/src/protocol/stream/chunked_output_writer.dart (Run dartfmt to format lib/src/protocol/stream/chunked_output_writer.dart.)

Maintenance suggestions

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and dart_amqp.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
logging ^0.11.3+2 0.11.3+2
Dev dependencies
coverage ^0.12.2
coveralls ^3.2.0
http ^0.11.1+1
mockito ^3.0.0
test ^1.3.0
xml ^3.2.0