ARTEMIS-537 - final improvements to OSGi integration and documentation update
This commit is contained in:
parent
fdaf9b22f5
commit
d891e47774
|
@ -19,7 +19,7 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
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-core</feature>
|
||||||
<feature>artemis-amqp</feature>
|
<feature>artemis-amqp</feature>
|
||||||
<feature>artemis-stomp</feature>
|
<feature>artemis-stomp</feature>
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
<feature>artemis-hornetq</feature>
|
<feature>artemis-hornetq</feature>
|
||||||
</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-common/${netty.version}</bundle>
|
||||||
<bundle>mvn:io.netty/netty-transport/${netty.version}</bundle>
|
<bundle>mvn:io.netty/netty-transport/${netty.version}</bundle>
|
||||||
<bundle>mvn:io.netty/netty-buffer/${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>
|
<bundle>mvn:io.netty/netty-handler/${netty.version}</bundle>
|
||||||
</feature>
|
</feature>
|
||||||
|
|
||||||
<feature name="artemis-core" version="${pom.version}">
|
<feature name="artemis-core" version="${pom.version}" description="ActiveMQ Artemis broker libraries">
|
||||||
<feature>transaction</feature>
|
<feature>transaction</feature>
|
||||||
<feature>netty-core</feature>
|
<feature>netty-core</feature>
|
||||||
<feature>scr</feature>
|
<feature>scr</feature>
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
<bundle>mvn:org.apache.activemq/artemis-server-osgi/${pom.version}</bundle>
|
<bundle>mvn:org.apache.activemq/artemis-server-osgi/${pom.version}</bundle>
|
||||||
</feature>
|
</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 prerequisite="true">wrap</feature>
|
||||||
<feature>artemis-core</feature>
|
<feature>artemis-core</feature>
|
||||||
<bundle>wrap:mvn:org.apache.qpid/proton-j/${proton.version}</bundle>
|
<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>
|
<bundle>mvn:org.apache.activemq/artemis-amqp-protocol/${pom.version}</bundle>
|
||||||
</feature>
|
</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>
|
<feature>artemis-core</feature>
|
||||||
<bundle>mvn:org.apache.activemq/artemis-stomp-protocol/${pom.version}</bundle>
|
<bundle>mvn:org.apache.activemq/artemis-stomp-protocol/${pom.version}</bundle>
|
||||||
</feature>
|
</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>
|
<feature>artemis-core</feature>
|
||||||
<bundle>mvn:org.apache.activemq/artemis-mqtt-protocol/${pom.version}</bundle>
|
<bundle>mvn:org.apache.activemq/artemis-mqtt-protocol/${pom.version}</bundle>
|
||||||
</feature>
|
</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>
|
<feature>artemis-core</feature>
|
||||||
<bundle>mvn:org.apache.activemq/artemis-hqclient-protocol/${pom.version}</bundle>
|
<bundle>mvn:org.apache.activemq/artemis-hqclient-protocol/${pom.version}</bundle>
|
||||||
<bundle>mvn:org.apache.activemq/artemis-hornetq-protocol/${pom.version}</bundle>
|
<bundle>mvn:org.apache.activemq/artemis-hornetq-protocol/${pom.version}</bundle>
|
||||||
|
|
|
@ -42,11 +42,12 @@ import org.osgi.framework.ServiceRegistration;
|
||||||
import org.osgi.service.component.ComponentContext;
|
import org.osgi.service.component.ComponentContext;
|
||||||
import org.osgi.service.component.annotations.Activate;
|
import org.osgi.service.component.annotations.Activate;
|
||||||
import org.osgi.service.component.annotations.Component;
|
import org.osgi.service.component.annotations.Component;
|
||||||
|
import org.osgi.service.component.annotations.ConfigurationPolicy;
|
||||||
import org.osgi.service.component.annotations.Deactivate;
|
import org.osgi.service.component.annotations.Deactivate;
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
import org.osgi.util.tracker.ServiceTracker;
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
@Component(configurationPid = "org.apache.activemq.artemis")
|
@Component(configurationPid = "org.apache.activemq.artemis", configurationPolicy = ConfigurationPolicy.REQUIRE)
|
||||||
public class OsgiBroker {
|
public class OsgiBroker {
|
||||||
private String name;
|
private String name;
|
||||||
private String configurationUrl;
|
private String configurationUrl;
|
||||||
|
|
|
@ -1,7 +1,44 @@
|
||||||
# Artemis on Apache Karaf
|
# 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
|
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`
|
|
@ -140,19 +140,26 @@ public class ArtemisFeatureTest extends Assert {
|
||||||
|
|
||||||
executeCommand("service:list -n");
|
executeCommand("service:list -n");
|
||||||
|
|
||||||
String amqpURI = "amqp://localhost:5672";
|
Connection connection = null;
|
||||||
JmsConnectionFactory factory = new JmsConnectionFactory(amqpURI);
|
try {
|
||||||
Connection connection = factory.createConnection(USER, PASSWORD);
|
JmsConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:5672");
|
||||||
connection.start();
|
connection = factory.createConnection(USER, PASSWORD);
|
||||||
|
connection.start();
|
||||||
|
|
||||||
javax.jms.Session sess = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
|
javax.jms.Session sess = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
|
||||||
Queue queue = sess.createQueue("jms.queue.exampleQueue");
|
Queue queue = sess.createQueue("jms.queue.exampleQueue");
|
||||||
MessageProducer producer = sess.createProducer(queue);
|
MessageProducer producer = sess.createProducer(queue);
|
||||||
producer.send(sess.createTextMessage("TEST"));
|
producer.send(sess.createTextMessage("TEST"));
|
||||||
|
|
||||||
MessageConsumer consumer = sess.createConsumer(queue);
|
MessageConsumer consumer = sess.createConsumer(queue);
|
||||||
Message msg = consumer.receive(5000);
|
Message msg = consumer.receive(5000);
|
||||||
assertNotNull(msg);
|
assertNotNull(msg);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (connection != null) {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String executeCommand(final String command, final Long timeout, final Boolean silent) {
|
protected String executeCommand(final String command, final Long timeout, final Boolean silent) {
|
||||||
|
|
Loading…
Reference in New Issue