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)
RealTimeWriter
write
in interface RealTimeWriter<E>
input
- as Collection
of records to be written to sink.public E write(E record)
RealTimeWriter
write
in interface RealTimeWriter<E>
public Object transform(Object input)
transform
in interface org.apache.commons.collections.Transformer
public void setFailFast(boolean failFast)
FailFastAware
setFailFast
in interface FailFastAware
public boolean isFailFast()
FailFastAware
isFailFast
in interface FailFastAware
public Collection<Throwable> getExceptions()
FailFastAware
getExceptions
in interface FailFastAware
public void setExceptions(Collection<Throwable> exceptions)
setExceptions
in interface FailFastAware
public Collection<String> getMessages()
FailFastAware
getMessages
in interface FailFastAware
public void setMessages(Collection<String> messages)
setMessages
in interface FailFastAware
public org.springframework.transaction.TransactionDefinition getTransactionDef()
executeUnderTransaction
public void setTransactionDef(org.springframework.transaction.TransactionDefinition transactionDef)
executeUnderTransaction
public void close() throws Exception
RealTimeWriter
close
in interface RealTimeWriter<E>
Exception
public boolean isInitialized()
RealTimeWriter
isInitialized
in interface RealTimeWriter<E>
public boolean isExecuteUnderTransaction()
transactionDef
.
transactionDef
public void setExecuteUnderTransaction(boolean executeUnderTransaction)
transactionDef
.
transactionDef
Copyright © 2018. All rights reserved.