Apache ActiveMQ Artemis 已準備好支援 OSGi。以下您將找到如何在 Apache Karaf OSGi 容器上安裝和設定訊息代理的說明。

1. 安裝

Apache ActiveMQ Artemis 提供使訊息代理易於安裝在 Apache Karaf (4.x 或更高版本) 上的功能。首先,您需要定義 feature URL,例如:

karaf@root()> feature:repo-add mvn:org.apache.activemq/artemis-features/1.3.0-SNAPSHOT/xml/features

這將新增與 Artemis 相關的功能

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

名為 artemis 的功能包含完整的訊息代理安裝,因此執行

feature:install artemis

將會安裝並執行訊息代理。

2. 設定

訊息代理以 org.apache.activemq.artemis OSGi 元件安裝,因此它是透過 ${KARAF_BASE}/etc/org.apache.activemq.artemis.cfg 檔案進行設定。檔案範例如下:

config=file:etc/artemis.xml
name=local
domain=karaf
rolePrincipalClass=org.apache.karaf.jaas.boot.principal.RolePrincipal
名稱 描述 預設值

config

設定檔的位置

${KARAF_BASE}/etc/artemis.xml

name

訊息代理的名稱

local

domain

用於安全性的 JAAS 網域

karaf

rolePrincipalClass

用於角色授權目的的類別名稱

org.apache.karaf.jaas.boot.principal.RolePrincipal

預設訊息代理設定檔位於 ${KARAF_BASE}/etc/artemis.xml