Search in sources :

Example 6 with RequestMessage

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

the class CommunicationRecoveryService method restoreCommunication.

public void restoreCommunication(final RtuDevice rtu) {
    LOGGER.info("Restoring communication for device {}.", rtu.getDeviceIdentification());
    if (rtu.getOwner() == null) {
        LOGGER.warn("Device {} has no owner. Skipping communication recovery.", rtu.getDeviceIdentification());
        return;
    }
    final RequestMessage message = this.createMessage(rtu);
    this.osgpCoreRequestMessageSender.send(message, DeviceFunction.GET_DATA.toString(), rtu.getIpAddress());
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Example 7 with RequestMessage

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

the class MonitoringService method getPQValues.

public void getPQValues(final CorrelationIds ids, final String messageType, final GetPQValuesRequest getPQValuesRequest) throws FunctionalException {
    LOGGER.info("Get PQ Values for device [{}] with correlation id [{}]", ids.getDeviceIdentification(), ids.getCorrelationUid());
    this.findOrganisation(ids.getOrganisationIdentification());
    final Device device = this.findActiveDevice(ids.getDeviceIdentification());
    final GetPQValuesRequestDto dto = this.mapper.map(getPQValuesRequest, GetPQValuesRequestDto.class);
    this.osgpCoreRequestMessageSender.send(new RequestMessage(ids, dto), messageType, device.getIpAddress());
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) GetPQValuesRequestDto(org.opensmartgridplatform.dto.da.GetPQValuesRequestDto)

Example 8 with RequestMessage

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

the class DeviceManagementService method revokeKey.

// === REVOKE KEY ===
public void revokeKey(final String organisationIdentification, @Identification final String deviceIdentification, final String correlationUid, final String messageType) throws FunctionalException {
    LOGGER.info("MessageType: {}. Revoking key for device [{}] on behalf of organisation [{}]", messageType, deviceIdentification, organisationIdentification);
    try {
        this.organisationDomainService.searchOrganisation(organisationIdentification);
    } catch (final UnknownEntityException e) {
        throw new FunctionalException(FunctionalExceptionType.UNKNOWN_ORGANISATION, ComponentType.DOMAIN_ADMIN, e);
    }
    this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, null), messageType, null);
}
Also used : UnknownEntityException(org.opensmartgridplatform.domain.core.exceptions.UnknownEntityException) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)

Example 9 with RequestMessage

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

the class OsgpCoreRequestMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        LOGGER.info("Received message");
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final String messageType = objectMessage.getJMSType();
        final RequestMessage requestMessage = (RequestMessage) objectMessage.getObject();
        this.messageProcessor.processMessage(requestMessage, messageType);
    } catch (final JMSException e) {
        // Can't read message.
        LOGGER.error("Exception: {}, StackTrace: {}", e.getMessage(), e.getStackTrace(), e);
    } catch (final UnknownMessageTypeException e) {
        // Don't know this message.
        LOGGER.error("UnknownMessageTypeException", e);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) JMSException(javax.jms.JMSException) UnknownMessageTypeException(org.opensmartgridplatform.shared.infra.jms.UnknownMessageTypeException)

Example 10 with RequestMessage

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

the class AdHocManagementService method handleSetDataRequest.

// === SET DATA ===
public void handleSetDataRequest(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final String messageType, final SetDataRequest setDataRequest) throws FunctionalException {
    LOGGER.info("Set data for device [{}] with correlation id [{}]", deviceIdentification, correlationUid);
    this.findOrganisation(organisationIdentification);
    final Device device = this.findActiveDevice(deviceIdentification);
    final SetDataRequestDto dto = this.mapper.map(setDataRequest, SetDataRequestDto.class);
    this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, dto), messageType, device.getIpAddress());
}
Also used : SetDataRequestDto(org.opensmartgridplatform.dto.valueobjects.microgrids.SetDataRequestDto) Device(org.opensmartgridplatform.domain.core.entities.Device) RtuDevice(org.opensmartgridplatform.domain.core.entities.RtuDevice) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Aggregations

RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)79 Device (org.opensmartgridplatform.domain.core.entities.Device)33 JMSException (javax.jms.JMSException)18 ObjectMessage (javax.jms.ObjectMessage)13 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)11 Test (org.junit.jupiter.api.Test)9 DomainInfo (org.opensmartgridplatform.domain.core.entities.DomainInfo)7 LightMeasurementDevice (org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice)6 Message (javax.jms.Message)5 Session (javax.jms.Session)5 RtuDevice (org.opensmartgridplatform.domain.core.entities.RtuDevice)5 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)5 UnknownEntityException (org.opensmartgridplatform.domain.core.exceptions.UnknownEntityException)4 MessageCreator (org.springframework.jms.core.MessageCreator)4 Transactional (org.springframework.transaction.annotation.Transactional)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 CdmaDevice (org.opensmartgridplatform.domain.core.valueobjects.CdmaDevice)3 EventNotificationDto (org.opensmartgridplatform.dto.valueobjects.EventNotificationDto)3 SystemEventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto)3 ObjectMessageBuilder (org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder)3