use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class AbstractDomainResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing response message");
String correlationUid = null;
String messageType = null;
String organisationIdentification = null;
String deviceIdentification = null;
final String notificationMessage;
final NotificationType notificationType;
final ResponseMessageResultType resultType;
final String resultDescription;
final Serializable dataObject;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT));
resultDescription = message.getStringProperty(Constants.DESCRIPTION);
notificationMessage = message.getStringProperty(Constants.DESCRIPTION);
notificationType = NotificationType.valueOf(messageType);
dataObject = message.getObject();
} catch (final JMSException | IllegalArgumentException | NullPointerException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.handleMessage(ids, messageType, resultType, resultDescription, dataObject);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, notificationType);
return;
}
/*
* Keep the notification part apart from handling the message. Exception
* handling that might be appropriate for issues with the message could
* likely not be appropriate for exceptions in the notification
* mechanism. The latter kind of issues should be covered by re-sending
* of notifications for existing response data or by application-side
* attempts to retrieve results after some amount of time.
*/
this.sendNotification(organisationIdentification, deviceIdentification, resultType.name(), correlationUid, notificationMessage, notificationType);
}
use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class CommonGetFirmwareResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing common get firmware version response message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
Object dataObject;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
dataObject = responseMessage.getDataObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
@SuppressWarnings("unchecked") final List<FirmwareVersionDto> firmwareVersions = (List<FirmwareVersionDto>) dataObject;
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.firmwareManagementService.handleGetFirmwareVersionResponse(firmwareVersions, ids, messageType, messagePriority, responseMessageResultType, osgpException);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class LoggingMessageListener method onMessage.
@Override
public void onMessage(final Message message) {
try {
LOGGER.info("Received logging message");
if (message instanceof TextMessage) {
LOGGER.warn("A TextMessage is received. TextMessages belong with configuration setting : auditlogging.message.create.json=true");
return;
}
final ObjectMessage objectMessage = (ObjectMessage) message;
// Create a log item.
final Date timestamp = new Date(objectMessage.getLongProperty(Constants.TIME_STAMP));
final String organisationIdentification = objectMessage.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
final String correlationUid = objectMessage.getJMSCorrelationID();
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
final MethodResult methodResult = methodResultFor(objectMessage);
final WebServiceMonitorLogItem webServiceMonitorLogItem = new WebServiceMonitorLogItem(timestamp, ids, objectMessage.getStringProperty(Constants.USER_NAME), methodResult);
// Save the log item in the data base.
this.webServiceMonitorLogRepository.save(webServiceMonitorLogItem);
} catch (final JMSException e) {
LOGGER.error("Exception: {}, StackTrace: {}", e.getMessage(), e.getStackTrace(), e);
}
}
use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class GetMeasurementReportResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing Measurement Report message");
String correlationUid = null;
String messageType = null;
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage = null;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
Object dataObject = null;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
dataObject = responseMessage.getDataObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
final MeasurementReportDto dataResponse = (MeasurementReportDto) dataObject;
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.monitoringService.handleGetMeasurementReportResponse(dataResponse, ids, messageType, responseMessageResultType, osgpException);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType);
}
}
use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.
the class SetDataResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing microgrids set data response message");
String correlationUid = null;
String messageType = null;
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
Object dataObject;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
dataObject = responseMessage.getDataObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
final EmptyResponseDto emptyResponse = (EmptyResponseDto) dataObject;
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.adHocManagementService.handleSetDataResponse(emptyResponse, ids, messageType, responseMessageResultType, osgpException);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType);
}
}
Aggregations