Configuring NMS

The configuration of NMS is so slick, we decided to take a similar approach with ActiveMQ. All configuration is achieved via URI-encoded parameters, either on the connection or destinations. Through the URIs, you can configure virtually every facet of your NMS client. The tables below show the comprehensive set of parameters.

Connection URI Parameters

 Example Configuration
cf = new ConnectionFactory(
    "activemq:tcp://localhost:61616?wireFormat=openwire&wireFormat.tightEncodingEnabled=true");

NMS Provider Options

Option Name Description
activemq Use the ActiveMQ NMS Provider to talk to an ActiveMQ Broker.

Protocol Options

Option Name
Description
tcp Uses TCP/IP Sockets to connect to the Broker.
discovery Uses The Discovery Transport to find a Broker
failover Uses the Failover Transport to connect and reconnect to one or more Brokers

Transport Options

TCP Transport Options
Option Name Default Description
useLogging false Log data that is sent across the Transport.
receiveBufferSize 8192 Amount of Data to buffer from the Socket
sendBufferSize 8192 Amount of Data to buffer before writing to the Socket
receiveTimeout 0 Time to wait for more data, zero means wait infinitely
sendTimeout 0 Timeout on sends, 0 means wait forever for completion
wireFormat openwire The Wire Format of the Commands sent to the Broker
requestTimeout 0 Time to wait before a Request Command is considered to have failed
Discovery Transport Options
Failover Transport Options

Connection Options

Option Name Default Description
AsyncSend false Are message sent Asynchronously.
AsyncClose true Should the close command be sent Asynchronously
AlwaysSyncSend false Causes all messages a Producer sends to be sent Asynchronously.
CopyMessageOnSend true Copies the Message objects a Producer sends so that the client can reuse Message objects without affecting an in-flight message.
ProducerWindowSize 0 The ProducerWindowSize is the maximum number of bytes in memory that a producer will transmit to a broker before waiting for acknowledgement messages from the broker that it has accepted the previously sent messages. In other words, this how you configure the producer flow control window that is used for async sends where the client is responsible for managing memory usage. The default value of 0 means no flow control at the client. See also Producer Flow Control

Wire Format Protocol Options

Option Name Default Description
wireFormat openwire Selects the wire format to use. Out of the box, can be either stomp or openwire.
OpenWire Options
Option Name Default Description
wireFormat.stackTraceEnabled false Should the stack trace of exception that occur on the broker be sent to the client? Only used by openwire protocol.
wireFormat.cacheEnabled false Should commonly repeated values be cached so that less marshalling occurs? Only used by openwire protocol.
wireFormat.tcpNoDelayEnabled false Does not affect the wire format, but provides a hint to the peer that TCP nodelay should be enabled on the communications Socket. Only used by openwire protocol.
wireFormat.sizePrefixDisabled false Should serialized messages include a payload length prefix? Only used by openwire protocol.
wireFormat.tightEncodingEnabled false Should wire size be optimized over CPU usage? Only used by the openwire protocol.

Destination URI Parameters

Example Configuration
d = session.CreateTopic("com.foo?consumer.prefetchSize=2000&consumer.noLocal=true");

General Options

Option Name Default Description
consumer.prefetchSize 1000 The number of message the consumer will prefetch.
consumer.maximumPendingMessageLimit 0 Use to control if messages are dropped if a slow consumer situation exists.
consumer.noLocal false Same as the noLocal flag on a Topic consumer. Exposed here so that it can be used with a queue.
consumer.dispatchAsync false Should the broker dispatch messages asynchronously to the consumer.
consumer.retroactive false Is this a Retroactive Consumer.
consumer.selector null JMS Selector used with the consumer.
consumer.exclusive false Is this an Exclusive Consumer.
consumer.priority 0 Allows you to configure a Consumer Priority.

OpenWire-only Options

Option Name Default Description
consumer.browser false  
consumer.networkSubscription false  
consumer.optimizedAcknowledge false Enables an optimised acknowledgement mode where messages are acknowledged in batches rather than individually. Alternatively, you could use Session.DUPS_OK_ACKNOWLEDGE acknowledgement mode for the consumers which can often be faster. WARNING enabling this issue could cause some issues with auto-acknowledgement on reconnection
consumer.noRangeAcks false  
consumer.retroactive false Sets whether or not retroactive consumers are enabled. Retroactive consumers allow non-durable topic subscribers to receive old messages that were published before the non-durable subscriber started.
Graphic Design By Hiram