Package com.avoka.fc.core.outbox
Class OutboxProcessor
java.lang.Object
com.avoka.fc.core.outbox.OutboxProcessor
- All Implemented Interfaces:
IOutboxProcessor
,IServiceDefinitionAware
- Direct Known Subclasses:
MockOutboxProcessor
Provide an outbox processor to process outbox events
- Since:
- 22.10.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateProducer
(ServiceConnection serviceConnection) return a producer to produce messageint
Return the fetch limit to limit the maximum number of events need to be processed.int
Return how long to wait to process (in minutes).int
Return the number of retry to process an event it failed.int
Return how long to wait in event queue to process (in minutes).Return the service definition for the service.int
Return how long to wait for adding in processing event queue (in milliseconds)void
processOutboxEvent
(Long eventId) look up the eventId in the outbox table and if found, process the event.raiseEvent
(ServiceConnection serviceConnection, String eventTopic, String payload, String eventDetails, String entityType, String entityId, UserAccount user) Create a new EventOutbox entity.void
sendEventToQueue
(EventOutbox eventOutbox) Send eventId to OutBoxThread BlockingQueuevoid
gets all events from event_outbox and send them to OutboxThread BlockingQueuevoid
setFetchLimit
(int fetchLimit) Set the fetch limit to limit the maximum number of events need to be processed.void
setInProgressTimeout
(int inProgressTimeout) set how long to wait to process (in minutes).void
setMaxRetry
(int maxRetry) Set the number of retry to process an event it failed.void
setQueueTimeout
(int queueTimeout) Set how long to wait in event queue to process (in minutes).void
setServiceDefinition
(ServiceDefinition serviceDefinition) Set the service definition for the service.void
setWaitForQueueTimeout
(int waitForQueueTimeout) Set how long to wait for adding in processing event queue (in milliseconds).
-
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
Return the service definition for the service.- Specified by:
getServiceDefinition
in interfaceIServiceDefinitionAware
- Returns:
- the service definition for the service.
-
setServiceDefinition
Set the service definition for the service.- Specified by:
setServiceDefinition
in interfaceIServiceDefinitionAware
- Parameters:
serviceDefinition
- the service definition for the service.
-
createProducer
return a producer to produce message- Specified by:
createProducer
in interfaceIOutboxProcessor
- 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 interfaceIOutboxProcessor
- Parameters:
serviceConnection
- the serviceConnection for sending eventeventTopic
- the topic which event should be sent topayload
- the payload which should be senteventDetails
- the event detailsentityType
- the entity type related to this evententityId
- the entity ID related to this eventuser
- 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 interfaceIOutboxProcessor
-
processOutboxEvent
look up the eventId in the outbox table and if found, process the event.- Specified by:
processOutboxEvent
in interfaceIOutboxProcessor
- Parameters:
eventId
- and eventId
-
sendEventToQueue
Send eventId to OutBoxThread BlockingQueue- Parameters:
eventOutbox
- the eventOutbox
-