Search in sources :

Example 1 with ActivityModuleRequest

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleRequest in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityMessageConsumerBean method onMessage.

@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void onMessage(Message message) {
    TextMessage textMessage = null;
    try {
        textMessage = (TextMessage) message;
        MappedDiagnosticContext.addMessagePropertiesToThreadMappedDiagnosticContext(textMessage);
        ActivityModuleRequest request;
        request = JAXBMarshaller.unmarshallTextMessage(textMessage, ActivityModuleRequest.class);
        LOG.debug("Message unmarshalled successfully in activity");
        if (request == null) {
            LOG.error("[ Request is null ]");
            return;
        }
        ActivityModuleMethod method = request.getMethod();
        if (method == null) {
            LOG.error("[ Request method is null ]");
            return;
        }
        switch(method) {
            case GET_FLUX_FA_REPORT:
            case GET_FLUX_FA_QUERY:
                receiveFishingActivityEvent.fire(new EventMessage(textMessage, method));
                break;
            case MAP_TO_SUBSCRIPTION_REQUEST:
                mapToSubscriptionRequest.fire(new EventMessage(textMessage));
                break;
            case GET_FISHING_TRIPS:
                getFishingTripListEvent.fire(new EventMessage(textMessage));
                break;
            case GET_FA_CATCH_SUMMARY_REPORT:
                getFACatchSummaryReportEvent.fire(new EventMessage(textMessage));
                break;
            case GET_NON_UNIQUE_IDS:
                getNonUniqueIdsRequest.fire(new EventMessage(textMessage));
                break;
            case GET_FISHING_ACTIVITY_FOR_TRIPS:
                getFishingActivityForTrips.fire(new EventMessage(textMessage));
                break;
            default:
                LOG.error("[ Request method {} is not implemented ]", method.name());
                errorEvent.fire(new EventMessage(textMessage, ActivityModuleResponseMapper.createFaultMessage(FaultCode.ACTIVITY_MESSAGE, "[ Request method " + method.name() + "  is not implemented ]")));
        }
    } catch (ActivityModelMarshallException | ClassCastException e) {
        LOG.error("[ Error when receiving message in activity: ] {}", e);
        errorEvent.fire(new EventMessage(textMessage, ActivityModuleResponseMapper.createFaultMessage(FaultCode.ACTIVITY_MESSAGE, "Error when receiving message")));
    }
}
Also used : ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) ActivityModuleMethod(eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleMethod) EventMessage(eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage) TextMessage(javax.jms.TextMessage) ActivityModuleRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleRequest) TransactionAttribute(javax.ejb.TransactionAttribute)

Aggregations

EventMessage (eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage)1 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)1 ActivityModuleMethod (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleMethod)1 ActivityModuleRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleRequest)1 TransactionAttribute (javax.ejb.TransactionAttribute)1 TextMessage (javax.jms.TextMessage)1