@EventDriven @InputRequirement(value=INPUT_REQUIRED) @Tags(value={"sql","record","jdbc","put","database","update","insert","delete"}) @CapabilityDescription(value="The PutDatabaseRecord processor uses a specified RecordReader to input (possibly multiple) records from an incoming flow file. These records are translated to SQL statements and executed as a single batch. If any errors occur, the flow file is routed to failure or retry, and if the records are transmitted successfully, the incoming flow file is routed to success. The type of statement executed by the processor is specified via the Statement Type property, which accepts some hard-coded values such as INSERT, UPDATE, and DELETE, as well as \'Use statement.type Attribute\', which causes the processor to get the statement type from a flow file attribute. IMPORTANT: If the Statement Type is UPDATE, then the incoming records must not alter the value(s) of the primary keys (or user-specified Update Keys). If such records are encountered, the UPDATE statement issued to the database may do nothing (if no existing records with the new primary key values are found), or could inadvertently corrupt the existing data (by changing records for which the new values of the primary keys exist).") @ReadsAttribute(attribute="statement.type", description="If \'Use statement.type Attribute\' is selected for the Statement Type property, the value of this attribute will be used to determine the type of statement (INSERT, UPDATE, DELETE, SQL, etc.) to generate and execute.") @WritesAttribute(attribute="putdatabaserecord.error", description="If an error occurs during processing, the flow file will be routed to failure or retry, and this attribute will be populated with the cause of the error.") public class PutDatabaseRecord extends AbstractSessionFactoryProcessor
Modifier and Type | Class and Description |
---|---|
protected static class |
PutDatabaseRecord.ColumnDescription |
Modifier and Type | Field and Description |
---|---|
protected static java.util.List<PropertyDescriptor> |
propDescriptors |
static Relationship |
REL_SUCCESS |
protected static java.util.Set<Relationship> |
relationships |
Constructor and Description |
---|
PutDatabaseRecord() |
Modifier and Type | Method and Description |
---|---|
java.util.Set<Relationship> |
getRelationships() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(java.lang.String propertyDescriptorName)
Used to allow subclasses to determine what PropertyDescriptor if any to
use when a property is requested for which a descriptor is not already
registered.
|
protected java.util.List<PropertyDescriptor> |
getSupportedPropertyDescriptors()
Allows subclasses to register which property descriptor objects are
supported.
|
void |
onScheduled(ProcessContext context) |
void |
onTrigger(ProcessContext context,
ProcessSessionFactory sessionFactory)
The method called when this processor is triggered to operate by the
controller.
|
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue
customValidate, equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
public static final Relationship REL_SUCCESS
protected static java.util.Set<Relationship> relationships
protected static java.util.List<PropertyDescriptor> propDescriptors
public java.util.Set<Relationship> getRelationships()
getRelationships
in interface Processor
getRelationships
in class AbstractSessionFactoryProcessor
protected java.util.List<PropertyDescriptor> getSupportedPropertyDescriptors()
AbstractConfigurableComponent
getSupportedPropertyDescriptors
in class AbstractConfigurableComponent
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(java.lang.String propertyDescriptorName)
AbstractConfigurableComponent
Used to allow subclasses to determine what PropertyDescriptor if any to use when a property is requested for which a descriptor is not already registered. By default this method simply returns a null descriptor. By overriding this method processor implementations can support dynamic properties since this allows them to register properties on demand. It is acceptable for a dynamically generated property to indicate it is required so long as it is understood it is only required once set. Dynamic properties by definition cannot be required until used.
This method should be side effect free in the subclasses in terms of how often it is called for a given property name because there is guarantees how often it will be called for a given property name.
Default is null.
getSupportedDynamicPropertyDescriptor
in class AbstractConfigurableComponent
propertyDescriptorName
- used to lookup if any property descriptors exist for that name@OnScheduled public void onScheduled(ProcessContext context)
public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException
Processor
The method called when this processor is triggered to operate by the
controller. In the absence of the TriggerSerially
annotation,
this method may be called concurrently from different threads.
When this method is called depends on how this processor is
configured within a controller to be triggered (timing or event
based).
context
- provides access to convenience methods for obtaining
property values, delaying the scheduling of the processor, provides
access to Controller Services, etc.sessionFactory
- provides access to a ProcessSession
, which
can be used for accessing FlowFiles, etc.ProcessException
- if processing did not complete normally though
indicates the problem is an understood potential outcome of processing.
The controller/caller will handle these exceptions gracefully such as
logging, etc.. If another type of exception is allowed to propagate the
controller may no longer trigger this processor to operate, as this would
indicate a probable coding defect.