use of eu.europa.ec.fisheries.schema.exchange.registry.v1.ExchangeRegistryBaseRequest in project UVMS-ExchangeModule-APP by UnionVMS.
the class RegistryBusEventListener method onMessage.
@Override
public void onMessage(Message message) {
TextMessage textMessage = (TextMessage) message;
ServiceType settings = null;
try {
ExchangeRegistryBaseRequest request = JAXBMarshaller.unmarshallTextMessage(textMessage, ExchangeRegistryBaseRequest.class);
LOG.info("Eventbus listener for Exchange Registry (ExchangeModelConstants.EXCHANGE_REGISTER_SERVICE): {} {}", ExchangeModelConstants.EXCHANGE_REGISTER_SERVICE, request);
switch(request.getMethod()) {
case REGISTER_SERVICE:
RegisterServiceRequest regReq = JAXBMarshaller.unmarshallTextMessage(textMessage, RegisterServiceRequest.class);
settings = regReq.getService();
registerServiceEvent.fire(new PluginMessageEvent(textMessage));
break;
case UNREGISTER_SERVICE:
UnregisterServiceRequest unRegReq = JAXBMarshaller.unmarshallTextMessage(textMessage, UnregisterServiceRequest.class);
settings = unRegReq.getService();
unregisterServiceEvent.fire(new PluginMessageEvent(textMessage));
break;
default:
LOG.error("[ Not implemented method consumed: {} ]", request.getMethod());
throw new ExchangeMessageException("[ Not implemented method consumed: " + request.getMethod() + " ]");
}
} catch (ExchangeMessageException | ExchangeModelMarshallException | NullPointerException e) {
LOG.error("[ Error when receiving message on topic in exchange: {}] {}", message, e);
errorEvent.fire(new PluginMessageEvent(textMessage, settings, ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.EXCHANGE_TOPIC_MESSAGE.getCode(), "Error when receiving message in exchange " + e.getMessage())));
}
}
Aggregations