Search in sources :

Example 1 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method handleUpdateExchangeLogAcknowledge.

private void handleUpdateExchangeLogAcknowledge(ExchangePluginMethod method, String serviceClassName, AcknowledgeType ack) {
    ExchangeLogStatusTypeType logStatus = ExchangeLogStatusTypeType.FAILED;
    switch(ack.getType()) {
        case OK:
            // TODO if(poll probably transmitted)
            logStatus = ExchangeLogStatusTypeType.SUCCESSFUL;
            try {
                exchangeLog.removeUnsentMessage(ack.getUnsentMessageGuid(), serviceClassName);
            } catch (ExchangeLogException ex) {
                log.error(ex.getMessage());
            }
            break;
        case NOK:
            log.debug(method + " was NOK: " + ack.getMessage());
            break;
    }
    try {
        ExchangeLogType updatedLog = exchangeLog.updateStatus(ack.getMessageId(), logStatus, serviceClassName);
        // Long polling
        LogRefType typeRef = updatedLog.getTypeRef();
        if (typeRef != null && typeRef.getType() == TypeRefType.POLL) {
            String pollGuid = typeRef.getRefGuid();
            pollEvent.fire(new NotificationMessage("guid", pollGuid));
        }
    } catch (ExchangeLogException e) {
        log.error(e.getMessage());
    }
}
Also used : NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)

Example 2 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogServiceBean method resend.

@Override
public void resend(List<String> messageIdList, String username) throws ExchangeLogException {
    log.debug("resend in service layer:{} {}", messageIdList, username);
    List<UnsentMessageType> unsentMessageList;
    try {
        unsentMessageList = unsentModel.resend(messageIdList);
        sendAuditLogMessageForResendUnsentMessage(messageIdList.toString(), username);
    } catch (ExchangeModelException e) {
        log.error("Couldn't read unsent messages", e);
        throw new ExchangeLogException("Couldn't read unsent messages");
    }
    if (unsentMessageList != null && !unsentMessageList.isEmpty()) {
        sendingQueueEvent.fire(new NotificationMessage("messageIds", messageIdList));
        for (UnsentMessageType unsentMessage : unsentMessageList) {
            try {
                String unsentMessageId = producer.sendMessageOnQueue(unsentMessage.getMessage(), MessageQueue.EVENT);
                // TextMessage unsentResponse = consumer.getMessage(unsentMessageId, TextMessage.class);
                sendAuditLogMessageForCreateUnsentMessage(unsentMessageId, username);
            // ExchangeModuleResponseMapper.validateResponse(unsentResponse, unsentMessageId);
            } catch (ExchangeMessageException e) {
                log.error("Error when sending/receiving message {} {}", messageIdList, e);
            }
        }
    }
}
Also used : UnsentMessageType(eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 3 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method handleSetPollStatusAcknowledge.

private void handleSetPollStatusAcknowledge(ExchangePluginMethod method, String serviceClassName, AcknowledgeType ack) {
    log.debug(method + " was acknowledged in " + serviceClassName);
    try {
        PollStatus updatedLog = exchangeLog.setPollStatus(ack.getMessageId(), ack.getPollStatus().getPollId(), ack.getPollStatus().getStatus(), serviceClassName);
        // Long polling
        pollEvent.fire(new NotificationMessage("guid", updatedLog.getPollGuid()));
    } catch (ExchangeLogException e) {
        log.error(e.getMessage());
    }
}
Also used : PollStatus(eu.europa.ec.fisheries.schema.exchange.v1.PollStatus) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Example 4 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method handleProcessedMovement.

// Async response handler for processed movements
@Override
public void handleProcessedMovement(@Observes @HandleProcessedMovementEvent ExchangeMessageEvent message) {
    try {
        ProcessedMovementResponse request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), ProcessedMovementResponse.class);
        log.debug("Received processed movement from Rules:{}", request);
        String username;
        MovementRefType movementRefType = request.getMovementRefType();
        SetReportMovementType orgRequest = request.getOrgRequest();
        if (PluginType.MANUAL.equals(orgRequest.getPluginType())) {
            username = request.getUsername();
        } else {
            username = orgRequest.getPluginName();
        }
        ExchangeLogType log = ExchangeLogMapper.getReceivedMovementExchangeLog(orgRequest, movementRefType.getMovementRefGuid(), movementRefType.getType().value(), username);
        ExchangeLogType createdLog = exchangeLog.log(log, username);
        LogRefType logTypeRef = createdLog.getTypeRef();
        if (logTypeRef != null && logTypeRef.getType() == TypeRefType.POLL) {
            String pollGuid = logTypeRef.getRefGuid();
            pollEvent.fire(new NotificationMessage("guid", pollGuid));
        }
    } catch (ExchangeLogException | ExchangeModelMarshallException e) {
        log.error(e.getMessage());
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) MovementRefType(eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementRefType) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) SetReportMovementType(eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType) ProcessedMovementResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.ProcessedMovementResponse)

Example 5 with NotificationMessage

use of eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method createNotificationMessage.

private NotificationMessage createNotificationMessage(String serviceClassName, boolean started) {
    NotificationMessage msg = new NotificationMessage("serviceClassName", serviceClassName);
    msg.setProperty("started", started);
    return msg;
}
Also used : NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)

Aggregations

NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)10 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)9 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)6 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)5 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)2 PollStatus (eu.europa.ec.fisheries.schema.exchange.v1.PollStatus)2 UnsentMessageType (eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType)2 ProcessedMovementResponse (eu.europa.ec.fisheries.schema.exchange.module.v1.ProcessedMovementResponse)1 MovementRefType (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementRefType)1 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)1 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)1 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)1 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)1 ExchangeModelMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException)1 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)1