Search in sources :

Example 21 with MessageProcessor

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

the class WebServiceRequestMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        LOGGER.info("Received message of type: {}", message.getJMSType());
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage);
        processor.processMessage(objectMessage);
    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) JMSException(javax.jms.JMSException)

Example 22 with MessageProcessor

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

the class TariffSwitchingResponseMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        final String messageType = message.getJMSType();
        LOGGER.info("Received message of type: {}", messageType);
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final String correlationUid = objectMessage.getJMSCorrelationID();
        LOGGER.info("objectMessage CorrelationUID: {}", correlationUid);
        final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage);
        processor.processMessage(objectMessage);
    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) JMSException(javax.jms.JMSException)

Example 23 with MessageProcessor

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

the class DeviceRequestMessageListenerTest method shouldProcessMessageWhenMessageTypeIsSupported.

@Test
void shouldProcessMessageWhenMessageTypeIsSupported() throws JMSException {
    // Arrange
    final String correlationUid = DEFAULT_CORRELATION_UID;
    final ObjectMessage message = new ObjectMessageBuilder().withCorrelationUid(correlationUid).withDeviceIdentification(DEFAULT_DEVICE_IDENTIFICATION).withMessageType(DEFAULT_MESSAGE_TYPE).withObject(new GetHealthStatusRequestDto()).build();
    final MessageProcessor messageProcessor = mock(GetHealthStatusRequestMessageProcessor.class);
    when(this.iec60870RequestMessageProcessorMap.getMessageProcessor(message)).thenReturn(messageProcessor);
    // Act
    this.deviceRequestMessageListener.onMessage(message);
    // Assert
    verify(this.pendingRequestsQueue).enqueue(DEFAULT_DEVICE_IDENTIFICATION, correlationUid);
    verify(messageProcessor).processMessage(message);
}
Also used : GetHealthStatusRequestDto(org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto) ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) GetHealthStatusRequestMessageProcessor(org.opensmartgridplatform.adapter.protocol.iec60870.infra.messaging.processors.GetHealthStatusRequestMessageProcessor) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) Test(org.junit.jupiter.api.Test)

Example 24 with MessageProcessor

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

the class WebServiceRequestMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        LOGGER.info("Received message of type: {}", message.getJMSType());
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage);
        processor.processMessage(objectMessage);
    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) JMSException(javax.jms.JMSException)

Example 25 with MessageProcessor

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

the class OsgpCoreResponseMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        LOGGER.info("Received message of type: {}", message.getJMSType());
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage);
        processor.processMessage(objectMessage);
    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) JMSException(javax.jms.JMSException)

Aggregations

ObjectMessage (javax.jms.ObjectMessage)28 MessageProcessor (org.opensmartgridplatform.shared.infra.jms.MessageProcessor)28 JMSException (javax.jms.JMSException)26 NotSupportedException (org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 Test (org.junit.jupiter.api.Test)1 GetHealthStatusRequestMessageProcessor (org.opensmartgridplatform.adapter.protocol.iec60870.infra.messaging.processors.GetHealthStatusRequestMessageProcessor)1 GetHealthStatusRequestDto (org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 MessageType (org.opensmartgridplatform.shared.infra.jms.MessageType)1 ObjectMessageBuilder (org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder)1 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)1