Skip to content
Snippets Groups Projects
Commit 22426f23 authored by Bhushan Rade's avatar Bhushan Rade
Browse files

pub sub changes

parent 84f4f099
No related branches found
No related tags found
1 merge request!155pub sub changes
/* Licensed Materials - Property of IBM */
/* (c) Copyright IBM Corp. 2020. All Rights Reserved.*/
package org.opengroup.osdu.register.provider.ibm.subscriber;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.notification.Topic;
import org.opengroup.osdu.register.provider.interfaces.subscriber.ITopicsRepository;
import org.opengroup.osdu.register.utils.FileUtil;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@Repository
@Primary
@RequiredArgsConstructor
public class TopicsRepositoryImpl implements ITopicsRepository {
private final JaxRsDpsLog log;
private final DpsHeaders headers;
private Map<String, List<Topic>> topicsMap = new HashMap<>();
public List<Topic> listMessages() {
final String partitionId = headers.getPartitionId();
if (topicsMap.containsKey(partitionId)) {
return topicsMap.get(partitionId);
}
final List<Topic> template = getTopicTemplate();
topicsMap.put(partitionId, template);
return template;
}
List<Topic> getTopicTemplate() {
Type type = new TypeToken<ArrayList<Topic>>() {
}.getType();
return new Gson().fromJson(FileUtil.readFile("topics.json", log), type);
}
}
[
{
"name": "records-changed",
"description": "This notification is sent whenever a new record or record version is created, updated or deleted, and when a new schema is created in storage.",
"state": "ACTIVE",
"example": [
{
"id": "common:abc:123",
"kind": "common:petrel:regularheightfieldsurface:1.0.0",
"op" : "create",
"recordUpdated": "false"
},
{
"id": "common:abc:124",
"kind": "common:petrel:regularheightfieldsurface:1.0.0",
"op" : "create",
"recordUpdated": "true"
},
{
"kind": "common:petrel:regularheightfieldsurface:1.0.0",
"op" : "create_schema"
},
{
"id": "common:ghi:345",
"kind": "common:petrel:regularheightfieldsurface:1.0.0",
"op" : "delete"
}
]
},
{
"name": "opendes-status-update-event-topic",
"description": "pubsub.",
"state": "ACTIVE",
"example": [
{
"kind": "status",
"properties": {
"correlationId": "3fb4b4ba-524b-490b-8c47-432c03130ada",
"stage": "TESTING_QUARKUS",
"status": "FAILED",
"message": "Testing message publishing through quarkus listener component",
"errorCode": 400,
"userEmail": "osdu-qa@osdu.opengroup.org",
"timestamp": 1633607749441
}
},
{
"kind": "status",
"properties": {
"correlationId": "3fb4b4ba-524b-490b-8c47-432c03130ada",
"stage": "TESTING_QUARKUS",
"status": "FAILED",
"message": "Testing message publishing through quarkus listener component",
"errorCode": 401,
"userEmail": "osdu-qa@osdu.opengroup.org",
"timestamp": 1633607749441
}
}
]
}
]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment