Class DataWareHouseBatchService

java.lang.Object
es.kukenan.smartfi.microservice.communication.service.batch.DataWareHouseBatchService

@Service public class DataWareHouseBatchService extends Object
Service that handles the scheduled execution of batch notification services.
  • Field Details

    • batchMessageRepository

      @Autowired private BatchMessageRepository batchMessageRepository
      Batch messages repository.
    • notificationSenderService

      @Autowired private NotificationSenderService notificationSenderService
      Notification sender service.
    • requestContextManager

      @Autowired private es.kukenan.smartfi.common.context.RequestContextManager requestContextManager
      Request context manager.
  • Constructor Details

    • DataWareHouseBatchService

      public DataWareHouseBatchService()
  • Method Details

    • findUnprocessedBatchMessages

      public Stream<BatchMessage> 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

      public void sendBatchMessage(BatchMessage batchMessage)
      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

      private void handleNotification(BatchMessage batchMessage, Notification notification)
      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

      private void handleUserNotificationsDisabled(BatchMessage batchMessage)
      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

      private void handleProcessError(BatchMessage batchMessage, Exception ex)
      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.