Contact Us 1-800-596-4880

Using Anypoint Studio to Configure Redis Connector 5.2 - Mule 4

Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files.

To add and configure a connector in Studio:

When you run your app, you can view the app log as described in View the App Log.

If you are new to configuring connectors in Studio, see Using Anypoint Studio to Configure a Connector. If, after reading this topic, you need additional information about the connector fields, see the Redis Connector 5.2 Reference.

Create a Mule Project

In Studio, create a new Mule project in which to add and configure the connector:

  1. In Studio, select File > New > Mule Project.

  2. Enter a name for your Mule project and click Finish.

Add the Connector to Your Mule Project

Add Anypoint Connector for Redis to your Mule project to automatically populate the XML code with the connector’s namespace and schema location and add the required dependencies to the project’s pom.xml file:

  1. In the Mule Palette view, click (X) Search in Exchange.

  2. In Add Modules to Project, type redis in the search field.

  3. Click Redis Connector in Available modules.

  4. Click Add.

  5. Click Finish.

Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace.

Configure an Input Source

An input source initiates a flow when a specified condition is met. You can configure one of these input sources to use with Redis Connector:

  • Subscribe, which enables the Mule app to listen to specified channels

  • HTTP Listener, which initiates a flow each time it receives a request on the configured host and port

  • Scheduler, which initiates a flow when a time-based condition is met

For example, to configure the Subscribe input source, follow these steps:

  1. In the Mule Palette view, select Redis > Subscribe.

  2. Drag Subscribe to the Studio canvas.

  3. On the Subscribe configuration screen, optionally change the value of the Display Name field.

  4. Click the plus sign (+) next to the Connector configuration field to configure a global element that can be used by all instances of Redis Connector in the app.

    When you configure a global element, you can reference a configuration file that contains ANT-style property placeholders (recommended), or you can enter your authorization credentials in the global configuration properties. For information about the benefits of using property placeholders and how to configure them, see Anypoint Connector Configuration.

  5. On the Connection tab, select whether the connection is for a clustered or non-clustered configuration:

    • For a clustered configuration, enter a comma-separated list of values for all hosts in the Cluster hosts field using the format host:port. Separate the values with commas.

      Then, optionally enter values for the Connection timeout and Entry ttl fields.

      For an example, see Clustered Redis Configuration.

    • For a non-clustered configuration, enter a value for the Host, Port, and Password fields, and optionally enter a value for the Connection timeout and Entry ttl fields.

  6. On the TLS tab, optionally specify TLS information.

    For an example, see TLS Configuration.

  7. On the Advanced tab, optionally specify reconnection information, including a reconnection strategy.

  8. Click Test Connection to confirm that Mule can connect with the specified server.

  9. Click OK.

Add a Connector Operation to the Flow

When you add a connector operation to your flow, you immediately define a specific operation for that connector to perform.

To add an operation for Redis Connector, follow these steps:

  1. In the Mule Palette view, select Redis and then select the desired operation.

  2. Drag the operation onto the Studio canvas to the right of the input source.

Configure a Global Element for the Connector

When you configure a connector, it’s best to configure a global element that all instances of that connector in the app can use. Configuring a global element requires you to provide the authentication credentials the connector uses to access the target Redis system. Redis Connector supports global elements for clustered Redis configurations and non-clustered Redis configurations.

If you configured the Subscribe input source for the connector, then you already created a global element for Redis Connector. If you configured the HTTP or Scheduler input source, then follow these steps to create a global element for Redis Connector:

  1. Select the name of the connector in the Studio canvas.

  2. In the configuration screen for the operation, click the plus sign (+) next to the Connector configuration field to access the global element configuration fields.

  3. On the General tab, configure fields for the Redis configuration.

  4. On the Advanced tab, optionally specify reconnection information, including a reconnection strategy.

  5. Click Test Connection to confirm that Mule can connect with the specified server.

  6. Click OK.

Clustered Redis Configuration

The following screenshot shows an example of configuring a global element to connect to a Redis clustered configuration:

redis basic config clustered

Specify values for the following fields:

  • Name

    Enter a name for this configuration.

  • Connection

    Select Clustered to use the connector with a clustered Redis configuration.

  • Cluster hosts

    Enter a comma-separated list of Redis cluster hosts using the format host:port.

  • Connection timeout

    Enter the connection timeout, in milliseconds.

  • Entry Ttl

    Enter the default time-to-live value to set on keys stored through the connector.

  • Password

  • Redis password

    Enter the password for server authentication.

Nonclustered Redis Configuration

The following screenshot shows an example of configuring a global element for a non-clustered Redis configuration:

Configuration

Specify values for the following fields:

  • Name

    Enter the name for this configuration.

  • Connection

    Select NonClustered to use the connector with a non-clustered Redis configuration.

  • Host

    Enter the host for the Redis server.

  • Port

    Enter the port on which the non-clustered server is running.

  • Connection Timeout

    Enter the connection timeout, in milliseconds.

  • Entry Ttl

    Enter the default time-to-live value to set on keys stored through the connector.

  • Password

    Enter the password for server authentication.

TLS Configuration

To enable and configure TLS for your app:

  1. Click the TLS tab to configure the truststore and keystore:

    • Trust Store Configuration

      • Path

        Location of the truststore file.

      • Password

        Password for the truststore file.

      • Type

        File format of the truststore file.

      • Algorithm

        Algorithm the truststore uses.

      • Insecure
        Boolean that determines whether or not to validate the truststore. If set to true, no validation occurs. The default value is false.

    • Key Store Configuration

      • Type

        Optionally specify the file format of the keystore file. The default value is JKS.

      • Path

        Location of the keystore file. This is optional and can be used for two-way authentication for the connector.

      • Alias

        Attribute that indicates the alias of the key to use when the keystore contains many private keys. If not defined, the first key in the file is used by default.

      • Key password

        Key manager password, which is the password for the private key inside the keystore.

      • Password

        Store password for the keystore file. This needed only if the Key Store Location is configured.

      • Algorithm

        Algorithm used in the keystore.

View the App Log

You can view the app log for the connector as follows:

  • If you’re running the app from the Anypoint Platform, the output is visible in the Anypoint Studio Console window.

  • If you’re running the app using Mule from the command line, the app log is visible in your OS console.

Unless the log file path was customized in the app’s log file (log4j2.xml), you can also view the app log in MULE_HOME/logs/<app-name>.log.

For more information about the app log, see Configuring Logging.

Next Step

After you configure a global element and connection information, configure the other fields for the connector.

View on GitHub