Source:
public void processMessage(final ObjectMessage message) throws JMSException { LOGGER.debug("Processing request message", this.deviceRequestMessageType.name()); final DlmsDeviceMessageMetadata messageMetadata = new DlmsDeviceMessageMetadata(); DlmsConnectionHolder conn = null; DlmsDevice device = null; final boolean isScheduled = message.propertyExists(Constants.IS_SCHEDULED) ? message.getBooleanProperty(Constants.IS_SCHEDULED) : false; try { messageMetadata.handleMessage(message); LOGGER.info("{} called for device: for organisation: {}", message.getJMSType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification()); Serializable response = null; if (this.usesDeviceConnection()) { device = this.domainHelperService.findDlmsDevice(messageMetadata); final DlmsMessageListener dlmsMessageListener; if (device.isInDebugMode()) { dlmsMessageListener = new DlmsMessageListener(device.getDeviceIdentification(), this.dlmsLogItemRequestMessageSender); dlmsMessageListener.setMessageMetadata(messageMetadata); dlmsMessageListener.setDescription("Create connection"); } else { dlmsMessageListener = null; } conn = this.dlmsConnectionFactory.getConnection(device, dlmsMessageListener); response = this.handleMessage(conn, device, message.getObject()); } else { response = this.handleMessage(message.getObject()); } this.sendResponseMessage(messageMetadata, ResponseMessageResultType.OK, null, this.responseMessageSender, response, isScheduled); } catch (final JMSException exception) { this.logJmsException(LOGGER, exception, messageMetadata); } catch (final Exception exception) { LOGGER.error("Unexpected exception during {}", this.deviceRequestMessageType.name(), exception); this.sendResponseMessage(messageMetadata, ResponseMessageResultType.NOT_OK, exception, this.responseMessageSender, message.getObject(), isScheduled); } finally { if (conn != null) { LOGGER.info("Closing connection with {}", device.getDeviceIdentification()); if (conn.hasDlmsMessageListener()) { conn.getDlmsMessageListener().setDescription("Close connection"); } try { conn.getConnection().close(); } catch (final IOException e) { LOGGER.error("Error while closing connection", e); } } } }

Target:
public void processMessage(final ObjectMessage message) throws JMSException { LOGGER.debug("Processing request message", this.deviceRequestMessageType.name()); final DlmsDeviceMessageMetadata messageMetadata = new DlmsDeviceMessageMetadata(); DlmsConnectionHolder conn = null; DlmsDevice device = null; final boolean isScheduled = message.propertyExists(Constants.IS_SCHEDULED) ? message.getBooleanProperty(Constants.IS_SCHEDULED) : false; try { messageMetadata.handleMessage(message); LOGGER.info("{} called for device: for organisation: {}", message.getJMSType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification()); Serializable response = null; if (this.usesDeviceConnection()) { device = this.domainHelperService.findDlmsDevice(messageMetadata); final LoggingDlmsMessageListener dlmsMessageListener; if (device.isInDebugMode()) { dlmsMessageListener = new LoggingDlmsMessageListener(device.getDeviceIdentification(), this.dlmsLogItemRequestMessageSender); dlmsMessageListener.setMessageMetadata(messageMetadata); dlmsMessageListener.setDescription("Create connection"); } else { dlmsMessageListener = null; } conn = this.dlmsConnectionFactory.getConnection(device, dlmsMessageListener); response = this.handleMessage(conn, device, message.getObject()); } else { response = this.handleMessage(message.getObject()); } this.sendResponseMessage(messageMetadata, ResponseMessageResultType.OK, null, this.responseMessageSender, response, isScheduled); } catch (final JMSException exception) { this.logJmsException(LOGGER, exception, messageMetadata); } catch (final Exception exception) { LOGGER.error("Unexpected exception during {}", this.deviceRequestMessageType.name(), exception); this.sendResponseMessage(messageMetadata, ResponseMessageResultType.NOT_OK, exception, this.responseMessageSender, message.getObject(), isScheduled); } finally { if (conn != null) { LOGGER.info("Closing connection with {}", device.getDeviceIdentification()); conn.getDlmsMessageListener().setDescription("Close connection"); try { conn.getConnection().close(); } catch (final IOException e) { LOGGER.error("Error while closing connection", e); } } } }