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