Search in sources :

Example 16 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 17 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)

Example 18 with MessageProcessor

use of org.opensmartgridplatform.shared.infra.jms.MessageProcessor 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 of type: {}", message.getJMSType());
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage);
        processor.processMessage(objectMessage);
    } catch (final Exception e) {
        /*
       * Just catch and log any exception. There is no response flow for
       * requests coming in from OSGP-Core, where exceptions should be
       * rapported to.
       */
        LOGGER.error("Exception while handling a request from OSGP-Core: ", e);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor)

Example 19 with MessageProcessor

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

the class DeviceRequestMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    ObjectMessage objectMessage = null;
    MessageMetadata messageMetadata = null;
    try {
        objectMessage = (ObjectMessage) message;
        messageMetadata = MessageMetadata.fromMessage(objectMessage);
    } catch (final Exception e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read JMS message instance, giving up.", e);
        return;
    }
    final String correlationUid = messageMetadata.getCorrelationUid();
    final String deviceIdentification = messageMetadata.getDeviceIdentification();
    try {
        LOGGER.info("Received message [correlationUid={}, messageType={}, messagePriority={}] for device {}", correlationUid, messageMetadata.getMessageType(), messageMetadata.getMessagePriority(), deviceIdentification);
        this.pendingRequestsQueue.enqueue(deviceIdentification, correlationUid);
        final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage);
        processor.processMessage(objectMessage);
    } catch (final IllegalArgumentException | JMSException e) {
        this.pendingRequestsQueue.remove(deviceIdentification, correlationUid);
        LOGGER.error("Unexpected exception for message [correlationUid={}]", correlationUid, e);
        this.sendNotSupportedException(objectMessage, messageMetadata);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) JMSException(javax.jms.JMSException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) JMSException(javax.jms.JMSException) NotSupportedException(org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException)

Example 20 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