@UriEndpoint(scheme="mongodb", title="MongoDB", syntax="mongodb:connectionBean", consumerClass=MongoDbTailableCursorConsumer.class, label="database,nosql") public class MongoDbEndpoint extends org.apache.camel.impl.DefaultEndpoint
Constructor and Description |
---|
MongoDbEndpoint() |
MongoDbEndpoint(String uri,
MongoDbComponent component) |
Modifier and Type | Method and Description |
---|---|
org.apache.camel.Consumer |
createConsumer(org.apache.camel.Processor processor) |
List<com.mongodb.BasicDBObject> |
createIndex()
Create technical list index
|
org.apache.camel.Exchange |
createMongoDbExchange(com.mongodb.DBObject dbObj) |
org.apache.camel.Producer |
createProducer() |
protected void |
doStart()
Applies validation logic specific to this endpoint type.
|
protected void |
doStop() |
void |
ensureIndex(com.mongodb.client.MongoCollection<com.mongodb.BasicDBObject> collection,
List<com.mongodb.BasicDBObject> dynamicIndex)
Add Index
|
String |
getCollection() |
String |
getCollectionIndex() |
String |
getConnectionBean() |
MongoDbConsumerType |
getConsumerType() |
long |
getCursorRegenerationDelay() |
String |
getDatabase() |
com.mongodb.client.MongoCollection<com.mongodb.BasicDBObject> |
getMongoCollection() |
com.mongodb.MongoClient |
getMongoConnection() |
com.mongodb.client.MongoDatabase |
getMongoDatabase() |
MongoDbOperation |
getOperation() |
MongoDbOutputType |
getOutputType() |
String |
getPersistentId() |
com.mongodb.ReadPreference |
getReadPreference() |
String |
getTailTrackCollection() |
String |
getTailTrackDb() |
String |
getTailTrackField() |
String |
getTailTrackIncreasingField() |
MongoDbTailTrackingConfig |
getTailTrackingConfig() |
com.mongodb.WriteConcern |
getWriteConcern() |
com.mongodb.WriteConcern |
getWriteConcernRef() |
void |
initializeConnection()
Initialises the MongoDB connection using the Mongo object provided to the endpoint
|
boolean |
isCreateCollection() |
boolean |
isDynamicity() |
boolean |
isPersistentTailTracking() |
boolean |
isSingleton() |
boolean |
isWriteResultAsHeader() |
void |
setCollection(String collection)
Sets the name of the MongoDB collection to bind to this endpoint
|
void |
setCollectionIndex(String collectionIndex)
Sets the collection index (JSON FORMAT : { "field1" : order1, "field2" : order2})
|
void |
setConnectionBean(String connectionBean)
Name of
Mongo to use. |
void |
setConsumerType(String consumerType)
Reserved for future use, when more consumer types are supported.
|
void |
setCreateCollection(boolean createCollection)
Create collection during initialisation if it doesn't exist.
|
void |
setCursorRegenerationDelay(long cursorRegenerationDelay)
MongoDB tailable cursors will block until new data arrives.
|
void |
setDatabase(String database)
Sets the name of the MongoDB database to target
|
void |
setDynamicity(boolean dynamicity)
Sets whether this endpoint will attempt to dynamically resolve the target database and collection from the incoming Exchange properties.
|
void |
setMongoConnection(com.mongodb.MongoClient mongoConnection)
Sets the Mongo instance that represents the backing connection
|
void |
setOperation(String operation)
Sets the operation this endpoint will execute against MongoDB.
|
void |
setOutputType(MongoDbOutputType outputType)
Convert the output of the producer to the selected type : "DBObjectList", "DBObject" or "DBCursor".
|
void |
setPersistentId(String persistentId)
One tail tracking collection can host many trackers for several tailable consumers.
|
void |
setPersistentTailTracking(boolean persistentTailTracking)
Enable persistent tail tracking, which is a mechanism to keep track of the last consumed message across system restarts.
|
void |
setReadPreference(String readPreference)
Sets a MongoDB
ReadPreference on the Mongo connection. |
void |
setTailTrackCollection(String tailTrackCollection)
Collection where tail tracking information will be persisted.
|
void |
setTailTrackDb(String tailTrackDb)
Indicates what database the tail tracking mechanism will persist to.
|
void |
setTailTrackField(String tailTrackField)
Field where the last tracked value will be placed.
|
void |
setTailTrackIncreasingField(String tailTrackIncreasingField)
Correlation field in the incoming record which is of increasing nature and will be used to position the tailing cursor every
time it is generated.
|
void |
setWriteConcern(String writeConcern)
Set the
WriteConcern for write operations on MongoDB using the standard ones. |
void |
setWriteConcernRef(String writeConcernRef)
Set the
WriteConcern for write operations on MongoDB, passing in the bean ref to a custom WriteConcern which exists in the Registry. |
void |
setWriteResultAsHeader(boolean writeResultAsHeader)
In write operations, it determines whether instead of returning
WriteResult as the body of the OUT
message, we transfer the IN message to the OUT and attach the WriteResult as a header. |
configureConsumer, configurePollingConsumer, configureProperties, createEndpointConfiguration, createEndpointUri, createExchange, createExchange, createExchange, createPollingConsumer, equals, getCamelContext, getComponent, getConsumerProperties, getEndpointConfiguration, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isBridgeErrorHandler, isLenientProperties, isPollingConsumerBlockWhenFull, isSynchronous, setBridgeErrorHandler, setCamelContext, setConsumerProperties, setEndpointConfiguration, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, toString
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public MongoDbEndpoint()
public MongoDbEndpoint(String uri, MongoDbComponent component)
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
Exception
public boolean isSingleton()
public void initializeConnection() throws CamelMongoDbException
CamelMongoDbException
public void ensureIndex(com.mongodb.client.MongoCollection<com.mongodb.BasicDBObject> collection, List<com.mongodb.BasicDBObject> dynamicIndex)
collection
- public List<com.mongodb.BasicDBObject> createIndex()
protected void doStart() throws Exception
doStart
in class org.apache.camel.impl.DefaultEndpoint
Exception
protected void doStop() throws Exception
doStop
in class org.apache.camel.impl.DefaultEndpoint
Exception
public org.apache.camel.Exchange createMongoDbExchange(com.mongodb.DBObject dbObj)
public String getConnectionBean()
public void setConnectionBean(String connectionBean)
Mongo
to use.public void setCollection(String collection)
collection
- collection namepublic String getCollection()
public void setCollectionIndex(String collectionIndex)
public String getCollectionIndex()
public void setOperation(String operation) throws CamelMongoDbException
MongoDbOperation
.operation
- name of the operation as per catalogued valuesCamelMongoDbException
public MongoDbOperation getOperation()
public void setDatabase(String database)
database
- name of the MongoDB databasepublic String getDatabase()
public void setCreateCollection(boolean createCollection)
createCollection
- true or falsepublic boolean isCreateCollection()
public void setMongoConnection(com.mongodb.MongoClient mongoConnection)
mongoConnection
- the connection to the databasepublic com.mongodb.MongoClient getMongoConnection()
public void setWriteConcern(String writeConcern)
WriteConcern
for write operations on MongoDB using the standard ones.
Resolved from the fields of the WriteConcern class by calling the WriteConcern.valueOf(String)
method.writeConcern
- the standard name of the WriteConcernpublic com.mongodb.WriteConcern getWriteConcern()
public void setWriteConcernRef(String writeConcernRef)
WriteConcern
for write operations on MongoDB, passing in the bean ref to a custom WriteConcern which exists in the Registry.
You can also use standard WriteConcerns by passing in their key. See the setWriteConcern
method.writeConcernRef
- the name of the bean in the registry that represents the WriteConcern to usepublic com.mongodb.WriteConcern getWriteConcernRef()
public void setReadPreference(String readPreference)
ReadPreference
on the Mongo connection. Read preferences set directly on the connection will be
overridden by this setting.
The ReadPreference.valueOf(String)
utility method is used to resolve the passed readPreference
value. Some examples for the possible values are nearest
, primary
or secondary
etc.readPreference
- the name of the read preference to setpublic com.mongodb.ReadPreference getReadPreference()
public void setDynamicity(boolean dynamicity)
dynamicity
- true or false indicated whether target database and collection should be calculated dynamically based on Exchange properties.MongoDbConstants.DATABASE
,
MongoDbConstants.COLLECTION
public boolean isDynamicity()
public void setConsumerType(String consumerType) throws CamelMongoDbException
consumerType
- key of the consumer typeCamelMongoDbException
public MongoDbConsumerType getConsumerType()
public String getTailTrackDb()
public void setTailTrackDb(String tailTrackDb)
tailTrackDb
- database namepublic String getTailTrackCollection()
public void setTailTrackCollection(String tailTrackCollection)
MongoDbTailTrackingConfig.DEFAULT_COLLECTION
will be used by default.tailTrackCollection
- collection namepublic String getTailTrackField()
public void setTailTrackField(String tailTrackField)
MongoDbTailTrackingConfig.DEFAULT_FIELD
will be used by default.tailTrackField
- field namepublic void setPersistentTailTracking(boolean persistentTailTracking)
persistentTailTracking
- true or falsepublic boolean isPersistentTailTracking()
public void setTailTrackIncreasingField(String tailTrackIncreasingField)
tailTrackIncreasingField
- public String getTailTrackIncreasingField()
public MongoDbTailTrackingConfig getTailTrackingConfig()
public void setCursorRegenerationDelay(long cursorRegenerationDelay)
cursorRegenerationDelay
- delay specified in millisecondspublic long getCursorRegenerationDelay()
public void setPersistentId(String persistentId)
persistentId
- the value of the persistent ID to use for this tailable consumerpublic String getPersistentId()
public boolean isWriteResultAsHeader()
public void setWriteResultAsHeader(boolean writeResultAsHeader)
WriteResult
as the body of the OUT
message, we transfer the IN message to the OUT and attach the WriteResult as a header.writeResultAsHeader
- flag to indicate if this option is enabledpublic MongoDbOutputType getOutputType()
public void setOutputType(MongoDbOutputType outputType)
outputType
- public com.mongodb.client.MongoDatabase getMongoDatabase()
public com.mongodb.client.MongoCollection<com.mongodb.BasicDBObject> getMongoCollection()
Apache Camel