Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-18534 : Bus out halt config and conditions added to allow stop … #1311

Open
wants to merge 1 commit into
base: release-1.2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

Expand Down Expand Up @@ -94,6 +95,12 @@ public abstract class MosipVerticleManager extends AbstractVerticle
@Autowired
protected PropertiesUtil propertiesUtil;

/*
* Comma separated out bus message addresses for which message will not be sent out from any stage
*/
@Value("#{T(java.util.Arrays).asList('${mosip.regproc.stage-common.bus-out-halt-addresses:}')}")
protected List<String> busOutHaltAddresses;

@Autowired
private MosipEventBusFactory mosipEventBusFactory;

Expand Down Expand Up @@ -173,6 +180,10 @@ public MosipEventBus getEventBus(Object verticleName, String clusterManagerUrl,
@Override
public void consumeAndSend(MosipEventBus mosipEventBus, MessageBusAddress fromAddress,
MessageBusAddress toAddress, long messageExpiryTimeLimit) {
if(busOutHaltAddresses.contains(toAddress.getAddress())) {
consume(mosipEventBus, fromAddress, messageExpiryTimeLimit);
return;
}
mosipEventBus.consumeAndSend(fromAddress, toAddress, (msg, handler) -> {
logger.debug("consumeAndSend received from {} {}",fromAddress.toString(), msg.getBody());
Map<String, String> mdc = MDC.getCopyOfContextMap();
Expand Down Expand Up @@ -218,6 +229,8 @@ public void consumeAndSend(MosipEventBus mosipEventBus, MessageBusAddress fromAd
* The message that needs to be sent
*/
public void send(MosipEventBus mosipEventBus, MessageBusAddress toAddress, MessageDTO message) {
if(busOutHaltAddresses.contains(toAddress.getAddress()))
return;
addTagsToMessageDTO(message);
message.setLastHopTimestamp(DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime()));
mosipEventBus.send(toAddress, message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.mosip.registration.processor.abstractverticle;

import java.net.URL;
import java.util.ArrayList;

import brave.Tracing;
import io.mosip.registration.processor.core.tracing.EventTracingHandler;
Expand Down Expand Up @@ -39,6 +40,7 @@ public void start() throws UnsupportedEventBusTypeException {
this.messageDTO.setIsValid(true);
this.messageDTO.setInternalError(false);
this.messageDTO.setReg_type(RegistrationType.NEW.name());
this.busOutHaltAddresses = new ArrayList<String>();

//this.consume(mosipEventBus, MessageBusAddress.PACKET_VALIDATOR_BUS_IN);
//this.consumeAndSend(mosipEventBus, MessageBusAddress.PACKET_VALIDATOR_BUS_OUT, MessageBusAddress.RETRY_BUS);
Expand Down