Search in sources :

Example 16 with RequestMessage

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

the class AdHocManagementServiceTest method testSetReboot.

@Test
public void testSetReboot() throws Exception {
    this.givenOnlyTheIdentifiedOrganisationExists(ORGANISATION_IDENTIFICATION);
    final ArgumentCaptor<RequestMessage> messageCaptor = ArgumentCaptor.forClass(RequestMessage.class);
    this.adHocManagementService.setReboot(ORGANISATION_IDENTIFICATION, DEVICE_IDENTIFICATION, CORRELATION_UUID, MESSAGE_TYPE, PRIORITY);
    verify(this.osgpCoreRequestMessageSender).send(messageCaptor.capture(), eq(MESSAGE_TYPE), eq(PRIORITY), eq(IP_ADDRESS));
    final RequestMessage message = messageCaptor.getValue();
    assertThat(message.getCorrelationUid()).isEqualTo(CORRELATION_UUID);
    assertThat(message.getOrganisationIdentification()).isEqualTo(ORGANISATION_IDENTIFICATION);
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) Test(org.junit.jupiter.api.Test)

Example 17 with RequestMessage

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

the class DeviceInstallationService method startSelfTest.

// === START DEVICE TEST ===
public void startSelfTest(@Identification final String deviceIdentification, @Identification final String organisationIdentification, final String correlationUid, final String messageType, final int messagePriority) throws FunctionalException {
    LOGGER.debug("startSelfTest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    this.findOrganisation(organisationIdentification);
    final Device device = this.findActiveDevice(deviceIdentification);
    this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, null), messageType, messagePriority, device.getIpAddress());
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice) Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Example 18 with RequestMessage

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

the class DeviceInstallationService method stopSelfTest.

// === STOP DEVICE TEST ===
public void stopSelfTest(@Identification final String deviceIdentification, @Identification final String organisationIdentification, final String correlationUid, final String messageType, final int messagePriority) throws FunctionalException {
    LOGGER.debug("stopSelfTest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    this.findOrganisation(organisationIdentification);
    final Device device = this.findActiveDevice(deviceIdentification);
    this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, null), messageType, messagePriority, device.getIpAddress());
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice) Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Example 19 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 20 with RequestMessage

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

the class DlmsChannelHandlerServer method processPushedAlarm.

private void processPushedAlarm(final DlmsPushNotification message, final String correlationId, final String deviceIdentification, final String ipAddress) {
    this.logMessage(message);
    final PushNotificationAlarmDto pushNotificationAlarm = new PushNotificationAlarmDto(deviceIdentification, message.getAlarms(), message.toByteArray());
    final RequestMessage requestMessage = new RequestMessage(correlationId, "no-organisation", deviceIdentification, ipAddress, null, null, pushNotificationAlarm);
    final MessageMetadata messageMetadata = new Builder().withMessagePriority(MessagePriorityEnum.HIGH.getPriority()).build();
    log.info("Sending push notification alarm to GXF with correlation ID: {}", correlationId);
    this.osgpRequestMessageSender.send(requestMessage, MessageType.PUSH_NOTIFICATION_ALARM.name(), messageMetadata);
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) PushNotificationAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushNotificationAlarmDto) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder)

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