ARTEMIS-537 - final improvements to OSGi integration and documentation update

This commit is contained in:
Dejan Bosanac 2016-05-27 13:51:21 +02:00
parent fdaf9b22f5
commit d891e47774
4 changed files with 66 additions and 21 deletions

View File

@ -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">
<feature name="artemis" version="${pom.version}">
<feature name="artemis" version="${pom.version}" description="Full ActiveMQ Artemis broker with default configuration">
<feature>artemis-core</feature>
<feature>artemis-amqp</feature>
<feature>artemis-stomp</feature>
@ -27,7 +27,7 @@
<feature>artemis-hornetq</feature>
</feature>
<feature name="netty-core" version="${netty.version}">
<feature name="netty-core" version="${netty.version}" description="Netty libraries">
<bundle>mvn:io.netty/netty-common/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-transport/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-buffer/${netty.version}</bundle>
@ -35,7 +35,7 @@
<bundle>mvn:io.netty/netty-handler/${netty.version}</bundle>
</feature>
<feature name="artemis-core" version="${pom.version}">
<feature name="artemis-core" version="${pom.version}" description="ActiveMQ Artemis broker libraries">
<feature>transaction</feature>
<feature>netty-core</feature>
<feature>scr</feature>
@ -55,7 +55,7 @@
<bundle>mvn:org.apache.activemq/artemis-server-osgi/${pom.version}</bundle>
</feature>
<feature name="artemis-amqp" version="${pom.version}">
<feature name="artemis-amqp" version="${pom.version}" description="ActiveMQ Artemis AMQP protocol libraries">
<feature prerequisite="true">wrap</feature>
<feature>artemis-core</feature>
<bundle>wrap:mvn:org.apache.qpid/proton-j/${proton.version}</bundle>
@ -64,17 +64,17 @@
<bundle>mvn:org.apache.activemq/artemis-amqp-protocol/${pom.version}</bundle>
</feature>
<feature name="artemis-stomp" version="${pom.version}">
<feature name="artemis-stomp" version="${pom.version}" description="ActiveMQ Artemis Stomp protocol libraries">
<feature>artemis-core</feature>
<bundle>mvn:org.apache.activemq/artemis-stomp-protocol/${pom.version}</bundle>
</feature>
<feature name="artemis-mqtt" version="${pom.version}">
<feature name="artemis-mqtt" version="${pom.version}" description="ActiveMQ Artemis MQTT protocol libraries">
<feature>artemis-core</feature>
<bundle>mvn:org.apache.activemq/artemis-mqtt-protocol/${pom.version}</bundle>
</feature>
<feature name="artemis-hornetq" version="${pom.version}">
<feature name="artemis-hornetq" version="${pom.version}" description="ActiveMQ Artemis HornetQ protocol libraries">
<feature>artemis-core</feature>
<bundle>mvn:org.apache.activemq/artemis-hqclient-protocol/${pom.version}</bundle>
<bundle>mvn:org.apache.activemq/artemis-hornetq-protocol/${pom.version}</bundle>

View File

@ -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;

View File

@ -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`

View File

@ -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) {