Search in sources :

Example 6 with CorrelationIds

use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.

the class DomainResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.debug("Processing public lighting response message");
    String correlationUid = null;
    String jmsType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    NotificationType notificationType;
    ResponseMessageResultType resultType;
    String resultDescription;
    Serializable dataObject;
    try {
        correlationUid = message.getJMSCorrelationID();
        jmsType = 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);
        notificationType = NotificationType.valueOf(jmsType);
        dataObject = message.getObject();
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        LOGGER.debug("correlationUid: {}", correlationUid);
        LOGGER.debug("messageType: {}", jmsType);
        LOGGER.debug("organisationIdentification: {}", organisationIdentification);
        LOGGER.debug("deviceIdentification: {}", deviceIdentification);
        return;
    }
    try {
        LOGGER.info("Calling application service function to handle response: {} with correlationUid: {}", jmsType, correlationUid);
        final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
        this.handleMessage(ids, jmsType, resultType, resultDescription, dataObject);
        this.notificationService.sendNotification(organisationIdentification, deviceIdentification, resultType.name(), correlationUid, resultDescription, notificationType);
    } catch (final RuntimeException e) {
        this.handleError(e, correlationUid, notificationType);
    }
}
Also used : Serializable(java.io.Serializable) NotificationType(org.opensmartgridplatform.adapter.ws.schema.publiclighting.notification.NotificationType) JMSException(javax.jms.JMSException) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds)

Example 7 with CorrelationIds

use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.

the class DomainResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    log.debug("Processing response message");
    String correlationUid = null;
    String actualMessageType = 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();
        actualMessageType = 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(actualMessageType);
        dataObject = message.getObject();
    } catch (final JMSException e) {
        log.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        log.debug("correlationUid: {}", correlationUid);
        log.debug("messageType: {}", actualMessageType);
        log.debug("organisationIdentification: {}", organisationIdentification);
        log.debug("deviceIdentification: {}", deviceIdentification);
        return;
    }
    log.info("Calling application service function to handle response: {} with correlationUid: {}", actualMessageType, correlationUid);
    final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
    this.handleMessage(ids, actualMessageType, resultType, resultDescription, dataObject);
    try {
        log.info("Send notification for correlationUid: {}", correlationUid);
        // Send notification indicating data is available.
        this.notificationService.sendNotification(new ApplicationDataLookupKey(organisationIdentification, this.webserviceNotificationApplicationName), new GenericNotification(notificationMessage, resultType.name(), deviceIdentification, correlationUid, String.valueOf(notificationType)));
        log.info("Notification sent for correlationUid: {}", correlationUid);
    } catch (final Exception e) {
        // Logging is enough, sending the notification will be done
        // automatically by the resend notification job
        log.warn("Delivering notification with correlationUid: {} and notification type: {} did not complete successfully.", correlationUid, notificationType, e);
    }
}
Also used : Serializable(java.io.Serializable) GenericNotification(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification) ApplicationDataLookupKey(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey) NotificationType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.notification.NotificationType) JMSException(javax.jms.JMSException) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds) JMSException(javax.jms.JMSException)

Example 8 with CorrelationIds

use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.

the class GetDeviceModelResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing DA Get Device Model response 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 GetDeviceModelResponseDto dataResponse = (GetDeviceModelResponseDto) dataObject;
        final CorrelationIds correlationIds = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
        this.adHocManagementService.handleGetDeviceModelResponse(dataResponse, correlationIds, messageType, responseMessageResultType, osgpException);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) GetDeviceModelResponseDto(org.opensmartgridplatform.dto.da.GetDeviceModelResponseDto) JMSException(javax.jms.JMSException) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException)

Example 9 with CorrelationIds

use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.

the class GetPQValuesResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    LOGGER.debug("Processing DA Power Quality response 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 GetPQValuesResponseDto dataResponse = (GetPQValuesResponseDto) dataObject;
        final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
        this.monitoringService.handleGetPQValuesResponse(dataResponse, ids, messageType, responseMessageResultType, osgpException);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) GetPQValuesResponseDto(org.opensmartgridplatform.dto.da.GetPQValuesResponseDto) JMSException(javax.jms.JMSException) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException)

Example 10 with CorrelationIds

use of org.opensmartgridplatform.shared.infra.jms.CorrelationIds in project open-smart-grid-platform by OSGP.

the class GetPQValuesPeriodicRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    LOGGER.info("Processing DA Get PQ Values Periodic request message");
    String correlationUid = null;
    String messageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    GetPQValuesPeriodicRequest getPQValuesPeriodicRequest = null;
    try {
        correlationUid = message.getJMSCorrelationID();
        messageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        if (message.getObject() instanceof GetPQValuesPeriodicRequest) {
            getPQValuesPeriodicRequest = (GetPQValuesPeriodicRequest) message.getObject();
        }
    } 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);
        return;
    }
    try {
        LOGGER.info("Calling application service function: {}", messageType);
        final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
        this.monitoringService.getPQValuesPeriodic(ids, messageType, getPQValuesPeriodicRequest);
    } catch (final Exception e) {
        this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType);
    }
}
Also used : JMSException(javax.jms.JMSException) GetPQValuesPeriodicRequest(org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesPeriodicRequest) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds) JMSException(javax.jms.JMSException)

Aggregations

CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)42 JMSException (javax.jms.JMSException)31 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)24 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)18 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)18 Test (org.junit.jupiter.api.Test)7 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)7 Serializable (java.io.Serializable)6 FirmwareVersionDto (org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)5 Date (java.util.Date)4 DeviceFirmwareFile (org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile)4 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)4 FirmwareFile (org.opensmartgridplatform.domain.core.entities.FirmwareFile)4 FirmwareModule (org.opensmartgridplatform.domain.core.entities.FirmwareModule)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 DeviceStatusDto (org.opensmartgridplatform.dto.valueobjects.DeviceStatusDto)3 ApplicationDataLookupKey (org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey)2 GenericNotification (org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification)2 Schedule (org.opensmartgridplatform.domain.core.valueobjects.Schedule)2 GetPQValuesResponseDto (org.opensmartgridplatform.dto.da.GetPQValuesResponseDto)2