use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class PublicLightingSetScheduleRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing public lighting set schedule request message");
MessageMetadata messageMetadata;
ScheduleDto scheduleDto;
try {
messageMetadata = MessageMetadata.fromMessage(message);
scheduleDto = (ScheduleDto) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
final RequestMessageData requestMessageData = RequestMessageData.newBuilder().messageMetadata(messageMetadata).build();
this.printDomainInfo(requestMessageData);
final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
final DeviceRequest.Builder deviceRequestBuilder = DeviceRequest.newBuilder().messageMetaData(messageMetadata);
this.deviceService.setSchedule(new SetScheduleDeviceRequest(deviceRequestBuilder, scheduleDto, RelayTypeDto.LIGHT), iec61850DeviceResponseHandler);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class TariffSwitchingGetStatusRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing tariff switching get status request message");
MessageMetadata messageMetadata;
try {
messageMetadata = MessageMetadata.fromMessage(message);
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
final RequestMessageData requestMessageData = RequestMessageData.newBuilder().messageMetadata(messageMetadata).build();
this.printDomainInfo(requestMessageData);
final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
final DeviceRequest deviceRequest = DeviceRequest.newBuilder().messageMetaData(messageMetadata).build();
this.deviceService.getStatus(deviceRequest, iec61850DeviceResponseHandler);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class CommonRebootRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing common reboot request message");
MessageMetadata messageMetadata;
messageMetadata = null;
try {
messageMetadata = MessageMetadata.fromMessage(message);
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
final RequestMessageData requestMessageData = RequestMessageData.newBuilder().messageMetadata(messageMetadata).build();
this.printDomainInfo(requestMessageData);
final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
final DeviceRequest deviceRequest = DeviceRequest.newBuilder().messageMetaData(messageMetadata).build();
this.deviceService.setReboot(deviceRequest, iec61850DeviceResponseHandler);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageListener method sendException.
private void sendException(final ObjectMessage objectMessage, final Exception exception) {
try {
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 MessageMetadata messageMetadata = MessageMetadata.fromMessage(objectMessage);
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata.builder().withScheduled(false).build()).result(result).osgpException(osgpException).dataObject(dataObject).build();
this.deviceResponseMessageSender.send(protocolResponseMessage);
} catch (final Exception e) {
LOGGER.error("Unexpected error during sendException(ObjectMessage, Exception)", e);
}
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class DefaultDeviceResponseService method handleDefaultDeviceResponse.
public void handleDefaultDeviceResponse(final CorrelationIds ids, final String messageType, final int messagePriority, final ResponseMessageResultType deviceResult, final OsgpException exception) {
LOGGER.info("handleDefaultDeviceResponse for MessageType: {}", messageType);
ResponseMessageResultType result = deviceResult;
OsgpException osgpException = exception;
if (deviceResult == ResponseMessageResultType.NOT_OK && exception == null) {
LOGGER.error("Incorrect response received, exception should not be null when result is not ok");
osgpException = new TechnicalException(ComponentType.DOMAIN_TARIFF_SWITCHING, "An unknown error occurred");
}
if (deviceResult == ResponseMessageResultType.OK && exception != null) {
LOGGER.error("Incorrect response received, result should be set to not ok when exception is not null");
result = ResponseMessageResultType.NOT_OK;
}
final MessageMetadata metaData = new MessageMetadata.Builder().withCorrelationUid(ids.getCorrelationUid()).withDeviceIdentification(ids.getDeviceIdentification()).withOrganisationIdentification(ids.getOrganisationIdentification()).withMessageType(messageType).build();
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(metaData).withResult(result).withOsgpException(osgpException).withMessagePriority(messagePriority).build();
this.webServiceResponseMessageSender.send(responseMessage);
}
Aggregations