@Test public void shouldProcessMessageWhenMessageTypeIsSupported() throws JMSException { final ObjectMessage message = new ObjectMessageBuilder().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); this.deviceRequestMessageListener.onMessage(message); verify(messageProcessor).processMessage(message); }
@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; } try { LOGGER.info("Received message [correlationUid={}, messageType={}, messagePriority={}]", messageMetadata.getCorrelationUid(), messageMetadata.getMessageType(), messageMetadata.getMessagePriority()); final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage); processor.processMessage(objectMessage); } catch (final IllegalArgumentException | JMSException e) { LOGGER.error("Unexpected exception for message [correlationUid={}]", messageMetadata.getCorrelationUid(), e); this.sendNotSupportedException(objectMessage, messageMetadata); } }
DeviceRequestMessageListener implements MessageListener { @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; } try { LOGGER.info("Received message [correlationUid={}, messageType={}, messagePriority={}]", messageMetadata.getCorrelationUid(), messageMetadata.getMessageType(), messageMetadata.getMessagePriority()); final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage); processor.processMessage(objectMessage); } catch (final IllegalArgumentException | JMSException e) { LOGGER.error("Unexpected exception for message [correlationUid={}]", messageMetadata.getCorrelationUid(), e); this.sendNotSupportedException(objectMessage, messageMetadata); } } }
DeviceRequestMessageListener implements MessageListener { @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; } try { LOGGER.info("Received message [correlationUid={}, messageType={}, messagePriority={}]", messageMetadata.getCorrelationUid(), messageMetadata.getMessageType(), messageMetadata.getMessagePriority()); final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage); processor.processMessage(objectMessage); } catch (final IllegalArgumentException | JMSException e) { LOGGER.error("Unexpected exception for message [correlationUid={}]", messageMetadata.getCorrelationUid(), e); this.sendNotSupportedException(objectMessage, messageMetadata); } }  }
DeviceRequestMessageListener implements MessageListener { @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; } try { LOGGER.info("Received message [correlationUid={}, messageType={}, messagePriority={}]", messageMetadata.getCorrelationUid(), messageMetadata.getMessageType(), messageMetadata.getMessagePriority()); final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage); processor.processMessage(objectMessage); } catch (final IllegalArgumentException | JMSException e) { LOGGER.error("Unexpected exception for message [correlationUid={}]", messageMetadata.getCorrelationUid(), e); this.sendNotSupportedException(objectMessage, messageMetadata); } }  @Override void onMessage(final Message message); }
DeviceRequestMessageListener implements MessageListener { @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; } try { LOGGER.info("Received message [correlationUid={}, messageType={}, messagePriority={}]", messageMetadata.getCorrelationUid(), messageMetadata.getMessageType(), messageMetadata.getMessagePriority()); final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage); processor.processMessage(objectMessage); } catch (final IllegalArgumentException | JMSException e) { LOGGER.error("Unexpected exception for message [correlationUid={}]", messageMetadata.getCorrelationUid(), e); this.sendNotSupportedException(objectMessage, messageMetadata); } }  @Override void onMessage(final Message message);  }