搜尋套件、儲存庫與 APP 分類

套件詳情v0.3.1

dart_amqp

一個原生的 Dart AMQP 客戶端,支援 AMQP 協定的 0.9.1 版本。它具備非同步 API、可插入的身份驗證提供者以及 TLS 支援。

AndroidiOSmacOSWindowsLinux
近 30 天下載
7500
喜歡數
63
Pub 分數
150

安裝套件

flutter pub add dart_amqp

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

dart_amqp 是 AMQP 0.9.1 協議的原生 Dart 客戶端,可在 Dart 應用中實現即時通訊。它提供非同步 API 以有效處理訊息,支援 TLS 加密以確保連接安全,並允許使用可插入的身份驗證機制。非常適合與訊息代理(如 RabbitMQ)整合,可在跨平台環境中實現可靠且低延遲的訊息傳遞。

適用情境

  • 即時訊息系統
  • 物聯網裝置通訊
  • 事件驅動的後端服務
  • 即時串流資料管道
  • 微服務協調

主要特色

  • AMQP 0.9.1 協議支援
  • 非同步API設計
  • TLS 加密
  • 可插入式驗證
  • 跨平台相容性

適合對象

  • 開發即時應用的開發者
  • 使用 RabbitMQ 的團隊
  • 需要安全訊息傳遞的應用程式
  • 需要事件路由的後端服務
  • 跨平台 Dart 項目

使用建議

  • 需要 AMQP 廣播器(例如 RabbitMQ)
  • 限制為 AMQP 0.9.1
  • 需要設置驗證
  • 不適合非即時使用情境
  • 無內建訊息持久化

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

dart_amqp

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).
  • supports both plain-text and TLS connections.
  • supports publish confirmations.
  • supports heartbeats.

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.

Quick start

Listening to a queue:

import "package:dart_amqp/dart_amqp.dart";

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

  Channel channel = await client.channel(); // auto-connect to localhost:5672 using guest credentials
  Queue queue = await channel.queue("hello");
  Consumer consumer = await queue.consume();
  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() async {

  // You can provide a settings object to override the
  // default connection settings
  ConnectionSettings settings = ConnectionSettings(
    host: "remote.amqp.server.com",
    authProvider: PlainAuthenticator("user", "pass")
  );
  Client client = Client(settings: settings);

  Channel channel = await client.channel();
  Exchange exchange = await channel.exchange("logs", ExchangeType.FANOUT);
  // We dont care about the routing key as our exchange type is FANOUT
  exchange.publish("Testing 1-2-3", null);
  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.

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案