Package com.github.ddth.queue.impl
Class MongodbQueueFactory<T extends MongodbQueue<ID,DATA>,ID,DATA>
- java.lang.Object
-
- com.github.ddth.queue.impl.AbstractQueueFactory<T,ID,DATA>
-
- com.github.ddth.queue.impl.MongodbQueueFactory<T,ID,DATA>
-
- All Implemented Interfaces:
IQueueFactory<ID,DATA>,AutoCloseable
- Direct Known Subclasses:
UniversalMongodbQueueFactory,UniversalMongodbQueueFactory
public abstract class MongodbQueueFactory<T extends MongodbQueue<ID,DATA>,ID,DATA> extends AbstractQueueFactory<T,ID,DATA>
Factory to createMongodbQueueinstances.- Since:
- 0.7.1
- Author:
- Thanh Ba Nguyen
-
-
Field Summary
Fields Modifier and Type Field Description static StringSPEC_FIELD_COLLECTION_NAMEstatic StringSPEC_FIELD_CONNECTION_STRINGstatic StringSPEC_FIELD_DATABASE_NAME
-
Constructor Summary
Constructors Constructor Description MongodbQueueFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()StringgetDefaultCollectionName()Default name of MongoDB collection to store queue messages, passed to all queues created by this factory.StringgetDefaultConnectionString()Default MongoDB's connection string (see http://mongodb.github.io/mongo-java-driver/3.10/driver/getting-started/quick-start/), passed to all queues created by this factory.StringgetDefaultDatabaseName()Default name of MongoDB database to store data, passed to all queues created by this factory.protected com.mongodb.client.MongoClientgetDefaultMongoClient()If allMongodbQueueinstances are connecting to one MongoDB server or cluster, it's a good idea to pre-create aMongoClientinstance and share it amongstMongodbQueueinstances created from this factory by assigning it todefaultMongoClient(seesetDefaultMongoClient(MongoClient)).protected voidinitQueue(T queue, QueueSpec spec)Initialize a newly created queue instance.MongodbQueueFactory<T,ID,DATA>setDefaultCollectionName(String defaultCollectionName)Default name of MongoDB collection to store queue messages, passed to all queues created by this factory.MongodbQueueFactory<T,ID,DATA>setDefaultConnectionString(String defaultConnectionString)Default MongoDB's connection string (see http://mongodb.github.io/mongo-java-driver/3.10/driver/getting-started/quick-start/), passed to all queues created by this factory.MongodbQueueFactory<T,ID,DATA>setDefaultDatabaseName(String defaultDatabaseName)Default name of MongoDB database to store data, passed to all queues created by this factory.MongodbQueueFactory<T,ID,DATA>setDefaultMongoClient(com.mongodb.client.MongoClient mongoClient)If allMongodbQueueinstances are connecting to one MongoDB server or cluster, it's a good idea to pre-create aMongoClientinstance and share it amongstMongodbQueueinstances created from this factory by assigning it todefaultMongoClient(seesetDefaultMongoClient(MongoClient)).protected MongodbQueueFactory<T,ID,DATA>setDefaultMongoClient(com.mongodb.client.MongoClient mongoClient, boolean setMyOwnMongoClient)If allMongodbQueueinstances are connecting to one MongoDB server or cluster, it's a good idea to pre-create aMongoClientinstance and share it amongstMongodbQueueinstances created from this factory by assigning it todefaultMongoClient(seesetDefaultMongoClient(MongoClient)).-
Methods inherited from class com.github.ddth.queue.impl.AbstractQueueFactory
close, createAndInitQueue, createQueueInstance, getDefaultEphemeralDisabled, getDefaultEphemeralMaxSize, getDefaultMaxSize, getQueue, init, isDefaultEphemeralDisabled, setDefaultEphemeralDisabled, setDefaultEphemeralMaxSize, setDefaultMaxSize
-
-
-
-
Field Detail
-
SPEC_FIELD_CONNECTION_STRING
public static final String SPEC_FIELD_CONNECTION_STRING
- See Also:
- Constant Field Values
-
SPEC_FIELD_DATABASE_NAME
public static final String SPEC_FIELD_DATABASE_NAME
- See Also:
- Constant Field Values
-
SPEC_FIELD_COLLECTION_NAME
public static final String SPEC_FIELD_COLLECTION_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDefaultConnectionString
public String getDefaultConnectionString()
Default MongoDB's connection string (see http://mongodb.github.io/mongo-java-driver/3.10/driver/getting-started/quick-start/), passed to all queues created by this factory.- Returns:
-
setDefaultConnectionString
public MongodbQueueFactory<T,ID,DATA> setDefaultConnectionString(String defaultConnectionString)
Default MongoDB's connection string (see http://mongodb.github.io/mongo-java-driver/3.10/driver/getting-started/quick-start/), passed to all queues created by this factory.- Parameters:
defaultConnectionString-- Returns:
-
getDefaultDatabaseName
public String getDefaultDatabaseName()
Default name of MongoDB database to store data, passed to all queues created by this factory.- Returns:
-
setDefaultDatabaseName
public MongodbQueueFactory<T,ID,DATA> setDefaultDatabaseName(String defaultDatabaseName)
Default name of MongoDB database to store data, passed to all queues created by this factory.- Parameters:
defaultDatabaseName-- Returns:
-
getDefaultCollectionName
public String getDefaultCollectionName()
Default name of MongoDB collection to store queue messages, passed to all queues created by this factory.- Returns:
-
setDefaultCollectionName
public MongodbQueueFactory<T,ID,DATA> setDefaultCollectionName(String defaultCollectionName)
Default name of MongoDB collection to store queue messages, passed to all queues created by this factory.- Parameters:
defaultCollectionName-- Returns:
-
getDefaultMongoClient
protected com.mongodb.client.MongoClient getDefaultMongoClient()
If allMongodbQueueinstances are connecting to one MongoDB server or cluster, it's a good idea to pre-create aMongoClientinstance and share it amongstMongodbQueueinstances created from this factory by assigning it todefaultMongoClient(seesetDefaultMongoClient(MongoClient)).- Returns:
-
setDefaultMongoClient
public MongodbQueueFactory<T,ID,DATA> setDefaultMongoClient(com.mongodb.client.MongoClient mongoClient)
If allMongodbQueueinstances are connecting to one MongoDB server or cluster, it's a good idea to pre-create aMongoClientinstance and share it amongstMongodbQueueinstances created from this factory by assigning it todefaultMongoClient(seesetDefaultMongoClient(MongoClient)).- Parameters:
mongoClient-- Returns:
-
setDefaultMongoClient
protected MongodbQueueFactory<T,ID,DATA> setDefaultMongoClient(com.mongodb.client.MongoClient mongoClient, boolean setMyOwnMongoClient)
If allMongodbQueueinstances are connecting to one MongoDB server or cluster, it's a good idea to pre-create aMongoClientinstance and share it amongstMongodbQueueinstances created from this factory by assigning it todefaultMongoClient(seesetDefaultMongoClient(MongoClient)).- Parameters:
mongoClient-setMyOwnMongoClient-- Returns:
-
destroy
public void destroy()
- Overrides:
destroyin classAbstractQueueFactory<T extends MongodbQueue<ID,DATA>,ID,DATA>
-
initQueue
protected void initQueue(T queue, QueueSpec spec) throws Exception
Initialize a newly created queue instance.Called by
AbstractQueueFactory.createAndInitQueue(QueueSpec). Sub-class may override this method to implement its own business logic.- Overrides:
initQueuein classAbstractQueueFactory<T extends MongodbQueue<ID,DATA>,ID,DATA>- Throws:
Exception
-
-