This page explains how to configure Apache ActiveMQ connection settings.

The picture below shows the ActiveMQ settings:


The fields used for ActiveMQ configuration are shown in the table below.

Field

Description

EnabledIndicates the active state of the setting.
NameThe name of the setting to be made.
DescriptionDescription can be entered.
ActiveMQ Connection Protocol TypeIt is used to select whether to connect to ActiveMQ with the AMQP protocol or the TCP protocol.
Broker UrlThe target connection URL where ActiveMQ is installed.
UsernameIt is the username information required to connect to ActiveMQ.
PasswordIt is the password information required to connect to ActiveMQ.
Destination TypeUsed to select whether the target is a Queue or Topic.
Destination NameIf Target is Queue this is the queue name, else it is the topic name.
Session AcknowledgementSpecifies how Session Confirmation should be done.
Client IDIt is used to set the JMS clientId value in connections.
Send TimeoutIt is used to set the send timeout value.
Request Timeout

If protocol type is AMQP, It is used to set the request timeout value.

Otherwise, "requestTimeout" parameter value must be added to Broker URL

Close TimeoutIt is used to control how long a Connection close will wait for clean shutdown of the connection before giving up.  A negative value means wait forever.
Connect Timeout

If protocol type is AMQP, this value is used to control how long a client will wait for a successful connection to the remote peer to be established before considering the attempt to have failed. 

Otherwise, "connectTimeout" parameter value must be added to Broker URL

Content TypeIt is used to set the contentType value of the data to be sent.
Content EncodingIt is used to set the contentEncoding value of the data to be sent.

Broker URL Examples

AMQP URL Examples

ScenarioURL ExampleDescription
Simple Connectionamqp://localhost:5672Basic AMQP connection
With Authenticationamqp://user:password@localhost:5672Connection with username and password
SSL/TLSamqps://secure-broker.example.com:5671Secure AMQP connection
Multiple Brokersamqp://broker1:5672,amqp://broker2:5672Connection to multiple brokers
With Timeoutsamqp://localhost:5672?transport.connectTimeout=30000&transport.requestTimeout=30000Connection with timeout settings
SSL with Failoveramqps://broker:5671?transport.trustStoreLocation=/path/truststore.jks&failover.maxReconnectAttempts=5SSL and reconnection configured
With Prefetchamqp://broker:5672?jms.prefetchPolicy.all=1000Connection with message prefetch
Many Featuresamqp://broker:5672?jms.prefetchPolicy.all=1000&amqp.idleTimeout=30000&transport.connectTimeout=30000Many features configured

TCP URL Examples

ScenarioURL ExampleDescription
Simple Connectiontcp://localhost:61616Basic TCP connection
With Authenticationtcp://user:password@localhost:61616Connection with username and password
With Timeoutstcp://localhost:61616?soTimeout=30000&soWriteTimeout=30000Connection with timeout settings
Basic Failoverfailover:(tcp://broker1:61616,tcp://broker2:61616)Basic failover configuration
With SSLssl://secure-broker:61617?needClientAuth=true&keyStore=/path/keystore.jksConnection with SSL certificate
Performance Optimizedtcp://localhost:61616?tcpNoDelay=true&socketBufferSize=65536Optimized for performance
High Availabilityfailover:(tcp://primary:61616,tcp://backup:61616)?maxReconnectAttempts=-1Configured for high availability
Full Failoverfailover:(tcp://broker1:61616,tcp://broker2:61616)?initialReconnectDelay=1000&maxReconnectDelay=30000&maxReconnectAttempts=5Detailed failover settings
Production Readyfailover:(tcp://prod1:61616,tcp://prod2:61616)?randomize=true&priorityBackup=true&useExponentialBackOff=trueOptimized for production

Important Parameters and Values

Parameter TypeParameterExample ValueDescription
TimeoutsoTimeout30000Socket read timeout (ms)
TimeoutsoWriteTimeout30000Socket write timeout (ms)
FailovermaxReconnectAttempts5Maximum reconnection attempts
FailoverinitialReconnectDelay1000Initial connection delay (ms)
PerformancetcpNoDelaytrueDisable TCP Nagle algorithm
PerformancesocketBufferSize65536Socket buffer size (bytes)
Prefetchjms.prefetchPolicy.queuePrefetch1000Queue prefetch count
Prefetchjms.prefetchPolicy.topicPrefetch1000Topic prefetch count
SSLneedClientAuthtrueClient certificate required
SSLverifyHosttrueHost verification enabled

Common Use Case Scenarios

Additional Connection Parameters

CategoryParameterValuePurpose
Wire FormatmaxFrameSize104857600Maximum message frame size
Wire FormatcacheEnabledtrueEnable wire format caching
ReliabilityuseAsyncSendtrueEnable asynchronous sending
ReliabilityalwaysSyncSendfalseDisable synchronous sending
NetworkkeepAlivetrueEnable TCP keep-alive
SecurityverifyHostNametrueEnable hostname verification
OptimizationoptimizeAcknowledgetrueEnable acknowledgment optimization
OptimizationoptimizedMessageDispatchtrue

Enable message dispatch optimization