Search in sources :

Example 1 with EventMessage

use of eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBean method sendError.

private void sendError(EventMessage message, Exception e) {
    log.error("[ Error in activity module. ] ", e);
    errorEvent.fire(new EventMessage(message.getJmsMessage(), ActivityModuleResponseMapper.createFaultMessage(FaultCode.ACTIVITY_MESSAGE, "Exception in activity [ " + e.getMessage())));
}
Also used : EventMessage(eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage)

Example 2 with EventMessage

use of eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage 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)

Example 3 with EventMessage

use of eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBeanTest method setUp.

@Before
@SneakyThrows
public void setUp() {
    nonUniqueIdsMessage = new ActiveMQTextMessage(session);
    Whitebox.setInternalState(nonUniqueIdsMessage, "text", new SimpleString(getStrRequest1()));
    Whitebox.setInternalState(nonUniqueIdsMessage, "jmsCorrelationID", "SomeCorrId");
    nonUniqueIdsMessageEventMessage = new EventMessage(nonUniqueIdsMessage);
    faAndTripIdsFromTripIdsMessage = new ActiveMQTextMessage(session);
    Whitebox.setInternalState(faAndTripIdsFromTripIdsMessage, "text", new SimpleString(getStrRequest2()));
    Whitebox.setInternalState(faAndTripIdsFromTripIdsMessage, "jmsCorrelationID", "SomeCorrId");
    faAndTripIdsFromTripIdsEventMessage = new EventMessage(faAndTripIdsFromTripIdsMessage);
    getNonUniqueIdsResponse = JAXBMarshaller.unmarshallTextMessage(getResponseStr1(), GetNonUniqueIdsResponse.class);
    getFishingActivitiesForTripResponse = JAXBMarshaller.unmarshallTextMessage(getResponseStr2(), GetFishingActivitiesForTripResponse.class);
}
Also used : EventMessage(eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage) GetNonUniqueIdsResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) GetFishingActivitiesForTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) Before(org.junit.Before) SneakyThrows(lombok.SneakyThrows)

Aggregations

EventMessage (eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage)3 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 GetFishingActivitiesForTripResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse)1 GetNonUniqueIdsResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse)1 TransactionAttribute (javax.ejb.TransactionAttribute)1 TextMessage (javax.jms.TextMessage)1 SneakyThrows (lombok.SneakyThrows)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ActiveMQTextMessage (org.apache.activemq.artemis.jms.client.ActiveMQTextMessage)1 Before (org.junit.Before)1