|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.camel.support.ServiceSupport
org.apache.camel.impl.DefaultEndpoint
org.apache.camel.component.mongodb.MongoDbEndpoint
public class MongoDbEndpoint
Represents a MongoDb endpoint.
It is responsible for creating MongoDbProducer
and MongoDbTailableCursorConsumer
instances.
It accepts a number of options to customise the behaviour of consumers and producers.
Field Summary |
---|
Fields inherited from class org.apache.camel.support.ServiceSupport |
---|
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending |
Constructor Summary | |
---|---|
MongoDbEndpoint()
|
|
MongoDbEndpoint(String endpointUri)
|
|
MongoDbEndpoint(String uri,
MongoDbComponent component)
|
Method Summary | |
---|---|
org.apache.camel.Consumer |
createConsumer(org.apache.camel.Processor processor)
|
List<com.mongodb.DBObject> |
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. |
void |
ensureIndex(com.mongodb.DBCollection collection,
List<com.mongodb.DBObject> dynamicIndex)
Add Index |
String |
getCollection()
|
String |
getCollectionIndex()
|
MongoDbConsumerType |
getConsumerType()
|
long |
getCursorRegenerationDelay()
|
String |
getDatabase()
|
com.mongodb.DB |
getDb()
|
com.mongodb.DBCollection |
getDbCollection()
|
com.mongodb.Mongo |
getMongoConnection()
|
MongoDbOperation |
getOperation()
|
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 |
isInvokeGetLastError()
|
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 |
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 |
setInvokeGetLastError(boolean invokeGetLastError)
Instructs this endpoint to invoke WriteResult.getLastError() with every operation. |
void |
setMongoConnection(com.mongodb.Mongo mongoConnection)
Sets the Mongo instance that represents the backing connection |
void |
setOperation(String operation)
Sets the operation this endpoint will execute against MongoDB. |
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. |
Methods inherited from class org.apache.camel.impl.DefaultEndpoint |
---|
configureConsumer, configurePollingConsumer, configureProperties, createEndpointConfiguration, createEndpointUri, createExchange, createExchange, createExchange, createPollingConsumer, doStop, equals, getCamelContext, getComponent, getConsumerProperties, getEndpointConfiguration, getEndpointKey, getEndpointUri, getExchangePattern, getId, hashCode, isLenientProperties, isSynchronous, setCamelContext, setConsumerProperties, setEndpointConfiguration, setEndpointUri, setEndpointUriIfNotSpecified, setExchangePattern, setProperties, setSynchronous, toString |
Methods inherited from class org.apache.camel.support.ServiceSupport |
---|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.camel.Service |
---|
start, stop |
Constructor Detail |
---|
public MongoDbEndpoint()
public MongoDbEndpoint(String uri, MongoDbComponent component)
public MongoDbEndpoint(String endpointUri)
Method Detail |
---|
public org.apache.camel.Producer createProducer() throws Exception
Exception
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.DBCollection collection, List<com.mongodb.DBObject> dynamicIndex)
collection
- public List<com.mongodb.DBObject> createIndex() throws Exception
Exception
protected void doStart() throws Exception
doStart
in class org.apache.camel.impl.DefaultEndpoint
Exception
public org.apache.camel.Exchange createMongoDbExchange(com.mongodb.DBObject dbObj)
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 values
CamelMongoDbException
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 com.mongodb.DB getDb()
public com.mongodb.DBCollection getDbCollection()
public void setMongoConnection(com.mongodb.Mongo mongoConnection)
mongoConnection
- the connection to the databasepublic com.mongodb.Mongo 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 setInvokeGetLastError(boolean invokeGetLastError)
WriteResult.getLastError()
with every operation. By default, MongoDB does not wait
for the write operation to occur before returning. If set to true, each exchange will only return after the write operation
has actually occurred in MongoDB.
invokeGetLastError
- true or falsepublic boolean isInvokeGetLastError()
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.
readPreference
- the bean 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 type
CamelMongoDbException
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 enabled
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |