public class MongoDbSender extends StreamingSenderBase implements HasPhysicalDestination
database
, collection Collection to act upon. Overrides attribute collection
, filter Filter. Can contain references to parameters between '?{' and '}'. Overrides attribute filter
, limit Limit to number of results returned. A value of 0 means 'no limit'. Overrides attribute limit
Modifier and Type | Class and Description |
---|---|
static class |
MongoDbSender.MongoAction |
Modifier and Type | Field and Description |
---|---|
static String |
NAMED_PARAM_END |
static String |
NAMED_PARAM_START |
static String |
PARAM_COLLECTION |
static String |
PARAM_DATABASE |
static String |
PARAM_FILTER |
static String |
PARAM_LIMIT |
parameterNamesMustBeUnique, paramList
log
Constructor and Description |
---|
MongoDbSender() |
Modifier and Type | Method and Description |
---|---|
protected void |
addOptionalValue(ObjectBuilder builder,
String name,
org.bson.BsonValue bsonValue) |
void |
close()
Stop/close the sender and deallocate resources.
|
void |
configure()
configure() is called once at startup of the framework in the configure method of the owner of this sender. |
protected com.mongodb.client.MongoCollection<org.bson.Document> |
getCollection(com.mongodb.client.MongoDatabase mongoDatabase,
ParameterValueList pvl) |
protected com.mongodb.client.MongoDatabase |
getDatabase(ParameterValueList pvl) |
protected org.bson.Document |
getDocument(Message message) |
protected org.bson.Document |
getDocument(String message) |
protected List<org.bson.Document> |
getDocuments(Message message) |
protected org.bson.Document |
getFilter(ParameterValueList pvl,
Message message) |
protected int |
getLimit(ParameterValueList pvl) |
String |
getPhysicalDestinationName() |
void |
open()
This method will be called to start the sender.
|
MessageOutputStream |
provideOutputStream(PipeLineSession session,
IForwardTarget next)
return a
MessageOutputStream that can be used to write a message to, that then will be processed in a streaming way. |
protected void |
renderResult(com.mongodb.client.result.DeleteResult deleteResult,
MessageOutputStream target) |
protected void |
renderResult(org.bson.Document findResult,
MessageOutputStream target) |
protected void |
renderResult(com.mongodb.client.FindIterable<org.bson.Document> findResults,
MessageOutputStream target) |
protected void |
renderResult(com.mongodb.client.result.InsertManyResult insertManyResult,
MessageOutputStream target) |
protected void |
renderResult(com.mongodb.client.result.InsertOneResult insertOneResult,
MessageOutputStream target) |
protected void |
renderResult(com.mongodb.client.result.UpdateResult updateResult,
MessageOutputStream target) |
PipeRunResult |
sendMessage(Message message,
PipeLineSession session,
IForwardTarget next) |
void |
setAction(MongoDbSender.MongoAction action)
Action
|
void |
setCollection(String collection)
Collection to act upon.
|
void |
setCountOnly(boolean countOnly)
Only for find operation: return only the count and not the full document(s)
|
void |
setDatabase(String database)
Database to connect to.
|
void |
setDatasourceName(String datasourceName)
The MongoDB datasource
|
void |
setFilter(String filter)
Filter.
|
void |
setLimit(int limit)
Limit to number of results returned.
|
void |
setOutputFormat(DocumentFormat outputFormat)
OutputFormat
|
void |
setPrettyPrint(boolean prettyPrint)
Format the output in easy legible way (currently only for XML)
|
canProvideOutputStream, sendMessage, supportsOutputStreamPassThrough
addParameter, checkStringAttributeOrParameter, consumesSessionVariable, getParameterList, getParameterOverriddenAttributeValue, getParameterOverriddenAttributeValue, getParameterValueList
createBean, getLogPrefix, getName, setApplicationContext, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDomain
consumesSessionVariable
isSynchronous, sendMessageOrThrow
getName, setName
getApplicationContext, getName
getConfigurationClassLoader
setApplicationContext
addParameter, getParameterList
public static final String PARAM_DATABASE
public static final String PARAM_COLLECTION
public static final String PARAM_FILTER
public static final String PARAM_LIMIT
public static final String NAMED_PARAM_START
public static final String NAMED_PARAM_END
public void configure() throws ConfigurationException
ISender
configure()
is called once at startup of the framework in the configure method of the owner of this sender.
Purpose of this method is to check whether the static configuration of the sender is correct.
As much as possible class-instantiating should take place in the configure()
or open()
method, to improve performance.configure
in interface IConfigurable
configure
in interface ISender
configure
in class StreamingSenderBase
ConfigurationException
public void open() throws SenderException
ISender
sendMessage()
method.open
in interface ISender
open
in class SenderBase
SenderException
public void close() throws SenderException
ISender
close
in interface ISender
close
in class SenderBase
SenderException
public MessageOutputStream provideOutputStream(PipeLineSession session, IForwardTarget next) throws StreamingException
IOutputStreamingSupport
MessageOutputStream
that can be used to write a message to, that then will be processed in a streaming way.
If a target MessageOutputStream is required to stream output to, this can be obtained from next
, if specified.
If the implementor of this method is a pipe, and it is the last one in the chain of streaming pipes, it must provide the appropriate
forward in the provide MessageOutputStream.
If the class cannot provide an outputstream, it must return null.
If the provider of an outputstream is a pipe itself, it must provide a proper pipeforward in the provided outputstreamprovideOutputStream
in interface IOutputStreamingSupport
StreamingException
public PipeRunResult sendMessage(Message message, PipeLineSession session, IForwardTarget next) throws SenderException, TimeoutException
sendMessage
in interface IStreamingSender
SenderException
TimeoutException
protected void renderResult(com.mongodb.client.result.InsertOneResult insertOneResult, MessageOutputStream target) throws SAXException, StreamingException
SAXException
StreamingException
protected void renderResult(com.mongodb.client.result.InsertManyResult insertManyResult, MessageOutputStream target) throws SAXException, StreamingException
SAXException
StreamingException
protected void renderResult(org.bson.Document findResult, MessageOutputStream target) throws StreamingException
StreamingException
protected void renderResult(com.mongodb.client.FindIterable<org.bson.Document> findResults, MessageOutputStream target) throws StreamingException
StreamingException
protected void renderResult(com.mongodb.client.result.UpdateResult updateResult, MessageOutputStream target) throws SAXException, StreamingException
SAXException
StreamingException
protected void renderResult(com.mongodb.client.result.DeleteResult deleteResult, MessageOutputStream target) throws SAXException, StreamingException
SAXException
StreamingException
protected void addOptionalValue(ObjectBuilder builder, String name, org.bson.BsonValue bsonValue) throws SAXException
SAXException
protected org.bson.Document getDocument(Message message) throws IOException
IOException
protected org.bson.Document getDocument(String message)
protected List<org.bson.Document> getDocuments(Message message) throws IOException
IOException
protected com.mongodb.client.MongoDatabase getDatabase(ParameterValueList pvl) throws SenderException
SenderException
protected com.mongodb.client.MongoCollection<org.bson.Document> getCollection(com.mongodb.client.MongoDatabase mongoDatabase, ParameterValueList pvl) throws SenderException
SenderException
protected org.bson.Document getFilter(ParameterValueList pvl, Message message) throws IOException, ParameterException, IllegalArgumentException
protected int getLimit(ParameterValueList pvl)
public String getPhysicalDestinationName()
getPhysicalDestinationName
in interface HasPhysicalDestination
public void setDatasourceName(String datasourceName)
public void setDatabase(String database)
public void setCollection(String collection)
public void setAction(MongoDbSender.MongoAction action)
public void setFilter(String filter)
public void setLimit(int limit)
public void setCountOnly(boolean countOnly)
public void setOutputFormat(DocumentFormat outputFormat)
public void setPrettyPrint(boolean prettyPrint)
Copyright © 2023 Frank!Framework. All rights reserved.