Skip to main content
Skip table of contents

Cache provider: MongoDB

Overview

This section describes how to create and configure a MongoDB instance running in a Docker container. For more information about MongoDB installations, please navigate to https://hub.docker.com/_/mongo/ or follow the steps below:

Installation prerequisites

You will need to have Docker Desktop for Mac, Docker Desktop for Windows, or similar software installed on your machine.

  1. Create a directory called MongoDB in machine’s root folder. In this example, the directory will be created in C:\Docker.

  2. Navigate to C:\Docker\MongoDB and create another directory called data. We will be using this directory to store MongoDB data files.

  3. Open VSCode editor and create new file called docker-compose.yml. This file must be saved within C:\Docker\MongoDB directory with the following content:

CODE
version: "3.9"

services:
    mongo:
        image: mongo:latest
        ports: 
            - "27018:27017"
        volumes:
            - ./data:/data/db
  1. In the host machine, launch command line console within C:\Docker\MongoDB directory and execute the command below to start MongoDB instance.

start " Mongo-DB" docker-compose -f docker-compose.yml up

Realtime API configuration

This section describes how to configure the Realtime API web application to utilize the MongoDB caching mechanism to support RPI realtime decisions. Please follow the steps below.

  1. Open the appsettings.json.config file in the Realtime API web application.

  2. Ensure you have uploaded the following assemblies to the Realtime API web application’s bin directory:

  • RedPoint.Resonance.MongoDBCache.dll

  • MongoDB.Bson.dll

  • MongoDB.Driver.Core.dll

  • MongoDB.Driver.dll

  • MongoDB.Libmongocrypt.dll

  1. In the appsettings.json.config file, locate CacheSettings and add the following entries:

CODE
   "Caches":[
      {
         "Name":"MongoDBCache",
         "Assembly":"RedPoint.Resonance.MongoDBCache",
         "Class":" RedPoint.Resonance.MongoDBCache.MongoDBCacheHandler",
         "Settings":[
            {
              "Key":"ConnectionString",
               "Value":"REPLACE THIS TEXT WITH MONGODB CONNECTION STRING"
            },
            {
               "Key":" Database",
               "Value":"” REPLACE THIS TEXT WITH MONGODB DATABASE NAME”"
            },
            {
               "Key":" CollectionName",
               "Value":"REPLACE THIS TEXT WITH MONGODB COLLECTION NAME"
            },
            {
               "Key":" MessageHistoryCollectionName",
               "Value":"REPLACE THIS TEXT WITH MONGODB COLLECTION NAME"
            },
            {
               "Key":" MessageHistoryCollectionName",
               "Value":"REPLACE THIS TEXT WITH MONGODB COLLECTION NAME"
            },
            {
               "Key":"PartitionKeyEnabled",
               "Value":false
            },
            {
               "Key":"PartitionKeys",
               "Value":[]
            },
            {
               "Key":"IDasKeyEnabled",
               "Value":false
            }
         ]
      }
   ]
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.