From d891e47774426e06b92c612fbc58bd098ef8f009 Mon Sep 17 00:00:00 2001 From: Dejan Bosanac Date: Fri, 27 May 2016 13:51:21 +0200 Subject: [PATCH] ARTEMIS-537 - final improvements to OSGi integration and documentation update --- .../src/main/resources/features.xml | 14 +++---- .../activemq/artemis/osgi/OsgiBroker.java | 3 +- docs/user-manual/en/karaf.md | 41 ++++++++++++++++++- .../integration/karaf/ArtemisFeatureTest.java | 29 ++++++++----- 4 files changed, 66 insertions(+), 21 deletions(-) diff --git a/artemis-features/src/main/resources/features.xml b/artemis-features/src/main/resources/features.xml index 0a88f80590..c6cd831ab8 100644 --- a/artemis-features/src/main/resources/features.xml +++ b/artemis-features/src/main/resources/features.xml @@ -19,7 +19,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0"> - + artemis-core artemis-amqp artemis-stomp @@ -27,7 +27,7 @@ artemis-hornetq - + mvn:io.netty/netty-common/${netty.version} mvn:io.netty/netty-transport/${netty.version} mvn:io.netty/netty-buffer/${netty.version} @@ -35,7 +35,7 @@ mvn:io.netty/netty-handler/${netty.version} - + transaction netty-core scr @@ -55,7 +55,7 @@ mvn:org.apache.activemq/artemis-server-osgi/${pom.version} - + wrap artemis-core wrap:mvn:org.apache.qpid/proton-j/${proton.version} @@ -64,17 +64,17 @@ mvn:org.apache.activemq/artemis-amqp-protocol/${pom.version} - + artemis-core mvn:org.apache.activemq/artemis-stomp-protocol/${pom.version} - + artemis-core mvn:org.apache.activemq/artemis-mqtt-protocol/${pom.version} - + artemis-core mvn:org.apache.activemq/artemis-hqclient-protocol/${pom.version} mvn:org.apache.activemq/artemis-hornetq-protocol/${pom.version} diff --git a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java index bfdc73eaa6..d491b170b5 100644 --- a/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java +++ b/artemis-server-osgi/src/main/java/org/apache/activemq/artemis/osgi/OsgiBroker.java @@ -42,11 +42,12 @@ import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; import org.osgi.service.component.annotations.Deactivate; import org.osgi.util.tracker.ServiceTracker; @SuppressWarnings({"unchecked", "rawtypes"}) -@Component(configurationPid = "org.apache.activemq.artemis") +@Component(configurationPid = "org.apache.activemq.artemis", configurationPolicy = ConfigurationPolicy.REQUIRE) public class OsgiBroker { private String name; private String configurationUrl; diff --git a/docs/user-manual/en/karaf.md b/docs/user-manual/en/karaf.md index 2b6e8a62a2..4756b9b6dc 100644 --- a/docs/user-manual/en/karaf.md +++ b/docs/user-manual/en/karaf.md @@ -1,7 +1,44 @@ # Artemis on Apache Karaf -Apache ActiveMQ Artemis can be installed on Apache Karaf (4.x or later) using the following commands from the Karaf shell: +Apache ActiveMQ Artemis is OSGi ready. Below you can find instruction on how to install and configure broker on Apache Karaf OSGi container. - feature:repo-add mvn:org.apache.activemq/artemis-features/1.3.0-SNAPSHOT/xml/features +## Installation + +Apache ActiveMQ Artemis provides features that makes it easy to install the broker on Apache Karaf (4.x or later). First you need to define the feature URL, like + + karaf@root()> feature:repo-add mvn:org.apache.activemq/artemis-features/1.3.0-SNAPSHOT/xml/features + +This will add Artemis related features + + karaf@root()> feature:list | grep artemis + artemis | 1.3.0.SNAPSHOT | | Uninstalled | artemis-1.3.0-SNAPSHOT | Full ActiveMQ Artemis broker with default configuration + netty-core | 4.0.32.Final | | Uninstalled | artemis-1.3.0-SNAPSHOT | Netty libraries + artemis-core | 1.3.0.SNAPSHOT | | Uninstalled | artemis-1.3.0-SNAPSHOT | ActiveMQ Artemis broker libraries + artemis-amqp | 1.3.0.SNAPSHOT | | Uninstalled | artemis-1.3.0-SNAPSHOT | ActiveMQ Artemis AMQP protocol libraries + artemis-stomp | 1.3.0.SNAPSHOT | | Uninstalled | artemis-1.3.0-SNAPSHOT | ActiveMQ Artemis Stomp protocol libraries + artemis-mqtt | 1.3.0.SNAPSHOT | | Uninstalled | artemis-1.3.0-SNAPSHOT | ActiveMQ Artemis MQTT protocol libraries + artemis-hornetq | 1.3.0.SNAPSHOT | | Uninstalled | artemis-1.3.0-SNAPSHOT | ActiveMQ Artemis HornetQ protocol libraries + +Feature named `artemis` contains full broker installation, so running + feature:install artemis +will install and run the broker. + +## Configuration + +The broker is installed as `org.apache.activemq.artemis` OSGi component, so it's configured through `${KARAF_BASE}/etc/org.apache.activemq.artemis.cfg` file. An example of the file looks like + + config=file:etc/artemis.xml + name=local + domain=karaf + rolePrincipalClass=org.apache.karaf.jaas.boot.principal.RolePrincipal + +| Name | Description | Default value | +| ------------------ | ----------------------------------------------- | -------------------------------------------------- | +| config | Location of the configuration file | ${KARAF_BASE}/etc/artemis.xml | +| name | Name of the broker | local | +| domain | JAAS domain to use for security | karaf | +| rolePrincipalClass | Class name used for role authorization purposes | org.apache.karaf.jaas.boot.principal.RolePrincipal | + +The default broker configuration file is located in `${KARAF_BASE}/etc/artemis.xml` \ No newline at end of file diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java index b2161101f7..134dd9a702 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java @@ -140,19 +140,26 @@ public class ArtemisFeatureTest extends Assert { executeCommand("service:list -n"); - String amqpURI = "amqp://localhost:5672"; - JmsConnectionFactory factory = new JmsConnectionFactory(amqpURI); - Connection connection = factory.createConnection(USER, PASSWORD); - connection.start(); + Connection connection = null; + try { + JmsConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:5672"); + connection = factory.createConnection(USER, PASSWORD); + connection.start(); - javax.jms.Session sess = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); - Queue queue = sess.createQueue("jms.queue.exampleQueue"); - MessageProducer producer = sess.createProducer(queue); - producer.send(sess.createTextMessage("TEST")); + javax.jms.Session sess = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); + Queue queue = sess.createQueue("jms.queue.exampleQueue"); + MessageProducer producer = sess.createProducer(queue); + producer.send(sess.createTextMessage("TEST")); - MessageConsumer consumer = sess.createConsumer(queue); - Message msg = consumer.receive(5000); - assertNotNull(msg); + MessageConsumer consumer = sess.createConsumer(queue); + Message msg = consumer.receive(5000); + assertNotNull(msg); + } + finally { + if (connection != null) { + connection.close(); + } + } } protected String executeCommand(final String command, final Long timeout, final Boolean silent) {