@UriEndpoint(firstVersion="2.19.0",
scheme="mongodb",
title="MongoDB",
syntax="mongodb:connectionBean",
label="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.MongoClient |
getMongoConnection() |
com.mongodb.client.MongoDatabase |
getMongoDatabase() |
MongoDbOperation |
getOperation() |
MongoDbOutputType |
getOutputType() |
String |
getPersistentId() |
com.mongodb.ReadPreference |
getReadPreference() |
String |
getStreamFilter() |
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 |
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)
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.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 |
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 |
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, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, doStop, equals, getCamelContext, getComponent, getConsumerProperties, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isBasicPropertyBinding, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isSingleton, isSynchronous, setBasicPropertyBinding, setBridgeErrorHandler, setCamelContext, setConsumerProperties, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, toString
doResume, doShutdown, doSuspend, getStatus, init, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
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)
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
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.MongoClient mongoConnection)
mongoConnection
- the connection to the databasepublic com.mongodb.MongoClient getMongoConnection()
public 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.writeConcernRef
- the name of the bean in the registry that
represents the WriteConcern to usepublic com.mongodb.WriteConcern getWriteConcernRef()
public 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 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)
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<org.bson.Document> getMongoCollection()
public String getStreamFilter()
public void setStreamFilter(String streamFilter)
Apache Camel