Class OutboxProcessor

java.lang.Object
com.avoka.fc.core.outbox.OutboxProcessor
All Implemented Interfaces:
IOutboxProcessor, IServiceDefinitionAware
Direct Known Subclasses:
MockOutboxProcessor

public class OutboxProcessor extends Object implements IOutboxProcessor, IServiceDefinitionAware
Provide an outbox processor to process outbox events
Since:
22.10.0
  • Constructor Details

    • OutboxProcessor

      public OutboxProcessor()
  • Method Details

    • getFetchLimit

      public int getFetchLimit()
      Return the fetch limit to limit the maximum number of events need to be processed.
      Returns:
      the fetch limit to limit the maximum number of events need to be processed
    • setFetchLimit

      public void setFetchLimit(int fetchLimit)
      Set the fetch limit to limit the maximum number of events need to be processed.
      Parameters:
      fetchLimit - the fetch limit to limit the maximum number of events need to be processed
    • getMaxRetry

      public int getMaxRetry()
      Return the number of retry to process an event it failed.
      Returns:
      the number of retry to process an event it failed
    • setMaxRetry

      public void setMaxRetry(int maxRetry)
      Set the number of retry to process an event it failed.
      Parameters:
      maxRetry - the number of retry to process an event it failed
    • getWaitForQueueTimeout

      public int getWaitForQueueTimeout()
      Return how long to wait for adding in processing event queue (in milliseconds)
      Returns:
      the timeout for adding in processing event queue (in milliseconds)
    • setWaitForQueueTimeout

      public void setWaitForQueueTimeout(int waitForQueueTimeout)
      Set how long to wait for adding in processing event queue (in milliseconds).
      Parameters:
      waitForQueueTimeout - the timeout for adding in processing event queue (in milliseconds)
    • getQueueTimeout

      public int getQueueTimeout()
      Return how long to wait in event queue to process (in minutes).
      Returns:
      the timeout to wait in event queue to process
    • setQueueTimeout

      public void setQueueTimeout(int queueTimeout)
      Set how long to wait in event queue to process (in minutes).
      Parameters:
      queueTimeout - the timeout to wait in event queue to process
    • getInProgressTimeout

      public int getInProgressTimeout()
      Return how long to wait to process (in minutes).
      Returns:
      the timeout to wait to process
    • setInProgressTimeout

      public void setInProgressTimeout(int inProgressTimeout)
      set how long to wait to process (in minutes).
      Parameters:
      inProgressTimeout - the timeout to wait to process
    • getServiceDefinition

      public ServiceDefinition getServiceDefinition()
      Return the service definition for the service.
      Specified by:
      getServiceDefinition in interface IServiceDefinitionAware
      Returns:
      the service definition for the service.
    • setServiceDefinition

      public void setServiceDefinition(ServiceDefinition serviceDefinition)
      Set the service definition for the service.
      Specified by:
      setServiceDefinition in interface IServiceDefinitionAware
      Parameters:
      serviceDefinition - the service definition for the service.
    • createProducer

      public IStreamProducer createProducer(ServiceConnection serviceConnection)
      return a producer to produce message
      Specified by:
      createProducer in interface IOutboxProcessor
      Parameters:
      serviceConnection - the serviceConnection
      Returns:
      an instance of IStreamProducer
    • raiseEvent

      public EventOutbox raiseEvent(ServiceConnection serviceConnection, String eventTopic, String payload, String eventDetails, String entityType, String entityId, UserAccount user)
      Create a new EventOutbox entity. This method doesn't include commit and caller should commit the change.
      Specified by:
      raiseEvent in interface IOutboxProcessor
      Parameters:
      serviceConnection - the serviceConnection for sending event
      eventTopic - the topic which event should be sent to
      payload - the payload which should be sent
      eventDetails - the event details
      entityType - the entity type related to this event
      entityId - the entity ID related to this event
      user - the user login name
      Returns:
      the created EventOutbox entity
    • sendOutboxEventsToProcess

      public void sendOutboxEventsToProcess()
      gets all events from event_outbox and send them to OutboxThread BlockingQueue
      Specified by:
      sendOutboxEventsToProcess in interface IOutboxProcessor
    • processOutboxEvent

      public void processOutboxEvent(Long eventId)
      look up the eventId in the outbox table and if found, process the event.
      Specified by:
      processOutboxEvent in interface IOutboxProcessor
      Parameters:
      eventId - and eventId
    • sendEventToQueue

      public void sendEventToQueue(EventOutbox eventOutbox)
      Send eventId to OutBoxThread BlockingQueue
      Parameters:
      eventOutbox - the eventOutbox