use of org.odpi.openmetadata.connector.sas.repository.connector.MetadataCollection in project egeria-connector-sas-viya by odpi.
the class RepositoryEventMapper method start.
/**
* {@inheritDoc}
*/
@Override
public void start() throws ConnectorCheckedException {
super.start();
final String methodName = "start";
auditLog.logMessage(methodName, AuditCode.EVENT_MAPPER_STARTING.getMessageDefinition());
if (!(repositoryConnector instanceof RepositoryConnector)) {
raiseConnectorCheckedException(ErrorCode.EVENT_MAPPER_IMPROPERLY_INITIALIZED, methodName, null, repositoryConnector.getServerName());
}
this.catalogOMRSRepositoryConnector = (RepositoryConnector) this.repositoryConnector;
try {
this.catalogOMRSMetadataCollection = (MetadataCollection) catalogOMRSRepositoryConnector.getMetadataCollection();
} catch (RepositoryErrorException e) {
raiseConnectorCheckedException(ErrorCode.REST_CLIENT_FAILURE, methodName, e, catalogOMRSRepositoryConnector.getServerName());
}
this.typeDefStore = catalogOMRSMetadataCollection.getTypeDefStore();
catalogOMRSMetadataCollection.setEventMapper(this);
this.metadataCollectionId = catalogOMRSRepositoryConnector.getMetadataCollectionId();
this.originatorServerName = catalogOMRSRepositoryConnector.getServerName();
this.originatorServerType = catalogOMRSRepositoryConnector.getServerType();
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
String message = new String(delivery.getBody(), "UTF-8");
log.debug("SAS Catalog Event received: '{}':'{}'", delivery.getEnvelope().getRoutingKey(), message);
try {
Event<CatalogEventPayload> event = this.mapper.readValue(message, Event.class);
String eventPayload = event.getPayloadAsString();
try {
processEvent(eventPayload);
} catch (Exception e) {
log.error("Could not process event payload.", e);
return;
}
} catch (IOException e) {
log.warn("Could not parse event payload. Reason: {}", e.getLocalizedMessage());
return;
}
};
try {
channel.basicConsume(queueName, true, deliverCallback, consumerTag -> {
});
} catch (Exception e) {
log.error("RabbitMQ basic consumer failed to start", e);
}
}
Aggregations