Commit 7f7ba071 authored by bseeger's avatar bseeger
Browse files

Add message service (broker), which current uses activemq

parent d545e27d
...@@ -24,6 +24,7 @@ Services ...@@ -24,6 +24,7 @@ Services
These modules provide particular services, independent of Fedora Resources. These modules provide particular services, independent of Fedora Resources.
* `acrepo-services-activemq`: This service creates a ActiveMQ connection for other modules to use
* `acrepo-services-inference`: An OSGi-based structural typing service using owl inference * `acrepo-services-inference`: An OSGi-based structural typing service using owl inference
* `acrepo-services-jsonld`: This service creates expanded or compact JSON-LD representations of input documents * `acrepo-services-jsonld`: This service creates expanded or compact JSON-LD representations of input documents
* `acrepo-services-ldcache`: This service dereferences and caches URIs, retrieving the `object` of particular triples on demand * `acrepo-services-ldcache`: This service dereferences and caches URIs, retrieving the `object` of particular triples on demand
......
/*
* Copyright 2016 Amherst College
*
* Licensed 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 edu.amherst.acdc.itests;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.File;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.ConfigurationManager;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.slf4j.Logger;
/**
* @author Bethany Seeger
* @since June 24, 2016
*/
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class AcrepoActiveMQIT extends AbstractOSGiIT {
private static Logger LOGGER = getLogger(AcrepoActiveMQIT.class);
@Configuration
public Option[] config() {
final ConfigurationManager cm = new ConfigurationManager();
final String jmsPort = cm.getProperty("fcrepo.dynamic.jms.port");
final String rmiRegistryPort = cm.getProperty("karaf.rmiRegistry.port");
final String rmiServerPort = cm.getProperty("karaf.rmiServer.port");
final String sshPort = cm.getProperty("karaf.ssh.port");
final String brokerUrl = "tcp://localhost:" + jmsPort;
return new Option[] {
karafDistributionConfiguration()
.frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf")
.versionAsInProject().type("zip"))
.unpackDirectory(new File("target", "exam"))
.useDeployFolder(false),
logLevel(LogLevel.WARN),
keepRuntimeFolder(),
configureConsole().ignoreLocalConsole(),
features(maven().groupId("org.apache.karaf.features").artifactId("standard")
.versionAsInProject().classifier("features").type("xml"), "scr"),
features(maven().groupId("org.apache.activemq").artifactId("activemq-karaf")
.type("xml").classifier("features").versionAsInProject(), "activemq-camel"),
features(maven().groupId("edu.amherst.acdc").artifactId("acrepo-karaf")
.type("xml").classifier("features").versionAsInProject(),
"acrepo-services-activemq"),
mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpclient-osgi").versionAsInProject(),
mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpcore-osgi").versionAsInProject(),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", rmiRegistryPort),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", rmiServerPort),
editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", sshPort),
editConfigurationFilePut("etc/edu.amherst.acdc.services.activemq.cfg", "jms.brokerUrl", brokerUrl),
};
}
@Test
public void testInstallation() throws Exception {
assertTrue(featuresService.isInstalled(featuresService.getFeature("camel-core")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("camel-blueprint")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("activemq-camel")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-activemq")));
}
}
...@@ -81,10 +81,9 @@ public class AcrepoServicesIT extends AbstractOSGiIT { ...@@ -81,10 +81,9 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
"acrepo-connector-idiomatic-pgsql", "acrepo-exts-fits", "acrepo-exts-image", "acrepo-connector-idiomatic-pgsql", "acrepo-exts-fits", "acrepo-exts-image",
"acrepo-exts-jsonld", "acrepo-exts-serialize-xml", "acrepo-exts-template", "acrepo-exts-jsonld", "acrepo-exts-serialize-xml", "acrepo-exts-template",
"acrepo-libs-jena", "acrepo-libs-sesame", "acrepo-libs-jsonld", "acrepo-libs-jena", "acrepo-libs-sesame", "acrepo-libs-jsonld",
"acrepo-libs-jackson", "acrepo-libs-marmotta", "acrepo-libs-jackson", "acrepo-libs-marmotta", "acrepo-services-activemq",
"acrepo-services-jsonld", "acrepo-services-ldcache", "acrepo-services-inference" "acrepo-services-jsonld", "acrepo-services-ldcache",
"acrepo-services-mint", "acrepo-services-pcdm", "acrepo-services-inference", "acrepo-services-mint", "acrepo-services-pcdm", "acrepo-connector-broadcast"),
"acrepo-connector-broadcast"),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.fits.cfg", "rest.port", fitsPort), editConfigurationFilePut("etc/edu.amherst.acdc.exts.fits.cfg", "rest.port", fitsPort),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.image.cfg", "rest.port", imagePort), editConfigurationFilePut("etc/edu.amherst.acdc.exts.image.cfg", "rest.port", imagePort),
...@@ -115,6 +114,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT { ...@@ -115,6 +114,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-jsonld"))); assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-jsonld")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-marmotta"))); assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-marmotta")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-sesame"))); assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-sesame")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-activemq")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-inference"))); assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-inference")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-jsonld"))); assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-jsonld")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-ldcache"))); assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-ldcache")));
......
...@@ -57,6 +57,13 @@ ...@@ -57,6 +57,13 @@
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>edu.amherst.acdc</groupId>
<artifactId>acrepo-services-activemq</artifactId>
<scope>test</scope>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
......
...@@ -68,6 +68,18 @@ ...@@ -68,6 +68,18 @@
<configfile finalname="/etc/edu.amherst.acdc.exts.pcdm.cfg">mvn:edu.amherst.acdc/acrepo-exts-pcdm/${project.version}/cfg/configuration</configfile> <configfile finalname="/etc/edu.amherst.acdc.exts.pcdm.cfg">mvn:edu.amherst.acdc/acrepo-exts-pcdm/${project.version}/cfg/configuration</configfile>
</feature> </feature>
<feature name="acrepo-services-activemq" version="${project.version}">
<details>Installs the ActiveMQ service</details>
<feature version="${camel.version}">camel</feature>
<feature version="${camel.version}">camel-blueprint</feature>
<feature version="${activemq.version}">activemq-camel</feature>
<bundle>mvn:edu.amherst.acdc/acrepo-services-activemq/${project.version}</bundle>
<configfile finalname="/etc/edu.amherst.acdc.services.activemq.cfg">mvn:edu.amherst.acdc/acrepo-services-activemq/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-services-ldcache" version="${project.version}"> <feature name="acrepo-services-ldcache" version="${project.version}">
<details>Installs the LDCache service</details> <details>Installs the LDCache service</details>
......
...@@ -77,11 +77,12 @@ public class KarafIT { ...@@ -77,11 +77,12 @@ public class KarafIT {
final String version = cm.getProperty("project.version"); final String version = cm.getProperty("project.version");
final String acrepoIdiomatic = getBundleUri("acrepo-connector-idiomatic", version); final String acrepoIdiomatic = getBundleUri("acrepo-connector-idiomatic", version);
final String acrepoPcdmSvc = getBundleUri("acrepo-services-pcdm", version); final String acrepoBrokerSvc = getBundleUri("acrepo-services-activemq", version);
final String acrepoInferenceSvc = getBundleUri("acrepo-services-inference", version); final String acrepoInferenceSvc = getBundleUri("acrepo-services-inference", version);
final String acrepoJsonLdSvc = getBundleUri("acrepo-services-jsonld", version); final String acrepoJsonLdSvc = getBundleUri("acrepo-services-jsonld", version);
final String acrepoJsonLd = getBundleUri("acrepo-exts-jsonld", version); final String acrepoJsonLd = getBundleUri("acrepo-exts-jsonld", version);
final String acrepoMintSvc = getBundleUri("acrepo-services-mint", version); final String acrepoMintSvc = getBundleUri("acrepo-services-mint", version);
final String acrepoPcdmSvc = getBundleUri("acrepo-services-pcdm", version);
return new Option[] { return new Option[] {
karafDistributionConfiguration() karafDistributionConfiguration()
...@@ -113,6 +114,7 @@ public class KarafIT { ...@@ -113,6 +114,7 @@ public class KarafIT {
mavenBundle().groupId("com.github.andrewoma.dexx").artifactId("collection").versionAsInProject(), mavenBundle().groupId("com.github.andrewoma.dexx").artifactId("collection").versionAsInProject(),
CoreOptions.systemProperty("acdc.idiomatic-bundle").value(acrepoIdiomatic), CoreOptions.systemProperty("acdc.idiomatic-bundle").value(acrepoIdiomatic),
CoreOptions.systemProperty("acdc.activemq-svc-bundle").value(acrepoBrokerSvc),
CoreOptions.systemProperty("acdc.inference-svc-bundle").value(acrepoInferenceSvc), CoreOptions.systemProperty("acdc.inference-svc-bundle").value(acrepoInferenceSvc),
CoreOptions.systemProperty("acdc.jsonld-bundle").value(acrepoJsonLd), CoreOptions.systemProperty("acdc.jsonld-bundle").value(acrepoJsonLd),
CoreOptions.systemProperty("acdc.jsonld-svc-bundle").value(acrepoJsonLdSvc), CoreOptions.systemProperty("acdc.jsonld-svc-bundle").value(acrepoJsonLdSvc),
...@@ -125,6 +127,7 @@ public class KarafIT { ...@@ -125,6 +127,7 @@ public class KarafIT {
bundle(acrepoJsonLdSvc).start(), bundle(acrepoJsonLdSvc).start(),
bundle(acrepoMintSvc).start(), bundle(acrepoMintSvc).start(),
bundle(acrepoPcdmSvc).start(), bundle(acrepoPcdmSvc).start(),
bundle(acrepoBrokerSvc).start(),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", rmiRegistryPort), editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", rmiRegistryPort),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", rmiServerPort), editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", rmiServerPort),
...@@ -144,6 +147,7 @@ public class KarafIT { ...@@ -144,6 +147,7 @@ public class KarafIT {
assertNotNull(bundleContext); assertNotNull(bundleContext);
assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("acdc.idiomatic-bundle")).getState()); assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("acdc.idiomatic-bundle")).getState());
assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("acdc.activemq-svc-bundle")).getState());
assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("acdc.inference-svc-bundle")).getState()); assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("acdc.inference-svc-bundle")).getState());
assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("acdc.jsonld-bundle")).getState()); assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("acdc.jsonld-bundle")).getState());
assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("acdc.jsonld-svc-bundle")).getState()); assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("acdc.jsonld-svc-bundle")).getState());
......
Repository ActiveMQ OSGi handling service
========================================
This OSGi service creates a connector to an ActiveMQ Broker. It may be used by other
modules in the repository service to connect up to an ActiveMQ Broker.
Building
--------
To build this project use
mvn install
Deploying in OSGi
-----------------
Each of these projects can be deployed in an OSGi container. For example using
[Apache Karaf](http://karaf.apache.org) version 4.x or better, you can run the following
command from its shell:
feature:repo-add mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
feature:install acrepo-services-activemq
Configuration
-------------
The application can be configured by creating the following configuration
file `$KARAF_HOME/etc/edu.amherst.acdc.services.activemq.cfg`. The following values
are available for configuration:
The url for connecting to the ActiveMQ broker
jms.brokerUrl=tcp://localhost:61616
If the ActiveMQ broker requires authentication, these properties will be useful:
jms.username=<username>
jms.password=<password>
Once the file is edited this service will be automatically redeployed
with the new configuration.
For more help see the [Apache Camel](http://camel.apache.org/) documentation
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>repository-services</artifactId>
<groupId>edu.amherst.acdc</groupId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<artifactId>acrepo-services-activemq</artifactId>
<packaging>bundle</packaging>
<name>Broker Service</name>
<description>An OSGi ActiveMQ-based service used to connect toolbox applications with ActiveMQ message broker</description>
<properties>
<osgi.export.packages>edu.amherst.acdc.services.activemq;version=${project.version}</osgi.export.packages>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
</dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!-- Testing & Camel Plugin -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- reserve network ports for integration testing -->
<!-- add configuration file to artifact set for OSGi deployment -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>src/main/cfg/edu.amherst.acdc.services.activemq.cfg</file>
<type>cfg</type>
<classifier>configuration</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
# The JMS connection URI, used for connecting to a local or remote ActiveMQ broker.
jms.brokerUrl=tcp://localhost:61616
# If authentication is enabled on the activemq broker, add appropriate values here
jms.username=
jms.password=
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<!-- OSGI blueprint property placeholder -->
<cm:property-placeholder id="properties" persistent-id="edu.amherst.acdc.services.activemq" update-strategy="reload">
<cm:default-properties>
<cm:property name="jms.brokerUrl" value="tcp://localhost:61616"/>
<cm:property name="jms.username" value=""/>
<cm:property name="jms.password" value=""/>
</cm:default-properties>
</cm:property-placeholder>
<!-- configuration of activemq component -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="${jms.brokerUrl}"/>
<property name="userName" value="${jms.username}"/>
<property name="password" value="${jms.password}"/>
</bean>
<service ref="broker" interface="org.apache.camel.Component">
<service-properties>
<entry key="osgi.jndi.service.name" value="acrepobroker"/>
</service-properties>
</service>
</blueprint>
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
<module>acrepo-exts-serialize-xml</module> <module>acrepo-exts-serialize-xml</module>
<module>acrepo-exts-template</module> <module>acrepo-exts-template</module>
<module>acrepo-karaf</module> <module>acrepo-karaf</module>
<module>acrepo-services-activemq</module>
<module>acrepo-services-inference</module> <module>acrepo-services-inference</module>
<module>acrepo-services-jsonld</module> <module>acrepo-services-jsonld</module>
<module>acrepo-services-ldcache</module> <module>acrepo-services-ldcache</module>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment