Source:
public void listen() throws InterruptedException { Properties properties = new Properties(); try { boolean validBroker = true; if (broker.equalsIgnoreCase("qpid")) { properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("qpid.properties")); } else if (broker.equalsIgnoreCase("activemq")) { properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("activemq.properties")); } else if (broker.equalsIgnoreCase("mb")) { properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("mb.properties")); } else { validBroker = false; log.error("Entered broker is invalid! "); } if (validBroker) { if (topic != null && topic.isEmpty() || topic.equals("\"\"")) { topic = null; } if (queue != null && queue.isEmpty() || queue.equals("\"\"")) { queue = null; } if (topic == null && queue == null) { log.error("Enter topic value or queue value! "); } else if (topic != null) { Context context = new InitialContext(properties); TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) context.lookup("ConnectionFactory"); TopicConsumer topicConsumer = new TopicConsumer(topicConnectionFactory, topic); Thread consumerThread = new Thread(topicConsumer); log.info("Starting" + broker + "consumerTopic thread..."); consumerThread.start(); Thread.sleep(1 * 60000); log.info("Shutting down " + broker + " consumerTopic..."); topicConsumer.shutdown(); } else { Context context = new InitialContext(properties); QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) context.lookup("ConnectionFactory"); QueueConsumer queueConsumer = new QueueConsumer(queueConnectionFactory, queue); Thread consumerThread = new Thread(queueConsumer); log.info("Starting" + broker + "consumerQueue thread..."); consumerThread.start(); Thread.sleep(1 * 60000); log.info("Shutting down " + broker + " consumerQueue..."); queueConsumer.shutdown(); } } } catch (IOException e) { log.error("Cannot read properties file from resources. " + e.getMessage(), e); } catch (NamingException e) { log.error("Invalid properties in the properties " + e.getMessage(), e); } }

Target:
public void listen() throws InterruptedException { Properties properties = new Properties(); try { if ("qpid".equalsIgnoreCase(broker)) { properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("qpid.properties")); } else if ("activemq".equalsIgnoreCase(broker)) { properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("activemq.properties")); } else if ("mb".equalsIgnoreCase(broker)) { properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream("mb.properties")); } else { log.error("Entered broker is invalid! "); } if (topic != null && topic.isEmpty() || topic.equals("\"\"")) { topic = null; } if (queue != null && queue.isEmpty() || queue.equals("\"\"")) { queue = null; } if (topic == null && queue == null) { log.error("Enter topic value or queue value! "); } else if (topic != null) { Context context = new InitialContext(properties); TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) context.lookup("ConnectionFactory"); TopicConsumer topicConsumer = new TopicConsumer(topicConnectionFactory, topic); Thread consumerThread = new Thread(topicConsumer); log.info("Starting" + broker + "consumerTopic thread..."); consumerThread.start(); Thread.sleep(1 * 60000); log.info("Shutting down " + broker + " consumerTopic..."); topicConsumer.shutdown(); } else { Context context = new InitialContext(properties); QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) context.lookup("ConnectionFactory"); QueueConsumer queueConsumer = new QueueConsumer(queueConnectionFactory, queue); Thread consumerThread = new Thread(queueConsumer); log.info("Starting" + broker + "consumerQueue thread..."); consumerThread.start(); Thread.sleep(1 * 60000); log.info("Shutting down " + broker + " consumerQueue..."); queueConsumer.shutdown(); } } catch (IOException e) { log.error("Cannot read properties file from resources. " + e.getMessage(), e); } catch (NamingException e) { log.error("Invalid properties in the properties " + e.getMessage(), e); } }