Note that fresh installations of MongoDB do not come with users or databases installed. Once you have setup MongoDB you will need to create a user to be used with Tigase. To do this, bring up the mongo console by running mongo.exe in a cmd window for windows, or run mongo in linux. Once connected, enter then following:
use admin db.createUser( { user: "tigase", pwd: "password", customData: { employeeId: 12345 }, roles: [ "root" ] } )
Be sure to give this user a root
role in order to properly write to the database.
Once you receive a user successfully created
message, you are ready to install tigase on MongoDB.
To configure Tigase XMPP Server to use MongoDB you need to set dataSource
in etc/config.tdsl file to proper MongoDB URI pointing to which MongoDB database should be used (it will be created by MongoDB
if it does not exist).
userRepository
property should not be set to let Tigase XMPP Server auto-detect proper implementation of UserRepository
. Tigase XMPP Server will create proper collections in MongoDB if they do not exist so no schema files are necessary.
Example configuration of XMPP Server pointing to MongoDB database tigase_test
in a local instance:
dataSource { default () { uri = 'mongodb://user:pass@localhost/tigase_test' } } userRepository { default () {} } authRepository { default () {} }
If Tigase Server is not able to detect a proper storage layer implementation, it can be forced to use one provided by Tigase
using the following lines in etc/config.tdsl
file:
userRepository { default () { cls = 'tigase.mongodb.MongoRepository' } } authRepository { default () { cls = 'tigase.mongodb.MongoRepository' } }
Every component should be able to use proper implementation to support MongoDB using this URI. Also MongoDB URI can be passed as any URI in configuration of any component.
By default, MUC component will use MongoDB to store data if Tigase is configured to use it as a default store. However, if
you would like to use a different MongoDB database to store MUC message archive, you can do this by adding the following lines
to etc/config.tdsl
file:
muc { 'history-db-uri' = 'mongodb://user:pass@localhost/tigase_test' }
If MUC components fails to detect and use a proper storage layer for MongoDB, you can force it to use one provided by Tigase
by using the following line in the config.tdsl
file:
muc { 'history-db' = 'tigase.mongodb.muc.MongoHistoryProvider' }
By default, PubSub component will use MongoDB to store data if Tigase is configured to use it as a default store. However,
if you would like to use a different MongoDB database to store PubSub component data, you can do this by adding the following
lines to etc/config.tdsl
file:
pubsub { 'pubsub-repo-url' = 'mongodb://user:pass@localhost/tigase_test' }
If the PubSub components fails to detect and use a proper storage layer for MongoDB, you can force it to use one provided
by Tigase by using the following line in the config.tdsl
file:
pubsub { 'pubsub-repo-class' = 'tigase.mongodb.pubsub.PubSubDAOMongo' }
By default, the Message Archiving component will use MongoDB to store data if Tigase is configured to use it as a default
store. However, if you would like to use a different MongoDB database to store message archives, you can do this by adding
the following lines to etc/config.tdsl
file:
'message-archive' { 'archive-repo-uri' = 'mongodb://user:pass@localhost/tigase_test' }
If Message Archiving component fails to detect and use a proper storage layer for MongoDB, you can force it to use one provided
by Tigase by using the following line in the config.tdsl
file:
'message-archive' { 'archive-repo-class' = 'tigase.mongodb.archive.MongoMessageArchiveRepository' }