Search in sources :

Example 76 with RequestMessage

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

the class PushNotificationSmsMessageProcessorTest method init.

@BeforeEach
public void init() throws JMSException {
    final String correlationUid = "corr-uid-1";
    final String organisationIdentification = "test-org";
    final RequestMessage requestMessage = new RequestMessage(correlationUid, organisationIdentification, DEVICE_IDENTIFICATION, IP_ADDRESS, null, null, this.pushNotificationSms);
    this.message = new ObjectMessageBuilder().withCorrelationUid(correlationUid).withMessageType(MessageType.PUSH_NOTIFICATION_SMS.name()).withDeviceIdentification(DEVICE_IDENTIFICATION).withObject(requestMessage).build();
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 77 with RequestMessage

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

the class EventNotificationMessageService method sendRequestMessageToDomainPublicLighting.

/**
 * Send a request message to OSGP-ADAPTER-DOMAIN-PUBLICLIGHTING.
 */
private void sendRequestMessageToDomainPublicLighting(final String messageType, final String deviceIdentification, final Serializable dataObject) {
    final String correlationUid = this.correlationIdProviderTimestampService.getCorrelationId(this.netmanagementOrganisation, deviceIdentification);
    final RequestMessage message = new RequestMessage(correlationUid, this.netmanagementOrganisation, deviceIdentification, dataObject);
    final DomainInfo domainInfo = this.eventNotificationHelperService.findDomainInfo(DomainTypeDto.PUBLIC_LIGHTING.name(), "1.0");
    this.domainRequestService.send(message, messageType, domainInfo);
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo)

Example 78 with RequestMessage

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

the class DeviceRegistrationMessageService method sendRequestMessageToDomainCore.

public void sendRequestMessageToDomainCore(final String deviceIdentification, final String organisationIdentification, final String correlationUid, final MessageType messageType) {
    final RequestMessage message = new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, null);
    final DomainInfo domainInfo = this.domainInfoRepository.findByDomainAndDomainVersion("CORE", "1.0");
    this.domainRequestService.send(message, messageType.name(), domainInfo);
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) DomainInfo(org.opensmartgridplatform.domain.core.entities.DomainInfo)

Example 79 with RequestMessage

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

the class Iec61850ChannelHandlerServer method processRegistrationMessage.

private void processRegistrationMessage(final RegisterDeviceRequest message, final String correlationId) {
    this.logMessage(message);
    final String deviceIdentification = message.getDeviceIdentification();
    if (this.deviceRegistrationService.isKnownDevice(deviceIdentification)) {
        LOGGER.info("Device {} found, start processing this registration message", deviceIdentification);
    } else {
        LOGGER.warn("Ignoring this registration message, because there's no device having identification {}", deviceIdentification);
        return;
    }
    final IED ied = IED.FLEX_OVL;
    final String ipAddress;
    // set, the values will be used to set an IP address for a device.
    if (this.testDeviceIps != null && this.testDeviceIps.containsKey(deviceIdentification)) {
        final String testDeviceIp = this.testDeviceIps.get(deviceIdentification);
        LOGGER.info("Using testDeviceId: {} and testDeviceIp: {}", deviceIdentification, testDeviceIp);
        ipAddress = testDeviceIp;
    } else {
        ipAddress = message.getIpAddress();
    }
    final DeviceRegistrationDataDto deviceRegistrationData = new DeviceRegistrationDataDto(ipAddress, Ssld.SSLD_TYPE, true);
    final RequestMessage requestMessage = new RequestMessage(correlationId, NO_ORGANISATION, deviceIdentification, ipAddress, null, null, deviceRegistrationData);
    LOGGER.info("Sending register device request to OSGP with correlation ID: {}", correlationId);
    this.osgpRequestMessageSender.send(requestMessage, MessageType.REGISTER_DEVICE.name());
    try {
        this.deviceRegistrationService.disableRegistration(deviceIdentification, InetAddress.getByName(ipAddress), ied, ied.getDescription());
        final RequestMessage cdrRequestMessage = new RequestMessage(correlationId, NO_ORGANISATION, deviceIdentification, ipAddress);
        this.osgpRequestMessageSender.send(cdrRequestMessage, MessageType.DEVICE_REGISTRATION_COMPLETED.name());
        LOGGER.info("Disabled registration for device: {}, at IP address: {}", deviceIdentification, ipAddress);
    } catch (final Exception e) {
        LOGGER.error("Failed to disable registration for device: {}, at IP address: {}", deviceIdentification, ipAddress, e);
    }
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) IED(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.IED) DeviceRegistrationDataDto(org.opensmartgridplatform.dto.valueobjects.DeviceRegistrationDataDto)

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