A JMS application can set properties on the ConnectionFactory to modify the behavior of the application.
The properties are defined in a class called com.ibm.msg.client.mqtt.MQTTConstants:
This property is a mandatory string property with no default value. This property is a URL format String describing the location of the broker to which to connect. When connecting to a broker in the same Virtual Machine (VM) that implements the Java
™ specifications as the application, use the String com.ibm.msg.client.mqtt.MQTTConstants.MQTT_LOCAL_SCHEMA + <Broker Name
>. When connecting to a broker in a remote VM from the application, use the String com.ibm.msg.client.mqtt.MQTTConstants.MQTT_TCP_SCHEMA + <Hostname
> + ":" + <port
This property is an optional integer property. The default value is 60000 milliseconds. This property represents a value in milliseconds, specifying how often the broker is to be notified that a client application is functioning. The keep alive functionality comes into operation only when no data has flowed over the connection for the defined keep alive period. The purpose of the keep alive functionality is to protect against connections becoming stale because a client has unexpectedly dropped off the network without the broker being notified.
This property is an optional integer property. The default value is 15000 milliseconds. This property represents a value in milliseconds, specifying how long the client is to wait for the broker to acknowledge requests. If acknowledgments are not received within this time interval, a JMSException is thrown to the application.
- Last Will and Testament
This property is optional. The default value is no last will and testament message. A client can specify a last will and testament message when connecting to the broker. This message is published by the broker on behalf of the client in the event that the client connection to the broker unexpectedly terminates. The purpose of this functionality is to allow monitoring applications to be notified of the event and an administrator to take action.
A string property specifying the topic on which the message is to be published.
A string property specifying the message content to be published.
A Boolean property indicating whether the message is to be retained by the broker. A retained publication remains associated with its topic in the broker until it is superseded by a new retained publication to the same topic. The benefit of this is that subscribers can receive this publication even if they were not subscribed at the time the event was generated.
A byte property specifying the quality of service at which the message is to be delivered to subscribers. Valid values are 0, 1, or 2, where 0 is non-persistent, 1 is persistent, but may be duplicated, 2 is persistent and ensures once-and-once-only delivery.
The property used to specify the SSL settings (as a Properties object) for an SSL connection (ssl://). Note that these SSL properties are valid only if an implementation of the Java Secure Socket Extensions (JSSE) is available. For more information about SSL, see ../com.ibm.rcp.tools.doc.appdev/mb_clientconfiguration.html.
This property is an optional Boolean property. The default value is true. This property represents a Boolean value specifying what behavior is to occur if a client with the same client identifier is already connected. When two clients with the same client identifier connect, the default action is to disconnect the client that has been connected longest. Setting this property to false reverses that behavior and causes the client trying to connect to be refused.
This property is a string property with no default value. This property is the client identifier that a client assumes when making connections to the broker. If this property is not set in the connection factory, the application must use javax.jms.Connection.setClientId() to set the client identifier. Each client connected to a broker must have a unique client identifier. If multiple clients are required, you must either:
- Create a connection factory for each client specifying a different client ID in each factory.
- Create a single connection factory without setting the CLIENT_ID property. The application must explicitly set the client identifier for each connection created from the connection factory.
This property is an optional Boolean property. The default value is false. This property indicates whether the client is to perform buffering on its connection to a micro broker. The behavior of a buffered client is detailed in mb_developingbufferedjmsapp.dita.
This property is an optional integer property used only when buffering is enabled on the client. It represents the size in bytes of the outbound message buffer. The default value is 524288 (512 KB).
This property is an optional integer property that is used only when buffering is enabled on the client. It represents the type of persistence the client should use to protect the buffer. The valid values are:
The buffer is held in memory. If the client shuts down, the buffer contents are lost.
The buffer is held in memory during normal operation. When the client shuts down, the buffer contents are written to disk.
The buffer is maintained on disk at all times. This value is the default value.
This property is an optional String property used only when buffering is enabled on the client and either SHUTDOWN or FULL persistence is used. The property represents the directory that the client uses to store its persisted data. If not specified, the client uses the value of the system property osgi.instance.area. If that property is not set, it uses the current working directory of the application. The client creates its own directory under this one, thereby allowing multiple clients to share the same data directory. Refer to MQTT_PERSISTENCE_KEY for more information on using multiple clients in the same data directory.
This property is an optional String property used only when buffering is enabled on the client and either SHUTDOWN or FULL persistence is used. To allow multiple clients to share the same MQTT_DATA_DIRECTORY, the client creates its own directory beneath that one. If this property is not set, it uses a combination of the client ID and the connection URI as the directory name. If this property is set, then the persistence directory is a combination of the client ID and this property, allowing the connection URI to be changed without losing the state of the buffer.