Code Monkey home page Code Monkey logo

wisdom-mongodb's Introduction

Wisdom MongoDB

This project is an extension for Wisdom Framework, to allow the integration of MongoDB database.

Installation

Add the following dependency to your pom.xml file:

<dependency>
  <groupId>org.wisdom-framework.mongo</groupId>
  <artifactId>wisdom-mongodb</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

Configuration using the application.conf file

In the src/main/configuration/application.conf file add the following snippet:

###
# MongoDB Configuration
###
mongodb {
  test { # Name used to identify the data source. If `datasources` is not set, it will be used
    hostname: localhost
    port: 12345
    dbname: kitten
  }
}

Under mongodb you can add several elements to configure several mongodb servers / databases.

Configuration using cfg files

You can also configure the extension using cfg files. Each cfg file creates an instance of the MongoDB Client. Create a file named org.wisdom.mongodb.MongoDBClient-YOUR_NAME.cfg into src/main/configuration.

hostname: localhost
port: 12345
dbname: kitten

Using MongoDB

For each instantiated client, a com.mongodb.DB is exposed. This service is only exposed if the database is available . A heartbeat is setup to track the availability. If the service is exposed, it means that the connection has been established and should work.

The service is exposed with the following properties that let you select the right one:

  • host: the host
  • port: the port
  • name: the name of the database
  • datasources: array of string

Here are some examples:

@Requires(filter="(host=localhost)") // database host
DB localhost;

@Requires(filter="(name=test)") // database name
DB localhost;

@Requires(filter="(datasources=cat)") // datasource names
DB localhost;

Configuration Property

These are the different Mongo Client options you can configure:

###description

Sets the description of the Mongo Client takes a string.

###connectionsPerHost

Sets the maximum number of connections per host, takes an integer, must be greater than 1, default is 2.

###threadsAllowedToBlockForConnectionMultiplier

Sets the multiplier for number of threads allowed to block waiting for a connection. Takes an integer that must be greater than 0.

###maxWaitTime Sets the maximum time that a thread will block waiting for a connection. Takes an integer that cannot be less than 0.

###connectTimeout Sets the connection timeout. Takes an integer, that cannot be less than 0.

###autoConnectRetry Sets whether auto connect retry is enabled, takes a boolean true or false.

###maxAutoConnectRetryTime Sets the maximum auto connect retry time, takes an integer.

###writeConcern Sets the write concern. individual params: WriteConcern(int w, int wtimeout, boolean fsync, boolean j)

###socketTimeout Sets the socket timeout.

###socketKeepAlive Sets whether socket keep alive is enabled.

###socketFactory Sets the socket factory.

wisdom-mongodb's People

Contributors

cescoffier avatar codepanda26 avatar jenf11 avatar jfry-axway avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.