E - of Entity typepublic class EntityPersistTransformer<E> extends Object implements org.apache.commons.collections.Transformer, RealTimeWriter<E>, FailFastAware
EntityManager.Transformer is capable of:
exceptions and messages if failFast is falseTransactionDefinition, if provided via setTransactionDef(TransactionDefinition). It uses the autowired PlatformTransactionManager for thisRealTimeWriter,
FailFastAware| Modifier and Type | Field and Description |
|---|---|
protected javax.persistence.EntityManager |
em |
protected Collection<Throwable> |
exceptions |
protected boolean |
failFast |
protected Collection<String> |
messages |
protected org.springframework.transaction.PlatformTransactionManager |
tm |
| Constructor and Description |
|---|
EntityPersistTransformer() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Any cleanup
|
Collection<Throwable> |
getExceptions()
If not in fail fast mode, will collect the exceptions and we can always query the exceptions
|
Collection<String> |
getMessages()
Any updates/messages that are not Error like
|
org.springframework.transaction.TransactionDefinition |
getTransactionDef() |
protected E |
handleException(RuntimeException e) |
void |
init() |
boolean |
isExecuteUnderTransaction()
If true, will execute persist under 1 transaction and will apply
transactionDef. |
boolean |
isFailFast()
If true will exit on first exception else will collect exceptions
|
boolean |
isInitialized()
Check if Writer is already Initialized
|
void |
setExceptions(Collection<Throwable> exceptions) |
void |
setExecuteUnderTransaction(boolean executeUnderTransaction)
If true, will execute persist under 1 transaction and will apply
transactionDef. |
void |
setFailFast(boolean failFast)
If true will exit on first exception else will collect exceptions
|
void |
setMessages(Collection<String> messages) |
void |
setTransactionDef(org.springframework.transaction.TransactionDefinition transactionDef) |
Object |
transform(Object input) |
Collection<E> |
write(Collection<E> input)
Write a Buffer of records at a given time.
|
E |
write(E record)
Write a record
|
protected boolean failFast
protected Collection<Throwable> exceptions
protected Collection<String> messages
@Autowired protected org.springframework.transaction.PlatformTransactionManager tm
protected javax.persistence.EntityManager em
public void init()
protected E handleException(RuntimeException e)
public Collection<E> write(Collection<E> input)
RealTimeWriterwrite in interface RealTimeWriter<E>input - as Collection of records to be written to sink.public E write(E record)
RealTimeWriterwrite in interface RealTimeWriter<E>public Object transform(Object input)
transform in interface org.apache.commons.collections.Transformerpublic void setFailFast(boolean failFast)
FailFastAwaresetFailFast in interface FailFastAwarepublic boolean isFailFast()
FailFastAwareisFailFast in interface FailFastAwarepublic Collection<Throwable> getExceptions()
FailFastAwaregetExceptions in interface FailFastAwarepublic void setExceptions(Collection<Throwable> exceptions)
setExceptions in interface FailFastAwarepublic Collection<String> getMessages()
FailFastAwaregetMessages in interface FailFastAwarepublic void setMessages(Collection<String> messages)
setMessages in interface FailFastAwarepublic org.springframework.transaction.TransactionDefinition getTransactionDef()
executeUnderTransactionpublic void setTransactionDef(org.springframework.transaction.TransactionDefinition transactionDef)
executeUnderTransactionpublic void close()
throws Exception
RealTimeWriterclose in interface RealTimeWriter<E>Exceptionpublic boolean isInitialized()
RealTimeWriterisInitialized in interface RealTimeWriter<E>public boolean isExecuteUnderTransaction()
transactionDef.
transactionDefpublic void setExecuteUnderTransaction(boolean executeUnderTransaction)
transactionDef.
transactionDefCopyright © 2018. All rights reserved.