Permalink
Browse files

fixed issue with local handlers in cluster

  • Loading branch information...
1 parent aa59dc6 commit bda117377779f933a082424228ab58667ab84fe5 @purplefox purplefox committed Jul 22, 2012
@@ -393,6 +393,8 @@ public void handle(AsyncResult<ServerIDs> event) {
ServerIDs serverIDs = event.result;
if (!serverIDs.isEmpty()) {
sendToSubs(serverIDs, message);
+ } else {
+ receiveMessage(message);
}
} else {
log.error("Failed to send message", event.exception);
@@ -105,7 +105,12 @@ public void testReply() {
}
@Test
- public void testLocal() {
+ public void testLocal1() {
+ startTest(getMethodName());
+ }
+
+ @Test
+ public void testLocal2() {
startTest(getMethodName());
}
@@ -89,13 +89,22 @@ public void handle(Message<Buffer> reply) {
}
}
- public void testLocal() {
+ public void testLocal1() {
+ testLocal(true);
+ }
+
+ public void testLocal2() {
+ testLocal(false);
+ }
+
+ public void testLocal(boolean localMethod) {
final int numHandlers = 10;
final String address = UUID.randomUUID().toString();
final AtomicInteger count = new AtomicInteger(0);
final Buffer buff = TestUtils.generateRandomBuffer(1000);
for (int i = 0; i < numHandlers; i++) {
- eb.registerHandler(address, new Handler<Message<Buffer>>() {
+
+ Handler<Message<Buffer>> handler = new Handler<Message<Buffer>>() {
boolean handled;
public void handle(Message<Buffer> msg) {
@@ -110,7 +119,12 @@ public void handle(Message<Buffer> msg) {
}
handled = true;
}
- });
+ };
+ if (localMethod) {
+ eb.registerLocalHandler(address, handler);
+ } else {
+ eb.registerHandler(address, handler);
+ }
}
eb.publish(address, buff);

0 comments on commit bda1173

Please sign in to comment.