ActiveMQ as the Martini Server Runtime Instance Message Broker
Apache ActiveMQ serves as the default messaging broker for Martini Server Runtime, facilitating message exchange between applications or microservices.
ActiveMQ acts as a middleware, managing asynchronous message exchange between distributed applications. As the default messaging broker for Martini Server Runtime, it ensures reliable message delivery and facilitates communication between components.
Transport Connectors
Transport connectors define communication protocols for clients to connect to the ActiveMQ broker. Martini supports various transport protocols, including TCP, VM, AMQP, MQTT, and STOMP. You can configure additional transport connectors to suit your requirements.
Adding a Transport Connector
To add a transport connector:
- Open the
activemq-embedded.xml
file located at<martini-home>/conf/broker/activemq-embedded.xml
. - Locate the
transportConnectors
property under thebroker
bean. - Add a new
TransportConnector
bean with the desired URI for the new transport protocol. - Save the file and restart Martini Server Runtime to apply the changes.
Editing a Transport Connector
To edit a transport connector:
- Modify the existing
TransportConnector
bean elements in theactivemq-embedded.xml
file. - Save the changes and restart Martini Server Runtime to reflect the updates.
Removing a Transport Connector
To remove a transport connector:
- Comment out or remove the corresponding
TransportConnector
bean element from theactivemq-embedded.xml
file. - Save the file and restart Martini Server Runtime as needed.
Using a Remote ActiveMQ Instance
For improved performance in production environments, consider using a standalone instance of ActiveMQ instead of the embedded version. Follow these steps to configure Martini to connect to a remote ActiveMQ instance:
- Ensure ActiveMQ is installed and deployed.
-
Configure Martini's connection properties in the
<martini-home>/data/override.properties
.3. Restart Martini Server Runtime to apply the changes. 4. Verify connection establishment and message transmission.1 2 3 4 5 6 7 8 9 10 11
jms.configuration-file=activemq-external # This property must be set if you require durable subscribers on topics. # The value of this property must be unique among clients connected to the ActiveMQ instance. jms.client-id=martini # The prefix is added to mitigate overlapping JMS destinations. jms.destination-prefix=your-prefix # The URL of the remote broker. activemq.uri=tcp://<activemq-ip-address>:61616?closeAsync=false
Authentication and Authorization
To ensure secure access to the message broker and its destinations, it's crucial to implement robust authentication and authorization mechanisms. ActiveMQ offers customizable security models, simplifying integration with existing security policies.
ActiveMQ supports pluggable security through various providers, including the JAAS and simple authentication plugins. The simple authentication plugin is straightforward and meets basic authentication needs, while the JAAS plugin enables user and group management without direct modifications to the broker.xml
file.
Configuring the ActiveMQ server
- Navigate to ActiveMQ's configuration directory:
1 |
|
- Modify the
activemq.xml
file to include theruntimeConfigurationPlugin
andjaasAuthenticationPlugin
:
1 2 3 4 |
|
Place this configuration below the <managementContext>
section. Save and close the file.
-
Define the JAAS realm in the
login.config
file to manage users and groups. -
Create and populate the required Java property files (
users.properties
andgroups.properties
) to specify users, passwords, and group memberships using the format:
1 |
|
1 |
|
- Configure the
authorizationPlugin
to define access privileges for groups on specific destinations (queues or topics) using<authorizationEntry />
elements.
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
- Restart ActiveMQ to apply the new security configurations.
Configuring Martini
To connect Martini to the remote ActiveMQ instance with updated security policies, edit the override.properties file.
- Navigate to Martini Server Runtime's
conf/properties
directory:
1 |
|
- Edit the
override.properties
file:
1 2 3 4 5 6 7 |
|
- Restart Martini to apply the changes.
ActiveMQ in a master-slave setup
For improved performance and high availability, consider configuring ActiveMQ in a master-slave setup. This setup is beneficial for Martini's performance, especially when dealing with search indices.
Procedure
Configuring the NFS server & NFS clients
Follow the provided guide to set up an NFS mount on Linux. It is recommended to create and share the /datastore/activemq-data
directory, but it is also possible to choose a different directory.
Configuring Martini
Edit the activemq.uri
property in Martini Server Runtime's configuration file to include the URLs of both ActiveMQ instances.
1 2 3 |
|
ActiveMQ configuration
Configure ActiveMQ instances via XML for advanced options and flexibility. Key configurations include:
broker
bean element- Destination policies
- Management context
- KahaDB directory
- Transport connectors (e.g.,
openwire
for fail-over)
Refer to ActiveMQ documentation for detailed configuration instructions.