Search in sources :

Example 11 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class MicrogridsGetDataRequestMessageProcessor method handleGetDataDeviceResponse.

private void handleGetDataDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    OsgpException osgpException = null;
    GetDataResponseDto dataResponse = null;
    try {
        final GetDataDeviceResponse response = (GetDataDeviceResponse) deviceResponse;
        dataResponse = response.getDataResponse();
    } catch (final Exception e) {
        LOGGER.error("Device Response Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        osgpException = new TechnicalException(ComponentType.PROTOCOL_IEC61850, "Unexpected exception while retrieving response message", e);
    }
    final DeviceMessageMetadata deviceMessageMetaData = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
    final ProtocolResponseMessage responseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetaData).result(result).osgpException(osgpException).dataObject(dataResponse).retryCount(retryCount).build();
    responseMessageSender.send(responseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) GetDataDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) GetDataResponseDto(com.alliander.osgp.dto.valueobjects.microgrids.GetDataResponseDto) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) JMSException(javax.jms.JMSException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Example 12 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class BaseMessageProcessor method handleExpectedError.

public void handleExpectedError(final OsgpException e, final String correlationUid, final String organisationIdentification, final String deviceIdentification, final String domain, final String domainVersion, final String messageType) {
    LOGGER.error("Expected error while processing message", e);
    final int retryCount = Integer.MAX_VALUE;
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, messageType, 0);
    final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(e).retryCount(retryCount).build();
    this.responseMessageSender.send(protocolResponseMessage);
}
Also used : ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)

Example 13 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class SsldDeviceRequestMessageProcessor method handleGetStatusDeviceResponse.

// This function is used in 3 domains.
protected void handleGetStatusDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final int retryCount) {
    LOGGER.info("Handling getStatusDeviceResponse for device: {}", deviceResponse.getDeviceIdentification());
    if (StringUtils.isEmpty(deviceResponse.getCorrelationUid())) {
        LOGGER.warn("CorrelationUID is null or empty, not sending GetStatusResponse message for GetStatusRequest message for device: {}", deviceResponse.getDeviceIdentification());
        return;
    }
    final GetStatusDeviceResponse response = (GetStatusDeviceResponse) deviceResponse;
    final DeviceStatusDto status = response.getDeviceStatus();
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
    final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.OK).osgpException(null).retryCount(retryCount).dataObject(status).build();
    responseMessageSender.send(protocolResponseMessage);
}
Also used : GetStatusDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetStatusDeviceResponse) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceStatusDto(com.alliander.osgp.dto.valueobjects.DeviceStatusDto) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)

Example 14 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class BaseMessageProcessor method handleUnExpectedError.

public void handleUnExpectedError(final DeviceResponse deviceResponse, final Throwable t, final Serializable messageData, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
    final OsgpException ex = this.ensureOsgpException(t);
    final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, 0);
    final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(ex).retryCount(retryCount).dataObject(messageData).scheduled(isScheduled).build();
    this.responseMessageSender.send(protocolResponseMessage);
}
Also used : OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)

Example 15 with DeviceMessageMetadata

use of com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata in project Protocol-Adapter-IEC61850 by OSGP.

the class DeviceRequestMessageListener method sendException.

private void sendException(final ObjectMessage objectMessage, final Exception exception) {
    try {
        final String domain = objectMessage.getStringProperty(Constants.DOMAIN);
        final String domainVersion = objectMessage.getStringProperty(Constants.DOMAIN_VERSION);
        final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
        final FunctionalException osgpException = new FunctionalException(FunctionalExceptionType.UNSUPPORTED_DEVICE_ACTION, ComponentType.PROTOCOL_IEC61850, exception);
        final Serializable dataObject = objectMessage.getObject();
        final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(objectMessage);
        final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().deviceMessageMetadata(deviceMessageMetadata).domain(domain).domainVersion(domainVersion).result(result).osgpException(osgpException).dataObject(dataObject).scheduled(false).build();
        this.deviceResponseMessageSender.send(protocolResponseMessage);
    } catch (final Exception e) {
        LOGGER.error("Unexpected error during sendException(ObjectMessage, Exception)", e);
    }
}
Also used : Serializable(java.io.Serializable) ProtocolResponseMessage(com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage) FunctionalException(com.alliander.osgp.shared.exceptionhandling.FunctionalException) DeviceMessageMetadata(com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata) ResponseMessageResultType(com.alliander.osgp.shared.infra.jms.ResponseMessageResultType) FunctionalException(com.alliander.osgp.shared.exceptionhandling.FunctionalException) JMSException(javax.jms.JMSException) NotSupportedException(com.alliander.osgp.shared.exceptionhandling.NotSupportedException)

Aggregations

DeviceMessageMetadata (com.alliander.osgp.shared.infra.jms.DeviceMessageMetadata)26 ProtocolResponseMessage (com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage)26 ResponseMessageResultType (com.alliander.osgp.shared.infra.jms.ResponseMessageResultType)17 OsgpException (com.alliander.osgp.shared.exceptionhandling.OsgpException)15 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)15 JMSException (javax.jms.JMSException)12 IOException (java.io.IOException)6 DeviceStatusDto (com.alliander.osgp.dto.valueobjects.DeviceStatusDto)4 Serializable (java.io.Serializable)4 GetStatusDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)3 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)2 ConfigurationDto (com.alliander.osgp.dto.valueobjects.ConfigurationDto)2 FirmwareVersionDto (com.alliander.osgp.dto.valueobjects.FirmwareVersionDto)2 PowerUsageHistoryResponseMessageDataContainerDto (com.alliander.osgp.dto.valueobjects.PowerUsageHistoryResponseMessageDataContainerDto)2 FunctionalException (com.alliander.osgp.shared.exceptionhandling.FunctionalException)2 NotSupportedException (com.alliander.osgp.shared.exceptionhandling.NotSupportedException)2 DaDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.da.rtu.DaDeviceResponse)1 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)1 GetConfigurationDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetConfigurationDeviceResponse)1 GetDataDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse)1