Search in sources :

Example 11 with RequestMessage

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

the class CommunicationRecoveryService method createMessage.

private RequestMessage createMessage(final RtuDevice rtu) {
    LOGGER.debug("Creating message for device {}.", rtu.getDeviceIdentification());
    final String correlationUid = this.createCorrelationUid(rtu);
    final String organisationIdentification = rtu.getOwner().getOrganisationIdentification();
    final String deviceIdentification = rtu.getDeviceIdentification();
    final GetDataRequestDto request = this.createRequest(rtu);
    return new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, request);
}
Also used : GetDataRequestDto(org.opensmartgridplatform.dto.valueobjects.microgrids.GetDataRequestDto) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Example 12 with RequestMessage

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

the class DeviceManagementServiceTest method testSetDeviceVerificationKey.

@Test
public void testSetDeviceVerificationKey() throws FunctionalException {
    final Device device = mock(Device.class);
    when(device.getIpAddress()).thenReturn(TEST_IP);
    when(this.deviceDomainService.searchActiveDevice(TEST_DEVICE, ComponentType.DOMAIN_CORE)).thenReturn(device);
    this.deviceManagementService.setDeviceVerificationKey(TEST_ORGANISATION, TEST_DEVICE, TEST_UID, "testKey", TEST_MESSAGE_TYPE, TEST_PRIORITY);
    verify(this.osgpCoreRequestManager).send(this.argumentRequestMessage.capture(), this.argumentMessageType.capture(), this.argumentPriority.capture(), this.argumentIpAddress.capture());
    final RequestMessage expectedRequestMessage = this.createNewRequestMessage("testKey");
    assertThat(this.argumentRequestMessage.getValue()).usingRecursiveComparison().isEqualTo(expectedRequestMessage);
    assertThat(this.argumentMessageType.getValue()).isEqualTo(TEST_MESSAGE_TYPE);
    assertThat(this.argumentPriority.getValue()).isEqualTo(TEST_PRIORITY);
    assertThat(this.argumentIpAddress.getValue()).isEqualTo(TEST_IP);
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) Test(org.junit.jupiter.api.Test)

Example 13 with RequestMessage

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

the class DeviceManagementServiceTest method testUpdateDeviceSslCertification.

@Test
public void testUpdateDeviceSslCertification() throws FunctionalException {
    final Device device = mock(Device.class);
    when(device.getIpAddress()).thenReturn(TEST_IP);
    when(this.deviceDomainService.searchActiveDevice(TEST_DEVICE, ComponentType.DOMAIN_CORE)).thenReturn(device);
    final Certification certification = new Certification("testUrl", "testDomain");
    this.deviceManagementService.updateDeviceSslCertification(TEST_ORGANISATION, TEST_DEVICE, TEST_UID, certification, TEST_MESSAGE_TYPE, TEST_PRIORITY);
    verify(this.osgpCoreRequestManager).send(this.argumentRequestMessage.capture(), this.argumentMessageType.capture(), this.argumentPriority.capture(), this.argumentIpAddress.capture());
    final RequestMessage expectedRequestMessage = this.createNewRequestMessage(this.domainCoreMapper.map(certification, CertificationDto.class));
    assertThat(this.argumentRequestMessage.getValue()).usingRecursiveComparison().isEqualTo(expectedRequestMessage);
    assertThat(this.argumentMessageType.getValue()).isEqualTo(TEST_MESSAGE_TYPE);
    assertThat(this.argumentPriority.getValue()).isEqualTo(TEST_PRIORITY);
    assertThat(this.argumentIpAddress.getValue()).isEqualTo(TEST_IP);
}
Also used : CertificationDto(org.opensmartgridplatform.dto.valueobjects.CertificationDto) Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) Certification(org.opensmartgridplatform.domain.core.valueobjects.Certification) Test(org.junit.jupiter.api.Test)

Example 14 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.osgpCoreRequestMessageProcessor.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 15 with RequestMessage

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

the class SigningServerRequestMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final Destination replyToQueue = objectMessage.getJMSReplyTo();
        final int messagePriority = objectMessage.getJMSPriority();
        final RequestMessage requestMessage = (RequestMessage) objectMessage.getObject();
        final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = (UnsignedOslpEnvelopeDto) requestMessage.getRequest();
        final String correlationUid = objectMessage.getJMSCorrelationID();
        final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        LOGGER.info("Received message of type: {}, for device: {} with correlationId: {} and replyToQueue: {}", objectMessage.getJMSType(), deviceIdentification, correlationUid, replyToQueue);
        LOGGER.debug("-----------------------------------------------------------------------------");
        LOGGER.debug("messagePriority: {}", messagePriority);
        LOGGER.debug("unsignedOslpEnvelopeDto.getCorrelationUid() : {}", unsignedOslpEnvelopeDto.getCorrelationUid());
        LOGGER.debug("unsignedOslpEnvelopeDto.getDeviceId() : {}", unsignedOslpEnvelopeDto.getDeviceId());
        LOGGER.debug("unsignedOslpEnvelopeDto.getDomain() : {}", unsignedOslpEnvelopeDto.getDomain());
        LOGGER.debug("unsignedOslpEnvelopeDto.getDomainVersion() : {}", unsignedOslpEnvelopeDto.getDomainVersion());
        LOGGER.debug("unsignedOslpEnvelopeDto.getIpAddress() : {}", unsignedOslpEnvelopeDto.getIpAddress());
        LOGGER.debug("unsignedOslpEnvelopeDto.getMessageType() : {}", unsignedOslpEnvelopeDto.getMessageType());
        LOGGER.debug("unsignedOslpEnvelopeDto.getMessagePriority() : {}", unsignedOslpEnvelopeDto.getMessagePriority());
        LOGGER.debug("unsignedOslpEnvelopeDto.getOrganisationIdentification() : {}", unsignedOslpEnvelopeDto.getOrganisationIdentification());
        LOGGER.debug("unsignedOslpEnvelopeDto.getPayloadMessage() : {}", unsignedOslpEnvelopeDto.getPayloadMessage());
        LOGGER.debug("unsignedOslpEnvelopeDto.getRetryCount() : {}", unsignedOslpEnvelopeDto.getRetryCount());
        LOGGER.debug("unsignedOslpEnvelopeDto.getSequenceNumber() : {}", unsignedOslpEnvelopeDto.getSequenceNumber());
        LOGGER.debug("unsignedOslpEnvelopeDto.isScheduled() : {}", unsignedOslpEnvelopeDto.isScheduled());
        LOGGER.debug("-----------------------------------------------------------------------------");
        this.signingService.sign(unsignedOslpEnvelopeDto, correlationUid, deviceIdentification, replyToQueue);
    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    }
}
Also used : Destination(javax.jms.Destination) UnsignedOslpEnvelopeDto(org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto) ObjectMessage(javax.jms.ObjectMessage) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) JMSException(javax.jms.JMSException)

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