-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[resolves #160] Provide camel-jgroups support
- Loading branch information
Thomas Diesler
committed
Jul 6, 2015
1 parent
89eb72a
commit 20e675a
Showing
8 changed files
with
135 additions
and
0 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
96 changes: 96 additions & 0 deletions
96
...standalone/basic/src/main/java/org/wildfly/camel/test/jgroups/JGroupsIntegrationTest.java
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,96 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.wildfly.camel.test.jgroups; | ||
|
||
import java.io.IOException; | ||
import java.util.UUID; | ||
|
||
import org.apache.camel.Exchange; | ||
import org.apache.camel.Processor; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.apache.camel.component.jgroups.JGroupsFilters; | ||
import org.apache.camel.impl.DefaultCamelContext; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(Arquillian.class) | ||
public class JGroupsIntegrationTest { | ||
|
||
String master; | ||
int nominationCount; | ||
|
||
String jgroupsEndpoint = String.format("jgroups:%s?enableViewMessages=true", UUID.randomUUID()); | ||
|
||
DefaultCamelContext firstCamelContext; | ||
DefaultCamelContext secondCamelContext; | ||
|
||
@Deployment | ||
public static JavaArchive createdeployment() throws IOException { | ||
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-jgroups-tests"); | ||
return archive; | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
|
||
class JGroupsRouteBuilder extends RouteBuilder { | ||
|
||
@Override | ||
public void configure() throws Exception { | ||
from(jgroupsEndpoint).filter(JGroupsFilters.dropNonCoordinatorViews()).process(new Processor() { | ||
@Override | ||
public void process(Exchange exchange) throws Exception { | ||
String camelContextName = exchange.getContext().getName(); | ||
if (!camelContextName.equals(master)) { | ||
master = camelContextName; | ||
nominationCount++; | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
firstCamelContext = new DefaultCamelContext(); | ||
firstCamelContext.setName("firstNode"); | ||
firstCamelContext.addRoutes(new JGroupsRouteBuilder()); | ||
|
||
secondCamelContext = new DefaultCamelContext(); | ||
secondCamelContext.setName("secondNode"); | ||
secondCamelContext.addRoutes(new JGroupsRouteBuilder()); | ||
} | ||
|
||
@Test | ||
public void shouldElectSecondNode() throws Exception { | ||
|
||
firstCamelContext.start(); | ||
String firstMaster = master; | ||
secondCamelContext.start(); | ||
firstCamelContext.stop(); | ||
String secondMaster = master; | ||
secondCamelContext.stop(); | ||
|
||
Assert.assertEquals(firstCamelContext.getName(), firstMaster); | ||
Assert.assertEquals(secondCamelContext.getName(), secondMaster); | ||
Assert.assertEquals(2, nominationCount); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
...ted/wildfly/modules/system/layers/fuse/org/apache/camel/component/jgroups/main/module.xml
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module xmlns="urn:jboss:module:1.1" name="org.apache.camel.component.jgroups"> | ||
<resources> | ||
<resource-root path="camel-jgroups-2.15.2.jar" /> | ||
</resources> | ||
<dependencies> | ||
<module name="javax.api" /> | ||
<module name="org.slf4j" /> | ||
<module name="javax.xml.bind.api" /> | ||
<module name="org.apache.camel.core" /> | ||
<module name="org.jgroups" /> | ||
</dependencies> | ||
</module> |
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