Commit 2574e38d authored by bseeger's avatar bseeger
Browse files

Merge branch 'use_fcrepo_broker' into 'master'

Remove our own activemq broker connector

Resolves: #26

See merge request !83
parents d6b437df a9b412e1
......@@ -26,7 +26,6 @@ Services
These modules provide particular services, independent of Fedora Resources.
* [`acrepo-services-activemq`](acrepo-services-activemq): This service creates a ActiveMQ connection for other modules to use
* [`acrepo-services-inference`](acrepo-services-inference): An OSGi-based structural typing service using owl inference
* [`acrepo-services-jsonld`](acrepo-services-jsonld): This service creates expanded or compact JSON-LD representations of input documents
* [`acrepo-services-mint`](acrepo-services-mint): This mints random (public) URIs for use with Fedora resources
......@@ -37,7 +36,7 @@ Connectors
These modules listen to repository events and react accordingly.
* [`acrepo-connector-broadcast`](acrepo-connector-broadcast): ActiveMQ Message Broadcast Service: This rebroadcasts messages from one queue/topic to every queue/topic in a specified list
* [`acrepo-connector-broadcast`](acrepo-connector-broadcast): Message Broadcast Service: This rebroadcasts messages from one queue/topic to every queue/topic in a specified list
* [`acrepo-connector-idiomatic`](acrepo-connector-idiomatic): Id Mapping Service: This maps a public ID to a (internal and typically much longer) Fedora URI
* [`acrepo-connector-idiomatic-mysql`](acrepo-connector-idiomatic-mysql): Id Mapping Service Database: This exposes a MySQL datastore for use with the Id Mapping service
* [`acrepo-connector-idiomatic-pgsql`](acrepo-connector-idiomatic-pgsql): Id Mapping Service Database: This exposes a Postgres datastore for use with the Id Mapping service
......
......@@ -14,7 +14,7 @@
</cm:default-properties>
</cm:property-placeholder>
<reference id="broker" interface="org.apache.camel.Component" filter="(osgi.jndi.service.name=acrepo/Broker)"/>
<reference id="broker" interface="org.apache.camel.Component" filter="(osgi.jndi.service.name=fcrepo/Broker)"/>
<camelContext id="AcrepoConnectorBroadcast" xmlns="http://camel.apache.org/schema/blueprint">
<package>edu.amherst.acdc.connector.broadcast</package>
......
......@@ -24,7 +24,7 @@
<reference id="minterService" interface="java.util.function.Supplier" filter="(osgi.jndi.service.name=acrepo/Minter)"/>
<reference id="broker" interface="org.apache.camel.Component" filter="(osgi.jndi.service.name=acrepo/Broker)"/>
<reference id="broker" interface="org.apache.camel.Component" filter="(osgi.jndi.service.name=fcrepo/Broker)"/>
<!-- component-wide configuration of jdbc -->
<bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
......
......@@ -88,7 +88,7 @@ public class RouteTest extends CamelBlueprintTestSupport {
services.put(Supplier.class.getName(),
asService(new MinterService(MINT_LENGTH), "osgi.jndi.service.name", "acrepo/Minter"));
services.put(Component.class.getName(),
asService(new SedaComponent(), "osgi.jndi.service.name", "acrepo/Broker"));
asService(new SedaComponent(), "osgi.jndi.service.name", "fcrepo/Broker"));
}
@Test
......
......@@ -48,7 +48,6 @@ dependencies {
testCompile project(':acrepo-connector-broadcast')
testCompile project(':acrepo-connector-idiomatic')
testCompile project(':acrepo-connector-idiomatic-pgsql')
testCompile project(':acrepo-services-activemq')
testCompile project(':acrepo-services-inference')
testCompile project(':acrepo-services-jsonld')
testCompile project(':acrepo-services-mint')
......
/*
* 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.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")
.version(cm.getProperty("karaf.version")).type("zip"))
.unpackDirectory(new File("build", "exam"))
.useDeployFolder(false),
logLevel(LogLevel.INFO),
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()),
features(maven().groupId("org.apache.camel.karaf").artifactId("apache-camel")
.type("xml").classifier("features").versionAsInProject()),
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")));
}
}
......@@ -86,9 +86,11 @@ public class AcrepoBroadcastIT extends AbstractOSGiIT {
.type("xml").classifier("features").versionAsInProject()),
features(maven().groupId("org.apache.camel.karaf").artifactId("apache-camel")
.type("xml").classifier("features").versionAsInProject()),
features(maven().groupId("org.fcrepo.camel").artifactId("toolbox-features")
.type("xml").classifier("features").versionAsInProject(), "fcrepo-service-activemq"),
features(maven().groupId("edu.amherst.acdc").artifactId("acrepo-karaf")
.type("xml").classifier("features").versionAsInProject(),
"acrepo-services-activemq", "acrepo-connector-broadcast"),
"acrepo-connector-broadcast"),
mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpclient-osgi").versionAsInProject(),
mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpcore-osgi").versionAsInProject(),
......@@ -98,7 +100,7 @@ public class AcrepoBroadcastIT extends AbstractOSGiIT {
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),
editConfigurationFilePut("etc/org.fcrepo.camel.service.activemq.cfg", "jms.brokerUrl", brokerUrl),
editConfigurationFilePut("etc/edu.amherst.acdc.connector.broadcast.cfg", "input.stream", inputStream),
editConfigurationFilePut("etc/edu.amherst.acdc.connector.broadcast.cfg", "message.recipients",
messageRecipients)
......@@ -123,7 +125,7 @@ public class AcrepoBroadcastIT extends AbstractOSGiIT {
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")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("fcrepo-service-activemq")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-connector-broadcast")));
}
......
......@@ -83,7 +83,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
features(maven().groupId("org.fcrepo.camel").artifactId("fcrepo-camel")
.type("xml").classifier("features").versionAsInProject()),
features(maven().groupId("org.fcrepo.camel").artifactId("toolbox-features")
.type("xml").classifier("features").versionAsInProject()),
.type("xml").classifier("features").versionAsInProject(), "fcrepo-service-activemq"),
features(maven().groupId("edu.amherst.acdc").artifactId("acrepo-karaf")
.type("xml").classifier("features").versionAsInProject(),
"acrepo-connector-broadcast",
......@@ -100,7 +100,6 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
"acrepo-libs-jsonld",
"acrepo-libs-jackson",
"acrepo-services-activemq",
"acrepo-services-inference",
"acrepo-services-jsonld",
"acrepo-services-mint",
......@@ -123,6 +122,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
public void testInstallation() throws Exception {
assertTrue(featuresService.isInstalled(featuresService.getFeature("camel-core")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("fcrepo-camel")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("fcrepo-service-activemq")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-connector-broadcast")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-fits")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-exts-image")));
......@@ -134,7 +134,6 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-jackson")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-jena")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-jsonld")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-activemq")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-inference")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-jsonld")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-mint")));
......
......@@ -86,19 +86,6 @@
<configfile finalname="/etc/edu.amherst.acdc.exts.pcdm.cfg">mvn:edu.amherst.acdc/acrepo-exts-pcdm/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-services-activemq" version="${project.version}">
<details>Installs the ActiveMQ service</details>
<feature version="${camelVersionRange}">camel</feature>
<feature version="${camelVersionRange}">camel-blueprint</feature>
<feature version="${camelVersionRange}">camel-jms</feature>
<feature version="${activemqVersionRange}">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-mint" version="${project.version}">
<details>Installs the id minter</details>
......
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
gradle 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
apply plugin: 'osgi'
description = 'Broker Service'
dependencies {
compile group: 'org.apache.camel', name: 'camel-core', version: camelVersion
compile group: 'org.apache.camel', name: 'camel-blueprint', version: camelVersion
compile group: 'org.apache.activemq', name: 'activemq-camel', version: activemqVersion
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
testCompile group: 'junit', name: 'junit', version: junitVersion
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: logbackVersion
}
task buildMainClasses {
ext.destDir = file('build/classes/main')
outputs.dir destDir
doLast {
destDir.mkdirs()
}
}
jar {
dependsOn buildMainClasses
manifest {
description project.description
docURL project.docURL
vendor project.vendor
license project.license
instruction 'Import-Package', "org.apache.camel,org.apache.activemq,org.apache.activemq.camel.component,org.apache.activemq.pool,org.apache.camel.component.jms,${defaultOsgiImports}"
instruction 'Export-Package', "edu.amherst.acdc.services.activemq;version=${projectOsgiVersion}"
}
}
artifacts {
archives (file('build/cfg/main/edu.amherst.acdc.services.activemq.cfg')) {
classifier 'configuration'
type 'cfg'
}
}
# 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=""/>
<!-- before overriding these values, reading these articles is advised:
http://blog.christianposta.com/lesson-learned/lessons-learned-activemq-apache-camel-and-connection-pooling/
http://camel.apache.org/activemq.html#ActiveMQ-Usingconnectionpooling
In particular, the jms.consumers value should only be > 1 if the camel routes are all reading from queues.
-->
<cm:property name="jms.connections" value="10"/>
<cm:property name="jms.consumers" value="1"/>
</cm:default-properties>
</cm:property-placeholder>
<!-- configuration of activemq component -->
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${jms.brokerUrl}"/>
<property name="userName" value="${jms.username}"/>
<property name="password" value="${jms.password}"/>
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
init-method="start" destroy-method="stop">
<property name="maxConnections" value="${jms.connections}"/>
<property name="connectionFactory" ref="connectionFactory"/>
<property name="reconnectOnException" value="true"/>
</bean>
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="concurrentConsumers" value="${jms.consumers}"/>
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
</bean>
<service ref="activemq" interface="org.apache.camel.Component">
<service-properties>
<entry key="osgi.jndi.service.name" value="acrepo/Broker"/>
</service-properties>
</service>
</blueprint>
......@@ -11,7 +11,6 @@ include ':acrepo-exts-pcdm'
include ':acrepo-exts-serialize-xml'
include ':acrepo-exts-template'
include ':acrepo-karaf'
include ':acrepo-services-activemq'
include ':acrepo-services-inference'
include ':acrepo-services-jsonld'
include ':acrepo-services-mint'
......@@ -30,7 +29,6 @@ project(':acrepo-exts-pcdm').projectDir = "$rootDir/acrepo-exts-pcdm" as File
project(':acrepo-exts-serialize-xml').projectDir = "$rootDir/acrepo-exts-serialize-xml" as File
project(':acrepo-exts-template').projectDir = "$rootDir/acrepo-exts-template" as File
project(':acrepo-karaf').projectDir = "$rootDir/acrepo-karaf" as File
project(':acrepo-services-activemq').projectDir = "$rootDir/acrepo-services-activemq" as File
project(':acrepo-services-inference').projectDir = "$rootDir/acrepo-services-inference" as File
project(':acrepo-services-jsonld').projectDir = "$rootDir/acrepo-services-jsonld" as File
project(':acrepo-services-mint').projectDir = "$rootDir/acrepo-services-mint" as File
......
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