Skip to content

Commit

Permalink
[resolves #160] Provide camel-jgroups support
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Diesler committed Jul 6, 2015
1 parent 89eb72a commit 20e675a
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 0 deletions.
4 changes: 4 additions & 0 deletions itests/standalone/basic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jgroups</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-mail</artifactId>
Expand Down
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);
}
}
1 change: 1 addition & 0 deletions modules/etc/baseline/module-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
/org/apache/camel/component/http4/main/camel-http4-2.15.2.jar
/org/apache/camel/component/jackson/main/camel-jackson-2.15.2.jar
/org/apache/camel/component/jaxb/main/camel-jaxb-2.15.2.jar
/org/apache/camel/component/jgroups/main/camel-jgroups-2.15.2.jar
/org/apache/camel/component/jms/main/camel-jms-2.15.2.jar
/org/apache/camel/component/jmx/main/camel-jmx-2.15.2.jar
/org/apache/camel/component/jpa/main/camel-jpa-2.15.2.jar
Expand Down
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>
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<module name="org.apache.camel.component.http4" export="true" services="export" />
<module name="org.apache.camel.component.jackson" export="true" services="export" />
<module name="org.apache.camel.component.jaxb" export="true" services="export" />
<module name="org.apache.camel.component.jgroups" export="true" services="export" />
<module name="org.apache.camel.component.jms" export="true" services="export" />
<module name="org.apache.camel.component.jmx" export="true" services="export" />
<module name="org.apache.camel.component.jpa" export="true" services="export" />
Expand Down
11 changes: 11 additions & 0 deletions modules/etc/smartics/camel-modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,17 @@
</dependencies>
</module>

<module name="org.apache.camel.component.jgroups">
<include artifact="org.apache.camel:camel-jgroups" />
<apply-to-dependencies skip="true">
<include module="org.apache.camel.apt" />
</apply-to-dependencies>
<dependencies>
<module name="javax.api"/>
<module name="org.slf4j"/>
</dependencies>
</module>

<module name="org.apache.camel.component.jms">
<include artifact="org.apache.camel:camel-jms" />
<apply-to-dependencies skip="true">
Expand Down
4 changes: 4 additions & 0 deletions modules/etc/smartics/wildfly-modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@
<include artifact=":jdom" />
</module>

<module name="org.jgroups" skip="true">
<include artifact=":jgroups" />
</module>

<module name="org.slf4j" skip="true">
<include artifact=":jcl-over-slf4j" />
<include artifact=":slf4j-api" />
Expand Down
5 changes: 5 additions & 0 deletions modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@
<artifactId>camel-jaxb</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jgroups</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
Expand Down

0 comments on commit 20e675a

Please sign in to comment.