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);
}
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);
}
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);
}
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);
}
}
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);
}
}
Aggregations