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