The TIBCO StreamBase® Output Adapter for MQTT Client Subscribe allows StreamBase applications to connect to an MQTT Broker and subscribe to messages from the broker on specific topic queues.
This section describes the properties you can set for this adapter, using the various tabs of the Properties view in StreamBase Studio.
Name: Use this field to specify or change the component's name, which must be unique in the application. The name must contain only alphabetic characters, numbers, and underscores, and no hyphens or other special characters. The first character must be alphabetic or an underscore.
Adapter: A read-only field that shows the formal name of the adapter.
Class: A field that shows the fully qualified class name that implements the functionality of this adapter. Use this class name when loading the adapter in StreamSQL programs with the APPLY JAVA statement. You can right-click this field and select Copy from the context menu to place the full class name in the system clipboard.
Start with application: If this field is set to Yes or to a module parameter that evaluates to true, an instance of this adapter starts as part of the containing StreamBase Server. If this field is set to No or to a module parameter that evaluates to false, the adapter is loaded with the server, but does not start until you send an sbadmin resume command, or until you start the component with StreamBase Manager. With this option set to No or false, the adapter does not start even if the application as a whole is suspended and later resumed. The recommended setting is selected by default.
Enable Error Output Port: Select this check box to add an Error Port to this component. In the EventFlow canvas, the Error Port shows as a red output port, always the last port for the component. See Using Error Ports and Error Streams to learn about Error Ports.
Description: Optionally enter text to briefly describe the component's purpose and function. In the EventFlow canvas, you can see the description by pressing Ctrl while the component's tooltip is displayed.
|MQTT Connection||drop-down list||This required field selects a value from the sbconf file, which contains the connection configuration for the MQTT client.
This value is selected from the
|Enable Control Port||check box||When enabled, the adapter allows incoming tuples to control the actions of this adapter.|
|Command Field Name||string||The name of the field in the incoming control tuple that contains the command.|
|Topic Field Name||string||The name of the field in the incoming tuple that contains the topic.|
|Qos Field Name||string||The name of the field in the incoming tuple that contains the QoS (quality of service) setting.|
|Enable Status Port||check box||When enabled, the adapter sends out informational data on the status port about various states of the adapter.|
|Log Level||Drop-down list||Controls the level of verbosity the adapter uses to issue informational traces to the console. This setting is independent of the containing application's overall log level. Available values, in increasing order of verbosity, are: OFF, ERROR, WARN, INFO, DEBUG, TRACE, and ALL.|
|Output As Raw Bytes||check box||Specifies whether the outbound payload data is to be a string or a blob data type.|
|Initial Subscriptions||table||The initial message queue subscriptions to make after connecting to the MQTT broker. The topic column must have a value and cannot contain the characters pound (#) or plus (+). The QoS column must be a value between 0 and 2, inclusive.|
Command, string, the command to send to the adapter.
The values are:
Connect — Connect to the MQTT broker.
Disconnect — Disconnect from the MQTT broker.
Subscribe — Subscribe to a message queue; the topic field must be included when using this command. Optional fields for this command are Qos (defaults to 0 if not found or null).
Unsubscribe — Unsubscribe from a message queue; the topic field must be included when using this command.
The status port is used to send status information tuples downstream to inform the user of changes.
type, string. The type of status information emitted on this port. Status types are:
Error — Indicates this message is related to an error that occurred.
Info — Indicates this message is related to extra status information.
Subscribe — A subscription was successful.
Subscribe Failed — A subscription was NOT successful
Unsubscribe — Unsubscribing from a queue was successful.
Unsubscribe Failed — Unsubscribing from a queue was NOT successful.
Connection Lost — The connection to the MQTT Broker was lost.
object, string. This value may be null. If it is not null, it contains a value relevant to the status message.
message, string. This is a formatted human readable message that explains the status message.
All settings are in the format <setting name="" val=""/>
The connection configuration is stored in the project's sbconf file. The following is an example of a complete configuration.
<?xml version="1.0" encoding="UTF-8"?> <streambase-configuration xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.streambase.com/schemas/sbconf/"> <adapter-configurations> <adapter-configuration name="mqttclientconnections"> <section name="mqttclientconnection"> <setting name="id" val="iot.eclipse.org"/> <!-- Determines if this connection is created on startup or during the first usage. --> <setting name="connectOnStartup" val="true" /> <!-- Comma separated list of URIs, If the port is not specified, it will default to 1883 for tcp://" URIs, and 8883 for ssl:// URIs --> <setting name="URIs" val="tcp://iot.eclipse.org:1883" /> <!-- isCleanSession: • If set to false both the client and server will maintain state across restarts of the client, the server and the connection. As state is maintained: ◦ Message delivery will be reliable meeting the specified QOS even if the client, server or connection are restarted. ◦ The server will treat a subscription as durable. • If set to true the client and server will not maintain state across restarts of the client, the server or the connection. This means: ◦ Message delivery to the specified QOS cannot be maintained if the client, server or connection are restarted ◦ The server will treat a subscription as non-durable --> <setting name="isCleanSession" val="true" /> <!-- The client identifier to use when creating a connection to the broker. If this value is blank an identifier will be generated. --> <setting name="ClientId" val="" /> <!-- The persistence class to use to store in-flight message. The values are 'memory' or 'file'. --> <setting name="PersistenceType" val="memory" /> <!-- The full path to use for file persistence. If this option is blank or missing the system will use System.getProperty("user.dir") as the location to store a temporary file--> <setting name="PersistencePath" val="/" /> <!-- Sets the user name to use for the connection. --> <setting name="Username" val="" /> <!-- Sets the password to use for the connection. --> <setting name="Password" val="" /> <!-- Sets the connection timeout value. This value, measured in seconds, defines the maximum time interval the client will wait for the network connection to the MQTT server to be established. The default timeout is 30 seconds. A value of 0 disables timeout processing meaning the client will wait until the network connection is made successfully or fails. --> <setting name="connectionTimeout" val="30" /> <!-- Sets the "keep alive" interval. This value, measured in seconds, defines the maximum time interval between messages sent or received. It enables the client to detect whether the server is no longer available, without having to wait for the TCP/IP timeout. The client will ensure that at least one message travels across the network within each keep alive period. In the absence of a data-related message during the time period, the client sends a very small ping message, which the server will acknowledge. A value of 0 disables keepalive processing in the client. The default value is 60 seconds. --> <setting name="keepAliveInterval" val="60" /> <!-- Sets the "Last Will and Testament" (LWT) for the connection. In the event that this client unexpectedly loses its connection to the server, the server will publish a message to itself using the supplied details. --> <!-- The topic to publish the will to --> <setting name="willTopic" val="" /> <!-- The payload for the message to send to the will topic to --> <setting name="willPayload" val="" /> <!-- The quality of service to which the message publish is to be published (0, 1 or 2). --> <setting name="willQos" val="" /> <!-- Whether or not the will message should be retained. --> <setting name="willRetained" val="" /> <!-- Sets the SSL properties for the connection. Note that these properties are only valid if an implementation of the Java Secure Socket Extensions (JSSE) is available. --> <!-- One of: SSL, SSLv3, TLS, TLSv1, SSL_TLS --> <setting name="sslProtocol" val="" /> <!-- Underlying JSSE provider. For example "IBMJSSE2" or "SunJSSE" --> <setting name="sslContextProvider" val="" /> <!-- The name of the file that contains the KeyStore object that you want the KeyManager to use. --> <setting name="sslKeyStore" val="" /> <!-- The password for the KeyStore object that you want the KeyManager to use --> <setting name="sslKeyStorePassword" val="" /> <!-- for example "PKCS12", "JKS", or "JCEKS" --> <setting name="sslKeyStoreType" val="" /> <!-- for example "IBMJCE" or "IBMJCEFIPS" --> <setting name="sslKeyStoreProvider" val="" /> <!-- The name of the file that contains the KeyStore object that you want the TrustManager to use. --> <setting name="sslTrustStore" val="" /> <!-- The password for the TrustStore object that you want the TrustManager to use. --> <setting name="sslTrustStorePassword" val="" /> <!-- for example "PKCS12", "JKS", or "JCEKS" --> <setting name="sslTrustStoreType" val="" /> <!-- for example "IBMJCE" or "IBMJCEFIPS" --> <setting name="sslTrustStoreProvider" val="" /> <!-- A list of which ciphers are enabled. Values are dependent on the provider, Examples are: SSL_RSA_WITH_AES_128_CBC_SHA SSL_RSA_WITH_3DES_EDE_CBC_SHA --> <setting name="sslEnabledCipherSuites" val="" /> <!-- Sets the algorithm that will be used to instantiate a KeyManagerFactory object instead of using the default algorithm available in the platform. Example values: "IbmX509" or "IBMJ9X509" --> <setting name="sslKeyManager" val="" /> <!-- Sets the algorithm that will be used to instantiate a TrustManagerFactory object instead of using the default algorithm available in the platform. Example values: "PKIX" or "IBMJ9X509". --> <setting name="sslTrustManager" val="" /> </section> </adapter-configuration> </adapter-configurations> </streambase-configuration>
Use the Concurrency tab to specify parallel regions for this instance of this component, or multiplicity options, or both. The Concurrency tab settings are described in Concurrency Options, and dispatch styles are described in Dispatch Styles.
Concurrency settings are not suitable for every application, and using these settings requires a thorough analysis of your application. For details, see Execution Order and Concurrency, which includes important guidelines for using the concurrency options.