use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class CommonStopDeviceTestRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing common stop device test 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;
}
this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
final DeviceRequest deviceRequest = DeviceRequest.newBuilder().messageMetaData(messageMetadata).build();
this.deviceService.stopSelfTest(deviceRequest);
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class CommonUpdateFirmwareRequestMessageProcessor method processMessage.
// IDEA: the FirmwareLocation class in domain and dto can/must be deleted!
// Or, this
// setup has to be changed in order to reuse the FirmwareLocation class in
// the domain!!
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing common update firmware request message");
MessageMetadata messageMetadata;
FirmwareUpdateMessageDataContainer firmwareUpdateMessageDataContainer;
try {
messageMetadata = MessageMetadata.fromMessage(message);
firmwareUpdateMessageDataContainer = (FirmwareUpdateMessageDataContainer) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
try {
final String firmwareIdentification = firmwareUpdateMessageDataContainer.getFirmwareUrl();
this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
final UpdateFirmwareDeviceRequest deviceRequest = new UpdateFirmwareDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), this.firmwareLocation.getDomain(), this.firmwareLocation.getFullPath(firmwareIdentification));
this.deviceService.updateFirmware(deviceRequest);
} catch (final RuntimeException e) {
this.handleError(e, messageMetadata);
}
}
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, final String errorMessage) {
try {
final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
final OsgpException osgpException = new OsgpException(ComponentType.PROTOCOL_OSLP, errorMessage, exception);
final Serializable dataObject = objectMessage.getObject();
final MessageMetadata messageMetadata = MessageMetadata.fromMessage(objectMessage).builder().withScheduled(false).build();
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).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 PublicLightingSetTransitionRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing public lighting set transition request message");
MessageMetadata messageMetadata;
TransitionMessageDataContainerDto transitionMessageDataContainer;
try {
messageMetadata = MessageMetadata.fromMessage(message);
transitionMessageDataContainer = (TransitionMessageDataContainerDto) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
try {
this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
final SetTransitionDeviceRequest deviceRequest = new SetTransitionDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), transitionMessageDataContainer);
this.deviceService.setTransition(deviceRequest);
} catch (final RuntimeException e) {
this.handleError(e, messageMetadata);
}
}
use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.
the class TariffSwitchingSetScheduleRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing tariff switching set schedule request message");
MessageMetadata messageMetadata;
ScheduleDto schedule;
try {
messageMetadata = MessageMetadata.fromMessage(message);
schedule = (ScheduleDto) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
try {
final ScheduleMessageDataContainerDto scheduleMessageDataContainer = new ScheduleMessageDataContainerDto.Builder(schedule).build();
this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
final SetScheduleDeviceRequest deviceRequest = new SetScheduleDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), scheduleMessageDataContainer, RelayTypeDto.TARIFF);
this.deviceService.setSchedule(deviceRequest);
} catch (final RuntimeException e) {
this.handleError(e, messageMetadata);
}
}
Aggregations