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())));
}
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")));
}
}
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);
}
Aggregations