Search in sources :

Example 6 with ExchangeMessageException

use of eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException 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 7 with ExchangeMessageException

use of eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException in project UVMS-ExchangeModule-APP by UnionVMS.

the class PluginServiceBean method registerService.

@Override
public void registerService(@Observes @RegisterServiceEvent PluginMessageEvent event) {
    LOG.info("register service:{}", event);
    TextMessage textMessage = event.getJmsMessage();
    RegisterServiceRequest register = null;
    try {
        register = JAXBMarshaller.unmarshallTextMessage(textMessage, RegisterServiceRequest.class);
        String messageId = textMessage.getJMSMessageID();
        boolean sendMessage = true;
        if (register.getService() != null) {
            sendMessage = checkPluginType(register.getService().getPluginType(), register.getService().getServiceResponseMessageName(), messageId);
            if (sendMessage) {
                registerService(register, messageId);
            }
        }
    } catch (ExchangeModelMarshallException | ExchangeMessageException | JMSException e) {
        LOG.error("Register service exception {} {}", event, e.getMessage());
        errorEvent.fire(new PluginMessageEvent(textMessage, register.getService(), ExchangePluginResponseMapper.mapToPluginFaultResponse(FaultCode.EXCHANGE_PLUGIN_EVENT.getCode(), "Exception when register service")));
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RegisterServiceRequest(eu.europa.ec.fisheries.schema.exchange.registry.v1.RegisterServiceRequest) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) JMSException(javax.jms.JMSException) PluginMessageEvent(eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent) TextMessage(javax.jms.TextMessage)

Example 8 with ExchangeMessageException

use of eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException in project UVMS-ExchangeModule-APP by UnionVMS.

the class PluginServiceBean method start.

@Override
public boolean start(String serviceClassName) throws ExchangeServiceException {
    if (serviceClassName == null) {
        throw new InputArgumentException("No service to start");
    }
    try {
        if (isServiceRegistered(serviceClassName)) {
            String text = ExchangePluginRequestMapper.createStartRequest();
            producer.sendEventBusMessage(text, serviceClassName);
            return true;
        } else {
            throw new ExchangeServiceException("Service with service class name: " + serviceClassName + " does not exist");
        }
    } catch (ExchangeModelMarshallException e) {
        throw new ExchangeServiceException("[ Couldn't map start request for " + serviceClassName + " ]");
    } catch (ExchangeMessageException e) {
        throw new ExchangeServiceException("[ Couldn't send start request for " + serviceClassName + " ]");
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 9 with ExchangeMessageException

use of eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException in project UVMS-ExchangeModule-APP by UnionVMS.

the class PluginServiceBean method updatePluginSetting.

@Override
public void updatePluginSetting(@Observes @UpdatePluginSettingEvent ExchangeMessageEvent settingEvent) {
    LOG.info("update plugin setting from module queue:{}", settingEvent);
    try {
        TextMessage jmsMessage = settingEvent.getJmsMessage();
        UpdatePluginSettingRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, UpdatePluginSettingRequest.class);
        updatePluginSetting(request.getServiceClassName(), request.getSetting(), request.getUsername());
        String text = ExchangeModuleResponseMapper.mapUpdateSettingResponse(ExchangeModuleResponseMapper.mapAcknowledgeTypeOK());
        producer.sendModuleResponseMessage(settingEvent.getJmsMessage(), text);
    } catch (ExchangeModelMarshallException | ExchangeServiceException | ExchangeMessageException e) {
        LOG.error("Couldn't unmarshall update setting request");
        settingEvent.setErrorFault(ExchangeModuleResponseMapper.createFaultMessage(FaultCode.EXCHANGE_EVENT_SERVICE, "Couldn't update plugin setting"));
        producer.sendModuleErrorResponseMessage(settingEvent);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) UpdatePluginSettingRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.UpdatePluginSettingRequest) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) TextMessage(javax.jms.TextMessage) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Example 10 with ExchangeMessageException

use of eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException in project UVMS-ExchangeModule-APP by UnionVMS.

the class PluginServiceBean method stop.

@Override
public boolean stop(String serviceClassName) throws ExchangeServiceException {
    if (serviceClassName == null) {
        throw new InputArgumentException("No service to stop");
    }
    try {
        if (isServiceRegistered(serviceClassName)) {
            String text = ExchangePluginRequestMapper.createStopRequest();
            producer.sendEventBusMessage(text, serviceClassName);
            return true;
        } else {
            throw new ExchangeServiceException("Service with service class name: " + serviceClassName + " does not exist");
        }
    } catch (ExchangeModelMarshallException e) {
        throw new ExchangeServiceException("[ Couldn't map stop request for " + serviceClassName + " ]");
    } catch (ExchangeMessageException e) {
        throw new ExchangeServiceException("[ Couldn't send stop request for " + serviceClassName + " ]");
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)

Aggregations

ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)15 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)13 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)7 ExchangeServiceException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException)6 TextMessage (javax.jms.TextMessage)4 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.service.exception.InputArgumentException)3 RegisterServiceRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.RegisterServiceRequest)2 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)2 PluginMessageEvent (eu.europa.ec.fisheries.uvms.exchange.message.event.carrier.PluginMessageEvent)2 ReceiveInvalidSalesMessage (eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveInvalidSalesMessage)1 SendSalesReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesReportRequest)1 SendSalesResponseRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesResponseRequest)1 SetFAQueryMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFAQueryMessageRequest)1 SetFLUXFAReportMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAReportMessageRequest)1 SetFLUXFAResponseMessageRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetFLUXFAResponseMessageRequest)1 UpdatePluginSettingRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.UpdatePluginSettingRequest)1 ExchangeRegistryBaseRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.ExchangeRegistryBaseRequest)1 UnregisterServiceRequest (eu.europa.ec.fisheries.schema.exchange.registry.v1.UnregisterServiceRequest)1 ServiceType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceType)1 SettingType (eu.europa.ec.fisheries.schema.exchange.service.v1.SettingType)1