Skip to content

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:

  1. Open the activemq-embedded.xml file located at <martini-home>/conf/broker/activemq-embedded.xml.
  2. Locate the transportConnectors property under the broker bean.
  3. Add a new TransportConnector bean with the desired URI for the new transport protocol.
  4. Save the file and restart Martini Server Runtime to apply the changes.

Editing a Transport Connector

To edit a transport connector:

  1. Modify the existing TransportConnector bean elements in the activemq-embedded.xml file.
  2. Save the changes and restart Martini Server Runtime to reflect the updates.

Removing a Transport Connector

To remove a transport connector:

  1. Comment out or remove the corresponding TransportConnector bean element from the activemq-embedded.xml file.
  2. 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:

  1. Ensure ActiveMQ is installed and deployed.
  2. Configure Martini's connection properties in the <martini-home>/data/override.properties.

     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
    
    3. Restart Martini Server Runtime to apply the changes. 4. Verify connection establishment and message transmission.

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

  1. Navigate to ActiveMQ's configuration directory:
1
cd $activemq_home/conf
  1. Modify the activemq.xml file to include the runtimeConfigurationPlugin and jaasAuthenticationPlugin:
1
2
3
4
 <plugins>
     <runtimeConfigurationPlugin checkPeriod="1000" />
     <jaasAuthenticationPlugin configuration="activemq-domain" />
 </plugins>

Place this configuration below the <managementContext> section. Save and close the file.

  1. Define the JAAS realm in the login.config file to manage users and groups.

  2. Create and populate the required Java property files (users.properties and groups.properties) to specify users, passwords, and group memberships using the format:

1
username=password
1
 groupname=user_one,user_two,...
  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
<plugins>
    <!-- ... -->
    <authorizationPlugin>
    <map>
        <authorizationMap>
            <authorizationEntries>
                <authorizationEntry topic="jmsPrefix.statistics.>" read="$yourGroup" write="$yourGroup" admin="$yourGroup" />
                <authorizationEntry topic="jmsPrefix.io.toro.martini.>" read="$yourGroup" write="$yourGroup" admin="$yourGroup" />
                <authorizationEntry queue="jmsPrefix.io.toro.martini.>" read="$yourGroup" write="$yourGroup" admin="$yourGroup" />
                <authorizationEntry topic="ActiveMQ.Advisory.>" read="$yourGroup" write="$yourGroup" admin="$yourGroup" />
            </authorizationEntries>
        </authorizationMap>
    </map>
    </authorizationPlugin>
</plugins>
  1. 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.

  1. Navigate to Martini Server Runtime's conf/properties directory:
1
cd <martini-home>/conf/properties
  1. Edit the override.properties file:
1
2
3
4
5
6
7
activemq.username=admin
activemq.password=admin

jms.configuration-file=activemq-external
jms.client-id=martini
activemq.uri=tcp://<activemq-ip-address>:61616?closeAsync=true
jms.destination-prefix=your-prefix
  1. 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
```properties
activemq.uri=failover:tcp://<activemq1-ip-address>:61616,tcp://<activemq2-ip-address>:61616?CloseAsync=false
```

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.