// This module is included in the following assemblies:
// as_connecting-to-mqtt.adoc

[id='creating-mqtt-connections_{context}']
= Creating a connection to an MQTT broker

In an integration, to obtain messages from or publish messages to
an MQTT broker, create a connection to the MQTT broker
of interest and then add that connection to an integration.

.Prerequisite
You must know the URL for the MQTT broker that you want to connect to. 

.Procedure

. In {prodname}, in the left panel, click *Connections* to
display any available connections.
. Click *Create Connection* to display
connectors.  
. Click the *MQTT Message Broker* connector.
. To configure the connection:
.. In the *MQTT broker URL* field, enter the location of the MQTT broker
that you want to send data to or obtain data from. This is the only
required field. 
.. In the *User Name* field, optionally enter the user name for the MQTT
account whose credentials you want to use to access the broker. 
.. In the *Password* field, if you specified a user name, then specify the
password associated with that account. 
.. In the *Client ID* field, optionally enter the ID that allows connections 
to close and reopen without missing messages. The connection must
subscribe to or publish to a topic.
. Click *Validate*. {prodname} immediately tries to validate the 
connection and displays a message that indicates whether 
validation is successful. If validation fails, revise the input 
parameters and try again.
. If validation is successful, click *Next*.
. In the *Name* field, enter your choice of a name that
helps you distinguish this connection from any other connections.
For example, you might enter `MQTT West`.
. In the *Description* field, optionally enter any information that
is helpful to know about this connection. 
. Click *Save* to see that the connection you 
created is now available. If you
entered the example name, you would 
see that *MQTT West* appears as a connection that you can 
choose to add to an integration. 
