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

套件詳情v1.0.1

dart_amqp_client

一個 Dart 套件,可簡化 AMQP(進階訊息佇列協定)連接、通道及相關回呼的處理。

AndroidiOSmacOSWindowsLinux
近 30 天下載
105
喜歡數
13
Pub 分數
145

安裝套件

flutter pub add dart_amqp_client

套件介紹

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

一個用於簡化 AMQP(進階訊息佇列協定)通訊的 Dart 套件,可於跨平台環境中實現可靠即時訊息傳遞。它簡化了連接管理、通道處理與回呼執行,適用於訊息驅動的應用程式。非常適合開發聊天系統、即時串流整合或任何需要強大佇列與傳遞保證的即時資料交換。該套件支援多種平台,包括 Android、iOS、macOS、Windows 與 Linux。

適用情境

  • 即時聊天應用
  • 直播串流活動廣播
  • 訊息佇列整合
  • 物聯網設備通訊
  • 事件驅動的後端服務

主要特色

  • 簡化版 AMQP 連接處理
  • 內建頻道管理
  • 非同步回呼支援
  • 跨平台相容性
  • 強大的錯誤處理

適合對象

  • 開發即時應用的開發者
  • 使用基於 AMQP 的訊息系統
  • 需要可靠訊息傳遞的專案
  • 移動和桌面即時通訊
  • 物聯網和後端服務整合

使用建議

  • 需要一個 AMQP 廣播器(例如 RabbitMQ)
  • 與成熟的替代方案相比,文件有限
  • 未針對高吞吐量場景進行優化
  • 依賴外部代理的可用性
  • 可能需要額外設定才能用於生產環境

原始 README

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

Dart AMQP Client

Dart AMQP Client is a Dart package that simplifies the handling of AMQP (Advanced Message Queuing Protocol) connections, channels, and associated callbacks.

Features

Connection Management: Automatically handles AMQP connection establishment and reconnection. Callback Support: Define custom callbacks for connection events, such as when the connection is established or encounters an error. Reconnection Control: Configure the maximum number of reconnection attempts for robust AMQP connections. Simple Integration: Easily integrate the package into your Dart applications with a straightforward API.

Table of Contents

Installation

To use this package, add dart_amqp_client as a dependency in your pubspec.yaml file:

dependencies: dart_amqp_client: ^1.0.1

Then, run pub get to fetch and install the package.

Quick start

import 'package:dart_amqp_client/dart_amqp_client.dart';

void main() {
  // Create a ConnectionSettings instance with your AMQP server details.
  ConnectionSettings connectionSettings = ConnectionSettings(
    host: 'localhost',
    port: 5672,
    maxConnectionAttempts: 5, // Set the maximum connection attempts
  );

  // Create an instance of the AMQP service.
  AmqpService(connectionSettings);

  // Set callback functions for connection events.
  AmqpService.onConnected(() {
    print('Connected to AMQP server.');
    // Use the service to establish an AMQP connection.
    Client client = AmqpService.getClient();

    // ... Perform AMQP operations with the client and channel ...

    String consumeTag = "hello";
    String msg = "Hello World!";

    client.channel().then((Channel channel) {
      return channel.queue(consumeTag, durable: false);
    }).then((Queue queue) {
      queue.publish(msg);
      print(" [x] Sent $msg");
      client.close();
    });

    String queueTag = "hello";
    Channel? channel = AmqpService.getChannel();
    channel!.queue(queueTag, durable: false).then((Queue queue) {
      print(" [*] Waiting for messages in $queueTag. To Exit press CTRL+C");
      return queue.consume(consumerTag: queueTag, noAck: true);
    }).then((Consumer consumer) {
      consumer.listen((AmqpMessage event) {
        print(" [x] Received ${event.payloadAsString}");
      });
    });
  });

  AmqpService.onDisconnected(() {
    print('Disconnected from AMQP server.');
  });

  AmqpService.onError((Exception error) {
    print('An error occurred: $error');
  });
}

Examples

The [example] folder contains implementations for getting started

Contributing

Feel free to contribute

License

dart_amqp is distributed under the [MIT license]

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。