use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.
the class PluginServiceBean method ping.
@Override
public boolean ping(String serviceClassName) throws ExchangeServiceException {
if (serviceClassName == null) {
throw new InputArgumentException("No service to ping");
}
try {
String text = ExchangePluginRequestMapper.createPingRequest();
producer.sendEventBusMessage(text, serviceClassName);
return true;
} catch (ExchangeModelMarshallException e) {
throw new ExchangeServiceException("[ Couldn't map ping request for " + serviceClassName + " ]");
} catch (ExchangeMessageException e) {
throw new ExchangeServiceException("[ Couldn't send ping request for " + serviceClassName + " ]");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeMessageConsumerBean method onMessage.
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void onMessage(Message message) {
TextMessage textMessage = (TextMessage) message;
ExchangeBaseRequest request = tryConsumeExchangeBaseRequest(textMessage);
LOG.info("Message received in Exchange Message MDB");
LOG.debug("Request body : ", request);
final ExchangeMessageEvent messageEventWrapper = new ExchangeMessageEvent(textMessage);
if (request == null) {
LOG.warn("[ERROR] ExchangeBaseRequest is null!! Check the message sent...");
try {
// Handle PingResponse from plugin
JAXBMarshaller.unmarshallTextMessage(textMessage, PingResponse.class);
updatePingStateEvent.fire(messageEventWrapper);
} catch (ExchangeModelMarshallException e) {
AcknowledgeResponse type = tryConsumeAcknowledgeResponse(textMessage);
if (type == null) {
LOG.error("[ Error when receiving message in exchange: {}]", message);
errorEvent.fire(new ExchangeMessageEvent(textMessage, ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_MESSAGE, "Error when receiving message in exchange")));
} else {
updateStateEvent.fire(messageEventWrapper);
}
}
} else if (!checkUsernameShouldBeProvided(request)) {
LOG.error("[ Error when receiving message in exchange, username must be set in the request: ]");
errorEvent.fire(new ExchangeMessageEvent(textMessage, ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_MESSAGE, "Username in the request must be set")));
} else {
LOG.info("[INFO] Going to process following message type (aka Exchange Method) : " + request.getMethod());
switch(request.getMethod()) {
case LIST_SERVICES:
pluginConfigEvent.fire(messageEventWrapper);
break;
case SET_COMMAND:
sendCommandToPluginEvent.fire(messageEventWrapper);
break;
case SEND_REPORT_TO_PLUGIN:
sendMessageToPluginEvent.fire(messageEventWrapper);
break;
case SET_MOVEMENT_REPORT:
processMovementEvent.fire(messageEventWrapper);
break;
case RECEIVE_SALES_REPORT:
receiveSalesReportEvent.fire(messageEventWrapper);
break;
case RECEIVE_SALES_QUERY:
receiveSalesQueryEvent.fire(messageEventWrapper);
break;
case RECEIVE_SALES_RESPONSE:
receiveSalesResponseEvent.fire(messageEventWrapper);
break;
case RECEIVE_INVALID_SALES_MESSAGE:
receiveInvalidSalesMessageEvent.fire(messageEventWrapper);
break;
case SEND_SALES_RESPONSE:
sendSalesResponseEvent.fire(messageEventWrapper);
break;
case SEND_SALES_REPORT:
sendSalesReportEvent.fire(messageEventWrapper);
break;
case UPDATE_PLUGIN_SETTING:
updatePluginSettingEvent.fire(messageEventWrapper);
break;
case PING:
pingEvent.fire(messageEventWrapper);
break;
case PROCESSED_MOVEMENT:
processedMovementEvent.fire(messageEventWrapper);
break;
case SET_MDR_SYNC_MESSAGE_REQUEST:
mdrSyncRequestMessageEvent.fire(messageEventWrapper);
break;
case SET_MDR_SYNC_MESSAGE_RESPONSE:
mdrSyncResponseMessageEvent.fire(messageEventWrapper);
break;
case SET_FLUX_FA_REPORT_MESSAGE:
processFLUXFAReportMessageEvent.fire(messageEventWrapper);
break;
case SEND_FLUX_FA_REPORT_MESSAGE:
sendFaReportToPluginMessageEvent.fire(messageEventWrapper);
break;
case SET_FA_QUERY_MESSAGE:
receivedFaQueryFromFlux.fire(messageEventWrapper);
break;
case SEND_FA_QUERY_MESSAGE:
sendFaQueryToPluginEvent.fire(messageEventWrapper);
break;
case SET_FLUX_FA_RESPONSE_MESSAGE:
processFLUXFAResponseMessageEvent.fire(messageEventWrapper);
break;
case RCV_FLUX_FA_RESPONSE_MESSAGE:
receivedFLUXFAResponseMessageEvent.fire(messageEventWrapper);
break;
case UPDATE_LOG_STATUS:
updateLogStatusEvent.fire(messageEventWrapper);
break;
case LOG_REF_ID_BY_TYPE_EXISTS:
logRefIdByTyeExists.fire(messageEventWrapper);
break;
case LOG_ID_BY_TYPE_EXISTS:
logIdByTyeExists.fire(messageEventWrapper);
break;
default:
LOG.error("[ Not implemented method consumed: {} ] ", request.getMethod());
errorEvent.fire(new ExchangeMessageEvent(textMessage, ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_MESSAGE, "Method not implemented")));
}
}
}
Aggregations