Package org.frankframework.mongodb
Class MongoDbSender
java.lang.Object
org.frankframework.senders.AbstractSender
org.frankframework.senders.AbstractSenderWithParameters
org.frankframework.mongodb.MongoDbSender
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasPhysicalDestination,IConfigurable,IScopeProvider,ISender,ISenderWithParameters,IWithParameters,NameAware,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle
@DestinationType(MONGODB)
public class MongoDbSender
extends AbstractSenderWithParameters
implements HasPhysicalDestination
Sender to perform action on a MongoDB database.
- Author:
- Gerrit van Brakel
- Specific parameters
- database Database to connect to. Overrides attribute
database, collection Collection to act upon. Overrides attributecollection, filter Filter. Can contain references to parameters between '?{' and '}'. Overrides attributefilter, limit Limit to number of results returned. A value of 0 means 'no limit'. Overrides attributelimit
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.frankframework.senders.AbstractSenderWithParameters
parameterNamesMustBeUnique, paramListFields inherited from class org.frankframework.senders.AbstractSender
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddOptionalValue(ObjectBuilder builder, String name, org.bson.BsonValue bsonValue) voidConfigure this component.protected com.mongodb.client.MongoCollection<org.bson.Document> getCollection(com.mongodb.client.MongoDatabase mongoDatabase, ParameterValueList pvl) protected com.mongodb.client.MongoDatabaseprotected org.bson.DocumentgetDocument(String message) protected org.bson.DocumentgetDocument(Message message) protected List<org.bson.Document> getDocuments(Message message) protected org.bson.DocumentgetFilter(ParameterValueList pvl, Message message) protected intprotected voidrenderResult(com.mongodb.client.FindIterable<org.bson.Document> findResults, MessageBuilder messageBuilder) protected voidrenderResult(com.mongodb.client.result.DeleteResult deleteResult, MessageBuilder messageBuilder) protected voidrenderResult(com.mongodb.client.result.InsertManyResult insertManyResult, MessageBuilder messageBuilder) protected voidrenderResult(com.mongodb.client.result.InsertOneResult insertOneResult, MessageBuilder messageBuilder) protected voidrenderResult(com.mongodb.client.result.UpdateResult updateResult, MessageBuilder messageBuilder) protected voidrenderResult(org.bson.Document findResult, MessageBuilder messageBuilder) sendMessage(Message message, PipeLineSession session) Send a message to some destination (as configured in the Sender object).voidsetAction(MongoDbSender.MongoAction action) ActionvoidsetCollection(String collection) Collection to act upon.voidsetCountOnly(boolean countOnly) Only for find operation: return only the count and not the full document(s)voidsetDatabase(String database) Database to connect to.voidsetDatasourceName(String datasourceName) The MongoDB datasourcevoidFilter.voidsetLimit(int limit) Limit to number of results returned.voidsetOutputFormat(DocumentFormat outputFormat) OutputFormatvoidsetPrettyPrint(boolean prettyPrint) Format the output in easy legible way (currently only for XML)voidstart()This method will be called to start the sender.voidstop()Stop/close the sender and deallocate resources.Methods inherited from class org.frankframework.senders.AbstractSenderWithParameters
addParameter, checkStringAttributeOrParameter, consumesSessionVariable, getParameterList, getParameterOverriddenAttributeValue, getParameterOverriddenAttributeValue, getParameterValueListMethods inherited from class org.frankframework.senders.AbstractSender
createBean, getLogPrefix, getName, isRunning, setApplicationContext, setNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.ISender
isSynchronous, sendMessageOrThrow
-
Field Details
-
PARAM_DATABASE
- See Also:
-
PARAM_COLLECTION
- See Also:
-
PARAM_FILTER
- See Also:
-
PARAM_LIMIT
- See Also:
-
NAMED_PARAM_START
- See Also:
-
NAMED_PARAM_END
- See Also:
-
-
Constructor Details
-
MongoDbSender
public MongoDbSender()
-
-
Method Details
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classAbstractSenderWithParameters- Throws:
ConfigurationException- in case it was not able to configure the component.
-
start
public void start()Description copied from interface:ISenderThis method will be called to start the sender. After this method is called the sendMessage method may be called. Purpose of this method is to reduce creating connections to databases etc. in thesendMessage()method.- Specified by:
startin interfaceISender- Specified by:
startin interfaceorg.springframework.context.Lifecycle- Overrides:
startin classAbstractSender
-
stop
public void stop()Description copied from interface:ISenderStop/close the sender and deallocate resources.- Specified by:
stopin interfaceISender- Specified by:
stopin interfaceorg.springframework.context.Lifecycle- Overrides:
stopin classAbstractSender
-
sendMessage
@Nonnull public SenderResult sendMessage(@Nonnull Message message, @Nonnull PipeLineSession session) throws SenderException, TimeoutException Description copied from interface:ISenderSend a message to some destination (as configured in the Sender object). This method may only be called after theconfigure()method is called.The following table shows the difference between synchronous and a-synchronous senders:
synchronous a-synchronous ISender.isSynchronous()returnstruefalsereturn value of sendMessage()isthe reply-message the messageId of the message sent the correlationID specified with sendMessage()may be ignored is sent with the message a {link TimeOutException} may be thrown if a timeout occurs waiting for a reply should not be expected Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, or
synchronized.- Specified by:
sendMessagein interfaceISender- Throws:
SenderExceptionTimeoutException
-
renderResult
protected void renderResult(com.mongodb.client.result.InsertOneResult insertOneResult, MessageBuilder messageBuilder) throws SAXException - Throws:
SAXException
-
renderResult
protected void renderResult(com.mongodb.client.result.InsertManyResult insertManyResult, MessageBuilder messageBuilder) throws SAXException - Throws:
SAXException
-
renderResult
protected void renderResult(org.bson.Document findResult, MessageBuilder messageBuilder) throws SAXException - Throws:
SAXException
-
renderResult
protected void renderResult(com.mongodb.client.FindIterable<org.bson.Document> findResults, MessageBuilder messageBuilder) throws IOException, SAXException - Throws:
IOExceptionSAXException
-
renderResult
protected void renderResult(com.mongodb.client.result.UpdateResult updateResult, MessageBuilder messageBuilder) throws SAXException - Throws:
SAXException
-
renderResult
protected void renderResult(com.mongodb.client.result.DeleteResult deleteResult, MessageBuilder messageBuilder) throws SAXException - Throws:
SAXException
-
addOptionalValue
protected void addOptionalValue(ObjectBuilder builder, String name, org.bson.BsonValue bsonValue) throws SAXException - Throws:
SAXException
-
getDocument
- Throws:
IOException
-
getDocument
-
getDocuments
- Throws:
IOException
-
getDatabase
protected com.mongodb.client.MongoDatabase getDatabase(ParameterValueList pvl) throws SenderException - Throws:
SenderException
-
getCollection
protected com.mongodb.client.MongoCollection<org.bson.Document> getCollection(com.mongodb.client.MongoDatabase mongoDatabase, ParameterValueList pvl) throws SenderException - Throws:
SenderException
-
getFilter
protected org.bson.Document getFilter(ParameterValueList pvl, Message message) throws IOException, IllegalArgumentException - Throws:
IOExceptionIllegalArgumentException
-
getLimit
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationNamein interfaceHasPhysicalDestination
-
setDatasourceName
The MongoDB datasource- Default value
- "mongodb.datasource.default"
-
setDatabase
Database to connect to. Can be overridden by parameter "database" -
setCollection
Collection to act upon. Can be overridden by parameter "collection" -
setAction
Action -
setFilter
-
setLimit
public void setLimit(int limit) Limit to number of results returned. A value of 0 means 'no limit'. Can be overridden by parameter "limit".- Default value
- 0
-
setCountOnly
public void setCountOnly(boolean countOnly) Only for find operation: return only the count and not the full document(s)- Default value
- false
-
setOutputFormat
OutputFormat- Default value
- JSON
-
setPrettyPrint
public void setPrettyPrint(boolean prettyPrint) Format the output in easy legible way (currently only for XML)
-