-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dependent `Handlers` will change from request to application scope
- Loading branch information
1 parent
aba72e4
commit cfdb2d5
Showing
19 changed files
with
130 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 58 additions & 2 deletions
60
...core/src/main/java/com/github/jonasrutishauser/transactional/event/core/store/Worker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,63 @@ | ||
package com.github.jonasrutishauser.transactional.event.core.store; | ||
|
||
interface Worker { | ||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.enterprise.context.control.ActivateRequestContext; | ||
import jakarta.enterprise.event.Event; | ||
import jakarta.inject.Inject; | ||
|
||
boolean process(String eventId); | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.eclipse.microprofile.metrics.annotation.ConcurrentGauge; | ||
|
||
import com.github.jonasrutishauser.transactional.event.api.monitoring.ProcessingFailedEvent; | ||
import com.github.jonasrutishauser.transactional.event.api.monitoring.ProcessingSuccessEvent; | ||
|
||
@Dependent | ||
class Worker { | ||
|
||
private static final Logger LOGGER = LogManager.getLogger(); | ||
|
||
private final TransactionalWorker transactional; | ||
|
||
private final Event<ProcessingSuccessEvent> processingSuccessEvent; | ||
private final Event<ProcessingFailedEvent> processingFailedEvent; | ||
|
||
@Inject | ||
Worker(TransactionalWorker transactional, Event<ProcessingSuccessEvent> processingSuccessEvent, | ||
Event<ProcessingFailedEvent> processingFailedEvent) { | ||
this.transactional = transactional; | ||
this.processingSuccessEvent = processingSuccessEvent; | ||
this.processingFailedEvent = processingFailedEvent; | ||
} | ||
|
||
@ActivateRequestContext | ||
@ConcurrentGauge(name = "com.github.jonasrutishauser.transaction.event.processing", | ||
description = "number of events in processing", absolute = true) | ||
public boolean process(String eventId) { | ||
try { | ||
processAttempt(eventId); | ||
transactional.process(eventId); | ||
processSuccess(eventId); | ||
return true; | ||
} catch (Exception e) { | ||
processAttemptFailed(eventId, e); | ||
transactional.processFailed(eventId); | ||
return false; | ||
} | ||
} | ||
|
||
private void processAttemptFailed(String eventId, Exception e) { | ||
processingFailedEvent.fire(new ProcessingFailedEvent(eventId, e)); | ||
LOGGER.warn("Failed to process event with id '{}'", eventId, e); | ||
} | ||
|
||
protected void processSuccess(String eventId) { | ||
processingSuccessEvent.fire(new ProcessingSuccessEvent(eventId)); | ||
LOGGER.debug("sucessfully processed event with id '{}'", eventId); | ||
} | ||
|
||
protected void processAttempt(String eventId) { | ||
LOGGER.debug("processing event with id '{}'", eventId); | ||
} | ||
|
||
} |
63 changes: 0 additions & 63 deletions
63
.../src/main/java/com/github/jonasrutishauser/transactional/event/core/store/WorkerImpl.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.