-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from achilleasa/support-confirm
Support publish confirmations
- Loading branch information
Showing
15 changed files
with
331 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import "dart:async"; | ||
import "package:dart_amqp/dart_amqp.dart"; | ||
|
||
void main() async { | ||
Completer done = Completer(); | ||
Client client = Client(); | ||
Channel channel = await client.channel(); | ||
Queue queue = await channel.privateQueue(); | ||
|
||
// To work with publish confirmations we first need to enable support for | ||
// confirmations on the channel used by our queue. | ||
await queue.channel.confirmPublishedMessages(); | ||
|
||
// Then register a handler to process publish notifications. | ||
queue.channel.publishNotifier((PublishNotification notification) { | ||
Object? msg = notification.message; | ||
String? corId = notification.properties?.corellationId; | ||
bool ack = notification.published; | ||
print( | ||
" [!] received delivery notification: msg: '$msg', correlation ID: '$corId', ACK'd?: $ack"); | ||
done.complete(); | ||
}); | ||
|
||
MessageProperties msgProps = MessageProperties()..corellationId = "42"; | ||
queue.publish("Hello World!", properties: msgProps); | ||
print(" [x] Sent 'Hello World!'; waiting for delivery confirmation"); | ||
|
||
await done.future; | ||
await client.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
part of dart_amqp.client; | ||
|
||
class _PublishNotificationImpl implements PublishNotification { | ||
@override | ||
final Object? message; | ||
@override | ||
final MessageProperties? properties; | ||
@override | ||
bool published; | ||
|
||
_PublishNotificationImpl(this.message, this.properties, this.published); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
part of dart_amqp.client; | ||
|
||
abstract class PublishNotification { | ||
Object? get message; | ||
MessageProperties? get properties; | ||
bool get published; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.