Class DataWareHouseBatchService
java.lang.Object
es.kukenan.smartfi.microservice.communication.service.batch.DataWareHouseBatchService
Service that handles the scheduled execution of batch notification services.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BatchMessageRepositoryBatch messages repository.private NotificationSenderServiceNotification sender service.private es.kukenan.smartfi.common.context.RequestContextManagerRequest context manager. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet unprocessed batch messages as a stream.private voidhandleNotification(BatchMessage batchMessage, Notification notification) Handle the given notification generated by the given batch message.private voidhandleProcessError(BatchMessage batchMessage, Exception ex) Handle the case when a notification has generated due to errors during the process.private voidhandleUserNotificationsDisabled(BatchMessage batchMessage) Handle the case when a notification has not been generated by the given batch message (user notifications must be disabled).voidsendBatchMessage(BatchMessage batchMessage) Process a single batch message.
-
Field Details
-
batchMessageRepository
Batch messages repository. -
notificationSenderService
Notification sender service. -
requestContextManager
@Autowired private es.kukenan.smartfi.common.context.RequestContextManager requestContextManagerRequest context manager.
-
-
Constructor Details
-
DataWareHouseBatchService
public DataWareHouseBatchService()
-
-
Method Details
-
findUnprocessedBatchMessages
Get unprocessed batch messages as a stream. This method must be run inside a transaction or streaming may fail.- Returns:
- unprocessed batch messages as a stream.
-
sendBatchMessage
Process a single batch message. This method always starts a new transaction suspending previous one, if any, until finished.- Parameters:
batchMessage- the batch message to process.
-
handleNotification
Handle the given notification generated by the given batch message. That is, update the batch message entity in DB.- Parameters:
batchMessage- the batch message.notification- the notification entity generated.
-
handleUserNotificationsDisabled
Handle the case when a notification has not been generated by the given batch message (user notifications must be disabled). That is, update the batch message entity in DB.- Parameters:
batchMessage- the batch message.
-
handleProcessError
Handle the case when a notification has generated due to errors during the process. That is, update the batch message entity in DB.- Parameters:
batchMessage- the batch message.ex- the exception.
-