Skip to content
Snippets Groups Projects
Commit 9388de3b authored by Chad Leong's avatar Chad Leong :speech_balloon:
Browse files

Merge branch 'fix-recordstopic-v2-logic' into 'master'

Bug Fix for Azure: update the message to not be sent to recordstopic v2 if feature flag is off

See merge request !582
parents 1217d162 f1c02900
No related branches found
No related tags found
1 merge request!582Bug Fix for Azure: update the message to not be sent to recordstopic v2 if feature flag is off
Pipeline #154268 failed
......@@ -24,6 +24,7 @@ import org.opengroup.osdu.storage.provider.azure.di.ServiceBusConfig;
import org.opengroup.osdu.storage.provider.azure.di.PublisherConfig;
import org.opengroup.osdu.storage.provider.interfaces.IMessageBus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.*;
......@@ -38,12 +39,16 @@ public class MessageBusImpl implements IMessageBus {
private MessagePublisher messagePublisher;
@Autowired
private PublisherConfig publisherConfig;
@Value("${collaboration.enabled:false}")
private boolean isCollaborationEnabled;
@Override
public void publishMessage(Optional<CollaborationContext> collaborationContext, DpsHeaders headers, PubSubInfo... messages) {
publishMessageToRecordsEvent(collaborationContext, headers, messages);
if(collaborationContext.isPresent()){
return;
if (isCollaborationEnabled) {
publishMessageToRecordsTopicV2(collaborationContext, headers, messages);
if (collaborationContext.isPresent()) {
return;
}
}
// The batch size is same for both Event grid and Service bus.
final int BATCH_SIZE = Integer.parseInt(publisherConfig.getPubSubBatchSize());
......@@ -63,7 +68,7 @@ public class MessageBusImpl implements IMessageBus {
}
public void publishMessageToRecordsEvent(Optional<CollaborationContext> collaborationContext, DpsHeaders headers, PubSubInfo... messages) {
public void publishMessageToRecordsTopicV2(Optional<CollaborationContext> collaborationContext, DpsHeaders headers, PubSubInfo... messages) {
// The batch size is same for both Event grid and Service bus.
final int BATCH_SIZE = Integer.parseInt(publisherConfig.getPubSubBatchSize());
for (int i = 0; i < messages.length; i += BATCH_SIZE) {
......
......@@ -99,7 +99,7 @@ public class MessageBusImplTest {
public void should_publishToBothTopics_WhenCollaborationContextIsNotProvided() {
PubSubInfo[] pubSubInfo = setup();
sut.publishMessage(Optional.empty(), dpsHeaders, pubSubInfo);
verify(messagePublisher, times(2)).publishMessage(any(), any(), any());
verify(messagePublisher, times(1)).publishMessage(any(), any(), any());
}
private PubSubInfo getPubsInfo(String id, String kind) {
......
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