Configuring ActiveMQ Classic for Martini
ActiveMQ Classic is embedded within the Martini Server Runtime and is used by default for development purposes. This setup simplifies the development process by providing a ready-to-use messaging solution. However, for enhanced performance and reliability in production environments, it is strongly recommended to switch to a standalone instance of ActiveMQ. A standalone configuration offers greater scalability, improved resource management, and better overall performance, making it a more suitable choice for production-level applications.
1 |
|
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. Configuring a transport connector involves adjusting its settings to meet your specific requirements, such as security settings, protocol-specific configurations, and performance tuning.
Adding a Transport Connector
To add a transport connector:
- Open the
activemq-embedded.xml
file located at<martini-home>/conf/broker
. - Locate the
transportConnectors
property under thebroker
bean. - Modify the connector's properties according to your requirements.
- Add a new
TransportConnector
bean with the desired URI for the new transport protocol. This might include setting up SSL/TLS, adjusting client connection limits, or configuring protocol-specific options. For example, configuring an MQTT connector for better security might involve adding SSL/TLS properties to the connector's configuration. - 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 External ActiveMQ Classic Instance
ActiveMQ Classic can be connected to by the Martini Server Runtime, providing the capability to integrate with an external instance. This integration allows users to leverage the robust messaging features of ActiveMQ, facilitating efficient communication between applications. By configuring the connection settings, developers can utilize the external broker for message sending and receiving, enhancing the overall scalability and performance of their messaging workflows.
Prerequisites
Before configuring Martini Server Runtime to connect with an ActiveMQ Classic broker, ensure the following prerequisite is met:
- Apache ActiveMQ Classic: Ensure your message broker is running. You can follow guides for setup here: Standalone or Docker Container.
Connect to a remote ActiveMQ Classic instance
-
Configure Martini's connection properties in the
<martini-home>/conf/overrides/override.properties
. Configuration properties: These properties represent the bare minimum requirements needed to get started with the application.1 2 3
jms.configuration-file=activemq-external # The URL of the remote broker. activemq.uri=tcp://[HOST]:61616
Authentication properties: If you are using the default credentials, you can skip the following properties. For guidance on setting up authentication, refer to the documentation here.
1 2 3 4 5 6
# Sets the login when connecting to a remote ActiveMQ broker. # If unspecified, Martini will use 'guest' for the login. activemq.username=[username] # Sets the password when connecting to a remote ActiveMQ broker. # If unspecified, Martini will use 'guest' for the password. activemq.password=[password]
JMS properties: These settings will prevent Martini colliding with different instances with the default properties.
1 2 3 4 5 6
# The value of this property must be unique among clients connected to the ActiveMQ instance. # This is used to identify the name of the Martini instance in the ActiveMQ connections. jms.client-id=[client-id] # The prefix is added to mitigate overlapping JMS destinations and to distinguish between different Martini instances connected to a single message broker. # It adds a prefix to the beginning of a queue and topic; for example: `your-prefix.io.lonti.martini` jms.destination-prefix=your-prefix
-
Restart Martini Server Runtime to apply the changes.
- Verify connection establishment.
1 |
|
Advanced properties
These properties will optimize the performance of ActiveMQ Classic on Martini. Adjust them according to the needs of your applications.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
Master / Slave setup
For improved performance and high availability, consider configuring ActiveMQ in a master / slave setup. This configuration is particularly beneficial for Martini's performance, especially when handling search indices. For more information, refer to Introduction to Master / Slave by Apache.
1 |
|
Failover Transport setup
For improved redundancy, consider configuring ActiveMQ in a Failover setup. This setup ensures continuous operation during broker failures, failover allows for seamless reconnection without manual intervention, which simplifies the application's architecture and improves user experience. It guarantees message delivery, preventing data loss and maintaining integrity, while also enabling load balancing through broker redundancy. For more information, refer to The Failover Transport by Apache.
1 |
|
ActiveMQ Classic 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 Apache documentation for detailed configuration instructions on ActiveMQ Classic.
Testing
Refer to JMS Messaging to learn more about sending and receiving JMS messages.