Implemented the handling of the mqtt executor removed event #62

Merged
reynisson merged 1 commits from auction_house_handle_executor_removed_event into dev 2021-11-14 20:07:04 +00:00
3 changed files with 6 additions and 6 deletions
Showing only changes of commit 1b7395ba0d - Show all commits

View File

@ -27,6 +27,7 @@ public class AuctionEventsMqttDispatcher {
// TODO: Register here your topics and event listener adapters
private void initRouter() {
router.put("ch/unisg/tapas/executors/added", new ExecutorAddedEventListenerMqttAdapter());
router.put("ch/unisg/tapas/executors/removed", new ExecutorRemovedEventListenerMqttAdapter());
}
/**

View File

@ -11,6 +11,8 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import java.net.URI;
/**
* Listener that handles events when an executor was removed to this TAPAS application.
*
@ -28,14 +30,14 @@ public class ExecutorRemovedEventListenerMqttAdapter extends AuctionEventMqttLis
// representation that makes sense in the context of your application.
JsonNode data = new ObjectMapper().readTree(payload);
String executorId = data.get("executorId").asText();
String executorUri = data.get("executorUri").asText();
ExecutorRemovedEvent executorRemovedEvent = new ExecutorRemovedEvent(
new ExecutorRegistry.ExecutorIdentifier(executorId)
new ExecutorRegistry.ExecutorUri(URI.create(executorUri))
);
ExecutorRemovedHandler newExecutorHandler = new ExecutorRemovedHandler();
newExecutorHandler.handleNewExecutorEvent(executorRemovedEvent);
newExecutorHandler.handleExecutorRemovedEvent(executorRemovedEvent);
} catch (JsonProcessingException | NullPointerException e) {
LOGGER.error(e.getMessage(), e);
return false;

View File

@ -16,7 +16,4 @@ public class ExecutorRemovedHandler implements ExecutorRemovedEventHandler {
public boolean handleExecutorRemovedEvent(ExecutorRemovedEvent executorRemovedEvent) {
return ExecutorRegistry.getInstance().removeExecutor(executorRemovedEvent.getExecutorUri());
}
public void handleNewExecutorEvent(ExecutorRemovedEvent executorRemovedEvent) {
}
}