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
Dart AMQP client implementing protocol version 0.9.1
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";
voidmain() async {
Client client = Client();
Channel channel = await client.channel(); // auto-connect to localhost:5672 using guest credentialsQueue queue = await channel.queue("hello");
Consumer consumer = await queue.consume();
consumer.listen((AmqpMessage message) {
// Get the payload as a stringprint(" [x] Received string: ${message.payloadAsString}");
// Or unserialize to jsonprint(" [x] Received json: ${message.payloadAsJson}");
// Or just get the raw data as a Uint8Listprint(" [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";
voidmain() async {
// You can provide a settings object to override the// default connection settingsConnectionSettings 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();
}
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.