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