Search in sources :

Example 1 with RequestMessage

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

the class OsgpCoreRequestMessageSender method send.

private void send(final RequestMessage requestMessage, final String messageType, final int messagePriority, final String ipAddress, final Long scheduledTime, final Long delay) {
    final String correlationUid = requestMessage.getCorrelationUid();
    final String organisationIdentification = requestMessage.getOrganisationIdentification();
    final String deviceIdentification = requestMessage.getDeviceIdentification();
    this.jmsTemplate.send(new MessageCreator() {

        @Override
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage();
            objectMessage.setJMSType(messageType);
            objectMessage.setJMSPriority(messagePriority);
            objectMessage.setJMSCorrelationID(correlationUid);
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, organisationIdentification);
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, deviceIdentification);
            objectMessage.setStringProperty(Constants.IP_ADDRESS, ipAddress);
            if (scheduledTime != null) {
                objectMessage.setLongProperty(Constants.SCHEDULE_TIME, scheduledTime);
            }
            if (delay != null) {
                objectMessage.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
            }
            objectMessage.setObject(requestMessage.getRequest());
            return objectMessage;
        }
    });
}
Also used : ScheduledMessage(org.apache.activemq.ScheduledMessage) ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) MessageCreator(org.springframework.jms.core.MessageCreator) Session(javax.jms.Session)

Example 2 with RequestMessage

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

the class CommonRelayStatusUpdatedMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    MessageMetadata messageMetadata;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        return;
    }
    final RequestMessage requestMsg = new RequestMessage(messageMetadata.getCorrelationUid(), messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification(), null);
    this.webServiceRequestMessageSender.send(requestMsg, messageMetadata.getMessageType());
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) JMSException(javax.jms.JMSException)

Example 3 with RequestMessage

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

the class DeviceManagementService method updateDeviceSslCertification.

@Transactional(value = "transactionManager")
public void updateDeviceSslCertification(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final Certification certification, final String messageType, final int messagePriority) throws FunctionalException {
    LOGGER.debug("UpdateDeviceSslCertification called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    this.findOrganisation(organisationIdentification);
    final Device device = this.findActiveDevice(deviceIdentification);
    if (certification == null) {
        LOGGER.info("Certification is empty, skip sending a request to device");
        return;
    }
    final org.opensmartgridplatform.dto.valueobjects.CertificationDto certificationDto = this.domainCoreMapper.map(certification, org.opensmartgridplatform.dto.valueobjects.CertificationDto.class);
    this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, certificationDto), messageType, messagePriority, device.getIpAddress());
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with RequestMessage

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

the class FirmwareManagementService method updateFirmware.

// === UPDATE FIRMWARE ===
public void updateFirmware(final CorrelationIds ids, final FirmwareUpdateMessageDataContainer firmwareUpdateMessageDataContainer, final Long scheduleTime, final String messageType, final int messagePriority) throws FunctionalException {
    LOGGER.debug("Update firmware called with organisation [{}], device [{}], firmwareIdentification [{}].", ids.getOrganisationIdentification(), ids.getDeviceIdentification(), firmwareUpdateMessageDataContainer.getFirmwareUrl());
    this.findOrganisation(ids.getOrganisationIdentification());
    final Device device = this.findActiveDevice(ids.getDeviceIdentification());
    if (device instanceof Ssld) {
        this.createSsldPendingFirmwareUpdateRecord(ids, firmwareUpdateMessageDataContainer.getFirmwareUrl());
    }
    this.osgpCoreRequestMessageSender.sendWithScheduledTime(new RequestMessage(ids, this.domainCoreMapper.map(firmwareUpdateMessageDataContainer, org.opensmartgridplatform.dto.valueobjects.FirmwareUpdateMessageDataContainer.class)), messageType, messagePriority, device.getIpAddress(), scheduleTime);
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) Ssld(org.opensmartgridplatform.domain.core.entities.Ssld)

Example 5 with RequestMessage

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

the class FirmwareManagementService method getFirmwareVersion.

public void getFirmwareVersion(@Identification final String organisationIdentification, @Identification final String deviceIdentification, final String correlationUid, final String messageType, final int messagePriority, final Long delay) throws FunctionalException {
    LOGGER.debug("Get firmware version called with organisation [{}], device [{}].", organisationIdentification, deviceIdentification);
    this.findOrganisation(organisationIdentification);
    final Device device = this.findActiveDevice(deviceIdentification);
    this.osgpCoreRequestMessageSender.sendWithDelay(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, null), messageType, messagePriority, device.getIpAddress(), delay);
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) 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