Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add named queue binding #30

Merged
merged 3 commits into from
Nov 6, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/src/client/impl/exchange_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,24 @@ class _ExchangeImpl implements Exchange {
}
return queue.consume(consumerTag: consumerTag, noAck: noAck);
}

Future<Consumer> bindQueueConsumer(String queueName, List<String> routingKeys,
hyeonjae marked this conversation as resolved.
Show resolved Hide resolved
{String consumerTag, bool noAck = true}) async {
// Fanout and headers exchanges do not need to specify any keys. Use the default one if none is specified
if ((type == ExchangeType.FANOUT || type == ExchangeType.HEADERS) &&
(routingKeys == null || routingKeys.isEmpty)) {
routingKeys = [""];
}

if ((routingKeys == null || routingKeys.isEmpty)) {
throw ArgumentError(
"One or more routing keys needs to be specified for this exchange type");
}

Queue queue = await channel.queue(queueName);
for (String routingKey in routingKeys) {
await queue.bind(this, routingKey);
}
return queue.consume(consumerTag: consumerTag, noAck: noAck);
}
}