-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODINV-986: InstanceIngress create events consumption (#729)
* MODINV-986: step 1: prepare InstanceIngestConsumerVerticle re-using other consumer verticles logic * MODINV-986: code review remark fixes * MODINV-986: instance_ingest -> instance_ingress * MODINV-986: InstanceIngressEventConsumer and CreateInstanceIngressEventHandler * MODINV-986: NEWS.md update * MODINV-986: re-using code from CreateInstanceEventHandler and AbstractInstanceEventHandler + proper additional fields setting * MODINV-986: remove a namespace from a topic name * MODINV-986: fix instance source mapped to MARC, code optimization * MODINV-986: post-rebase fixes * MODINV-986: unit test + fixes * MODINV-986: unit test + fixes * MODINV-986: return consumers base property * MODINV-986: rename source type BIBFRAME to LINKED_DATA * MODINV-986: minor hotfix * MODINV-986: postSnapshotInSrs just before saving + minor fixes
- Loading branch information
Showing
32 changed files
with
1,334 additions
and
415 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"description": "Instance ingress event data model", | ||
"javaType": "org.folio.rest.jaxrs.model.InstanceIngressEvent", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"id": { | ||
"description": "UUID", | ||
"$ref": "uuid.json" | ||
}, | ||
"eventType": { | ||
"type": "string", | ||
"enum": ["CREATE_INSTANCE", "UPDATE_INSTANCE"], | ||
"description": "Instance ingress event type" | ||
}, | ||
"InstanceIngressEventMetadata": { | ||
"description": "Event metadata", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"eventTTL": { | ||
"description": "Time-to-live (TTL) for event in minutes", | ||
"type": "integer" | ||
}, | ||
"correlationId": { | ||
"description": "Id to track related events, can be a meaningful string or a UUID", | ||
"type": "string" | ||
}, | ||
"originalEventId": { | ||
"description": "Id of the event that started the sequence of related events", | ||
"$ref": "uuid.json" | ||
}, | ||
"publisherCallback": { | ||
"description": "Allows a publisher to provide a callback endpoint or an error Event Type to be notified that despite the fact that there are subscribers for such an event type no one has received the event within the specified period of time", | ||
"type": "object", | ||
"properties": { | ||
"endpoint": { | ||
"description": "Callback endpoint", | ||
"type": "string" | ||
}, | ||
"eventType": { | ||
"description": "Error Event Type", | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"createdDate": { | ||
"description": "Timestamp when event was created", | ||
"type": "string", | ||
"format": "date-time" | ||
}, | ||
"publishedDate": { | ||
"description": "Timestamp when event was initially published to the underlying topic", | ||
"type": "string", | ||
"format": "date-time" | ||
}, | ||
"createdBy": { | ||
"description": "Username of the user whose action caused an event", | ||
"type": "string" | ||
}, | ||
"publishedBy": { | ||
"description": "Name and version of the module that published an event", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"eventTTL", | ||
"publishedBy" | ||
] | ||
}, | ||
"eventPayload": { | ||
"type": "object", | ||
"description": "An instance source record container", | ||
"$ref": "instance-ingress-payload.json" | ||
}, | ||
"tenant": { | ||
"description": "Tenant id", | ||
"type": "string" | ||
}, | ||
"ts": { | ||
"description": "Message timestamp", | ||
"type": "string", | ||
"format": "date-time" | ||
} | ||
}, | ||
"excludedFromEqualsAndHashCode": [ | ||
"eventMetadata", | ||
"tenant", | ||
"ts" | ||
], | ||
"required": [ | ||
"id", | ||
"eventType" | ||
] | ||
} |
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,25 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"description": "An instance source record container", | ||
"type": "object", | ||
"properties": { | ||
"sourceRecordIdentifier": { | ||
"type": "string", | ||
"description": "The source record identifier" | ||
}, | ||
"sourceRecordObject": { | ||
"type": "string", | ||
"description": "The source record JSON object" | ||
}, | ||
"sourceType": { | ||
"type": "string", | ||
"enum": ["FOLIO", "LINKED_DATA", "MARC"], | ||
"description": "Source type" | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"required": [ | ||
"sourceRecordObject", | ||
"sourceType" | ||
] | ||
} |
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
33 changes: 33 additions & 0 deletions
33
src/main/java/org/folio/inventory/InstanceIngressConsumerVerticle.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,33 @@ | ||
package org.folio.inventory; | ||
|
||
import static org.folio.inventory.dataimport.util.ConsumerWrapperUtil.constructModuleName; | ||
|
||
import io.vertx.core.Promise; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.folio.inventory.instanceingress.InstanceIngressEventConsumer; | ||
import org.folio.inventory.support.KafkaConsumerVerticle; | ||
|
||
public class InstanceIngressConsumerVerticle extends KafkaConsumerVerticle { | ||
|
||
private static final Logger LOGGER = LogManager.getLogger(InstanceIngressConsumerVerticle.class); | ||
private static final String INSTANCE_INGRESS_TOPIC = "inventory.instance_ingress"; | ||
private static final String BASE_PROPERTY = "InstanceIngressConsumerVerticle"; | ||
|
||
@Override | ||
public void start(Promise<Void> startPromise) { | ||
var instanceIngressEventHandler = new InstanceIngressEventConsumer(vertx, getStorage(), getHttpClient(), getMappingMetadataCache()); | ||
|
||
var consumerWrapper = createConsumer(INSTANCE_INGRESS_TOPIC, BASE_PROPERTY, false); | ||
|
||
consumerWrapper.start(instanceIngressEventHandler, constructModuleName()) | ||
.onFailure(startPromise::fail) | ||
.onSuccess(ar -> startPromise.complete()); | ||
} | ||
|
||
@Override | ||
protected Logger getLogger() { | ||
return LOGGER; | ||
} | ||
|
||
} |
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.