Source:
public void processMessage(final ObjectMessage message) throws JMSException { LOGGER.debug("Processing request message", this.osgpRequestMessageType.name()); MessageMetadata messageMetadata = null; DlmsConnectionHolder conn = null; DlmsDevice device = null; try { messageMetadata = MessageMetadata.fromMessage(message); device = this.domainHelperService.findDlmsDevice(messageMetadata); LOGGER.info("{} called for device: for organisation: {}", message.getJMSType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification()); Serializable response = null; if (this.usesDeviceConnection()) { 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(device, message); } } catch (final JMSException exception) { this.logJmsException(LOGGER, exception, messageMetadata); } catch (final Exception exception) { LOGGER.error("Unexpected exception during {}", this.osgpRequestMessageType.name(), exception); } finally { if (conn != null) { LOGGER.info("Closing connection with {}", device.getDeviceIdentification()); conn.getDlmsMessageListener().setDescription("Close connection"); try { conn.close(); } catch (final Exception e) { LOGGER.error("Error while closing connection", e); } } } }

Target:
public void processMessage(final ObjectMessage message) throws JMSException { LOGGER.debug("Processing request message", this.osgpRequestMessageType.name()); MessageMetadata messageMetadata = null; DlmsConnectionHolder conn = null; DlmsDevice device = null; try { messageMetadata = MessageMetadata.fromMessage(message); device = this.domainHelperService.findDlmsDevice(messageMetadata); LOGGER.info("{} called for device: for organisation: {}", message.getJMSType(), messageMetadata.getDeviceIdentification(), messageMetadata.getOrganisationIdentification()); if (this.usesDeviceConnection()) { 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); this.handleMessage(conn, device, message.getObject()); } else { this.handleMessage(device, message); } } catch (final JMSException exception) { this.logJmsException(LOGGER, exception, messageMetadata); } catch (final Exception exception) { LOGGER.error("Unexpected exception during {}", this.osgpRequestMessageType.name(), exception); this.sendResponseMessage(messageMetadata, ResponseMessageResultType.NOT_OK, exception, this.responseMessageSender, message.getObject()); } finally { if (conn != null) { LOGGER.info("Closing connection with {}", device.getDeviceIdentification()); conn.getDlmsMessageListener().setDescription("Close connection"); try { conn.close(); } catch (final Exception e) { LOGGER.error("Error while closing connection", e); } } } }