@UriEndpoint(firstVersion="2.19.0",
scheme="mongodb",
title="MongoDB",
syntax="mongodb:connectionBean",
category={DATABASE,NOSQL})
public class MongoDbEndpoint
extends org.apache.camel.support.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<org.bson.conversions.Bson> |
createIndex()
Create technical list index
|
org.apache.camel.Exchange |
createMongoDbExchange(org.bson.Document dbObj) |
org.apache.camel.Producer |
createProducer() |
protected void |
doStart() |
void |
ensureIndex(com.mongodb.client.MongoCollection<org.bson.Document> aCollection,
List<org.bson.conversions.Bson> dynamicIndex)
Add Index
|
String |
getCollection() |
String |
getCollectionIndex() |
String |
getConnectionBean() |
String |
getConsumerType() |
long |
getCursorRegenerationDelay() |
String |
getDatabase() |
MongoDbConsumerType |
getDbConsumerType() |
com.mongodb.client.MongoCollection<org.bson.Document> |
getMongoCollection() |
com.mongodb.client.MongoClient |
getMongoConnection() |
com.mongodb.client.MongoDatabase |
getMongoDatabase() |
MongoDbOperation |
getOperation() |
MongoDbOutputType |
getOutputType() |
String |
getPersistentId() |
String |
getReadPreference() |
com.mongodb.ReadPreference |
getReadPreferenceBean() |
String |
getStreamFilter() |
String |
getTailTrackCollection() |
String |
getTailTrackDb() |
String |
getTailTrackField() |
String |
getTailTrackIncreasingField() |
MongoDbTailTrackingConfig |
getTailTrackingConfig() |
String |
getWriteConcern() |
com.mongodb.WriteConcern |
getWriteConcernBean() |
void |
initializeConnection()
Initialises the MongoDB connection using the Mongo object provided to the endpoint
|
boolean |
isCreateCollection() |
boolean |
isDynamicity() |
boolean |
isPersistentTailTracking() |
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
MongoClient to use. |
void |
setConsumerType(String consumerType)
Consumer type.
|
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 |
setDbConsumerType(String dbConsumerType)
Reserved for future use, when more consumer types are supported.
|
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.client.MongoClient mongoConnection)
Sets the Mongo instance that represents the backing connection
|
void |
setOperation(MongoDbOperation operation)
Sets the operation this endpoint will execute against MongoDB.
|
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 : DocumentList Document or MongoIterable.
|
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)
Configure how MongoDB clients route read operations to the members of a replica set.
|
void |
setStreamFilter(String streamFilter)
Filter condition for change streams consumer.
|
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)
Configure the connection bean with the level of acknowledgment requested
from MongoDB for write operations to a standalone mongod, replicaset or cluster.
|
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, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, doStop, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isBasicPropertyBinding, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isSingleton, isSynchronous, setBasicPropertyBinding, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, toString
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public MongoDbEndpoint()
public MongoDbEndpoint(String uri, MongoDbComponent component)
public org.apache.camel.Producer createProducer()
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
Exception
public void initializeConnection() throws CamelMongoDbException
CamelMongoDbException
public void ensureIndex(com.mongodb.client.MongoCollection<org.bson.Document> aCollection, List<org.bson.conversions.Bson> dynamicIndex)
aCollection
- public List<org.bson.conversions.Bson> createIndex()
public org.apache.camel.Exchange createMongoDbExchange(org.bson.Document dbObj)
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.DefaultEndpoint
Exception
public String getConnectionBean()
public void setConnectionBean(String connectionBean)
MongoClient
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
CamelMongoDbException
public void setOperation(MongoDbOperation operation)
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.client.MongoClient mongoConnection)
mongoConnection
- the connection to the databasepublic com.mongodb.client.MongoClient getMongoConnection()
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 setDbConsumerType(String dbConsumerType) throws CamelMongoDbException
dbConsumerType
- key of the consumer typeCamelMongoDbException
- if consumer type is not supportedpublic MongoDbConsumerType getDbConsumerType()
public String getConsumerType()
public void setConsumerType(String consumerType)
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)
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<org.bson.Document> getMongoCollection()
public String getStreamFilter()
public void setStreamFilter(String streamFilter)
public void setWriteConcern(String writeConcern)
writeConcern
- public String getWriteConcern()
public com.mongodb.WriteConcern getWriteConcernBean()
public void setReadPreference(String readPreference)
readPreference
- public String getReadPreference()
public com.mongodb.ReadPreference getReadPreferenceBean()
Apache Camel