Search in sources :

Example 1 with PingResponse

use of eu.europa.ec.fisheries.schema.exchange.module.v1.PingResponse in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method ping.

@Override
public void ping(@Observes @PingEvent ExchangeMessageEvent message) {
    try {
        PingResponse response = new PingResponse();
        response.setResponse("pong");
        producer.sendModuleResponseMessage(message.getJmsMessage(), JAXBMarshaller.marshallJaxBObjectToString(response));
    } catch (ExchangeModelMarshallException e) {
        log.error("[ Error when marshalling ping response ]");
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) PingResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.PingResponse)

Example 2 with PingResponse

use of eu.europa.ec.fisheries.schema.exchange.module.v1.PingResponse 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)2 ExchangeBaseRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.ExchangeBaseRequest)1 PingResponse (eu.europa.ec.fisheries.schema.exchange.module.v1.PingResponse)1 AcknowledgeResponse (eu.europa.ec.fisheries.schema.exchange.plugin.v1.AcknowledgeResponse)1 ExchangeMessageEvent (eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.ExchangeMessageEvent)1 TransactionAttribute (javax.ejb.TransactionAttribute)1 TextMessage (javax.jms.TextMessage)1