You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/01/22 02:20:41 UTC
[2/8] james-project git commit: MAILBOX-376 WorkQueueName need to
carry a Group instance
MAILBOX-376 WorkQueueName need to carry a Group instance
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/00973f98
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/00973f98
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/00973f98
Branch: refs/heads/master
Commit: 00973f98b6e9705cde3caaa910ab599ad921cf8b
Parents: 97555fe
Author: tran tien duc <dt...@linagora.com>
Authored: Mon Jan 21 11:17:37 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Tue Jan 22 09:20:12 2019 +0700
----------------------------------------------------------------------
.../mailbox/events/EventBusTestFixture.java | 6 ++++--
.../james/mailbox/events/GroupRegistration.java | 22 ++++++++++----------
2 files changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/00973f98/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
index acac797..263a439 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
@@ -93,9 +93,11 @@ public interface EventBusTestFixture {
MailboxIdRegistrationKey KEY_1 = new MailboxIdRegistrationKey(ID_1);
MailboxIdRegistrationKey KEY_2 = new MailboxIdRegistrationKey(ID_2);
MailboxIdRegistrationKey KEY_3 = new MailboxIdRegistrationKey(ID_3);
- List<Class<? extends Group>> ALL_GROUPS = ImmutableList.of(GroupA.class, GroupB.class, GroupC.class);
-
GroupA GROUP_A = new GroupA();
+ GroupB GROUP_B = new GroupB();
+ GroupC GROUP_C = new GroupC();
+ List<Group> ALL_GROUPS = ImmutableList.of(GROUP_A, GROUP_B, GROUP_C);
+
ConditionFactory WAIT_CONDITION = await().timeout(Duration.FIVE_SECONDS);
static MailboxListener newListener() {
http://git-wip-us.apache.org/repos/asf/james-project/blob/00973f98/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
index 68f67be..36a6d1a 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
@@ -38,7 +38,6 @@ import org.apache.james.mailbox.MailboxListener;
import com.github.fge.lambdas.Throwing;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
import com.rabbitmq.client.Connection;
import reactor.core.Disposable;
@@ -57,22 +56,25 @@ import reactor.rabbitmq.Sender;
class GroupRegistration implements Registration {
static class WorkQueueName {
- @VisibleForTesting
- static WorkQueueName of(Class<? extends Group> clazz) {
- return new WorkQueueName(groupName(clazz));
- }
+ @VisibleForTesting
static WorkQueueName of(Group group) {
- return of(group.getClass());
+ return new WorkQueueName(group);
}
static final String MAILBOX_EVENT_WORK_QUEUE_PREFIX = MAILBOX_EVENT + "-workQueue-";
+ private final Group group;
private final String name;
- private WorkQueueName(String name) {
- Preconditions.checkArgument(!Strings.isNullOrEmpty(name), "Queue name must be specified");
- this.name = name;
+ private WorkQueueName(Group group) {
+ Preconditions.checkNotNull(group, "Group must be specified");
+ this.group = group;
+ this.name = groupName(group.getClass());
+ }
+
+ public Group getGroup() {
+ return group;
}
String asString() {
@@ -95,7 +97,6 @@ class GroupRegistration implements Registration {
private final EventSerializer eventSerializer;
private final GroupConsumerRetry retryHandler;
private final WaitDelayGenerator delayGenerator;
- private final RetryBackoffConfiguration retryBackoff;
private Optional<Disposable> receiverSubscriber;
GroupRegistration(Mono<Connection> connectionSupplier, Sender sender, EventSerializer eventSerializer,
@@ -109,7 +110,6 @@ class GroupRegistration implements Registration {
this.receiverSubscriber = Optional.empty();
this.unregisterGroup = unregisterGroup;
this.retryHandler = new GroupConsumerRetry(sender, queueName, group, retryBackoff);
- this.retryBackoff = retryBackoff;
this.delayGenerator = WaitDelayGenerator.of(retryBackoff);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org