Search in sources :

Example 26 with ExchangeModelMarshallException

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 + " ]");
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 27 with ExchangeModelMarshallException

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")));
        }
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) AcknowledgeResponse(eu.europa.ec.fisheries.schema.exchange.plugin.v1.AcknowledgeResponse) TextMessage(javax.jms.TextMessage) ExchangeBaseRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ExchangeBaseRequest) ExchangeMessageEvent(eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.ExchangeMessageEvent) TransactionAttribute(javax.ejb.TransactionAttribute)

Aggregations

ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)27 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)15 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)13 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)8 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)8 TextMessage (javax.jms.TextMessage)7 RulesModelMapperException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException)4 RulesModelMarshallException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException)4 JMSException (javax.jms.JMSException)4 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)3 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)3 PluginMessageEvent (eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent)3 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException)3 SetFAQueryMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFAQueryMessageRequest)2 SetFLUXFAReportMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAReportMessageRequest)2 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)2 AcknowledgeResponse (eu.europa.ec.fisheries.schema.exchange.plugin.v1.AcknowledgeResponse)2 RegisterServiceRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.RegisterServiceRequest)2 UnregisterServiceRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.UnregisterServiceRequest)2 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)2