public MainTeset() throws Exception { QueueConsumer consumer = new QueueConsumer("queue"); Thread consumerThread = new Thread(consumer); consumerThread.start(); Producer producer = new Producer("queue"); for (int i = 0; i < 100000; i++) { HashMap message = new HashMap(); message.put("message number", i); producer.sendMessage(message); System.out.println("Message Number " + i + " sent."); } }
public static void main(String[] args) { // TODO Auto-generated method stub BrokerService broker = new BrokerService(); try { broker.addConnector("tcp://localhost:61616"); broker.setPopulateJMSXUserID(true); broker.start(); if (broker.isPopulateJMSXUserID()) LOG.info("jmsxuserid is true"); else LOG.info("jmsxuserid is false"); Producer producer = new Producer(); LOG.info("Consumer created"); Consumer consumer = new Consumer("TestQueue"); producer.sendMessage("TestQueue", "hello buddy"); Thread.sleep(4000); } catch (JMSException e) { // TODO Auto-generated catch block LOG.debug("Error occured while sending message", e); } catch (Exception e) { // TODO: handle exception LOG.debug("error releasing resources", e); } }