forked from folio-org/mod-entities-links
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(authority-source-files): produce authority source file update ev…
…ent (folio-org#271) * feat(authority-source-files): produce domain event - Add Kafka topic for authority source files updating - Add publisher for new topic Closes: MODELINKS-202
- Loading branch information
1 parent
949fe95
commit f51aa0c
Showing
17 changed files
with
321 additions
and
51 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
37 changes: 37 additions & 0 deletions
37
...in/java/org/folio/entlinks/service/authority/AuthoritySourceFileDomainEventPublisher.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.folio.entlinks.service.authority; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.folio.entlinks.domain.dto.AuthoritySourceFileDto; | ||
import org.folio.entlinks.integration.dto.event.DomainEvent; | ||
import org.folio.entlinks.integration.dto.event.DomainEventType; | ||
import org.folio.entlinks.integration.kafka.EventProducer; | ||
import org.folio.spring.FolioExecutionContext; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Log4j2 | ||
public class AuthoritySourceFileDomainEventPublisher { | ||
private static final String DOMAIN_EVENT_TYPE_HEADER = "domain-event-type"; | ||
|
||
@Qualifier("authoritySourceFileDomainMessageProducer") | ||
private final EventProducer<DomainEvent<?>> eventProducer; | ||
private final FolioExecutionContext folioExecutionContext; | ||
|
||
public void publishUpdateEvent(AuthoritySourceFileDto oldAsfDto, AuthoritySourceFileDto updatedAsfDto) { | ||
var id = updatedAsfDto.getId(); | ||
if (id == null || oldAsfDto.getId() == null) { | ||
log.warn("Old/New Authority Source File cannot have null id: updated.id - {}, old.id: {}", | ||
id, oldAsfDto.getId()); | ||
return; | ||
} | ||
|
||
log.debug("publishUpdated::process authority source file id={}", id); | ||
|
||
var domainEvent = DomainEvent.updateEvent(id, oldAsfDto, updatedAsfDto, | ||
folioExecutionContext.getTenantId()); | ||
eventProducer.sendMessage(id.toString(), domainEvent, DOMAIN_EVENT_TYPE_HEADER, DomainEventType.UPDATE); | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
...lio/entlinks/service/consortium/propagation/model/AuthoritySourceFilePropagationData.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.folio.entlinks.service.consortium.propagation.model; | ||
|
||
import java.util.function.BiConsumer; | ||
import org.folio.entlinks.domain.entity.AuthoritySourceFile; | ||
|
||
public record AuthoritySourceFilePropagationData<T>(AuthoritySourceFile authoritySourceFile, | ||
BiConsumer<T, T> publishConsumer) { | ||
} |
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.