static public void main(String[] args) throws Exception { if (args.length < 2) { usage("Wrong number of arguments."); } String qcfBindingName = args[0]; String queueBindingName = args[1]; String username = null; String password = null; if (args.length == 4) { username = args[2]; password = args[3]; } LoggerContext loggerContext = (LoggerContext) LoggerFactory .getILoggerFactory(); new ContextInitializer(loggerContext).autoConfig(); new JMSQueueSink(qcfBindingName, queueBindingName, username, password); BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); // Loop until the word "exit" is typed System.out.println("Type \"exit\" to quit JMSQueueSink."); while (true) { String s = stdin.readLine(); if (s.equalsIgnoreCase("exit")) { System.out.println("Exiting. Kill the application if it does not exit " + "due to daemon threads."); return; } } }
public JMSQueueSink(String qcfBindingName, String queueBindingName, String username, String password) { try { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); env.put(Context.PROVIDER_URL, "tcp://localhost:61616"); Context ctx = new InitialContext(env); QueueConnectionFactory queueConnectionFactory; queueConnectionFactory = (QueueConnectionFactory) lookup(ctx, qcfBindingName); System.out.println("Queue Cnx Factory found"); Queue queue = (Queue) ctx.lookup(queueBindingName); System.out.println("Queue found: " + queue.getQueueName()); QueueConnection queueConnection = queueConnectionFactory .createQueueConnection(username, password); System.out.println("Queue Connection created"); QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer queueConsumer = queueSession.createConsumer(queue); queueConsumer.setMessageListener(this); queueConnection.start(); System.out.println("Queue Connection started"); } catch (Exception e) { logger.error("Could not read JMS message.", e); } }
static public void main(String[] args) throws Exception { if (args.length < 2) { usage("Wrong number of arguments."); } String qcfBindingName = args[0]; String queueBindingName = args[1]; String username = null; String password = null; if (args.length == 4) { username = args[2]; password = args[3]; } LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); new ContextInitializer(loggerContext).autoConfig(); new JMSQueueSink(qcfBindingName, queueBindingName, username, password); BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); // Loop until the word "exit" is typed System.out.println("Type \"exit\" to quit JMSQueueSink."); while (true) { String s = stdin.readLine(); if (s.equalsIgnoreCase("exit")) { System.out.println("Exiting. Kill the application if it does not exit " + "due to daemon threads."); return; } } }
public JMSQueueSink(String qcfBindingName, String queueBindingName, String username, String password) { try { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); env.put(Context.PROVIDER_URL, "tcp://localhost:61616"); Context ctx = new InitialContext(env); QueueConnectionFactory queueConnectionFactory; queueConnectionFactory = (QueueConnectionFactory) lookup(ctx, qcfBindingName); System.out.println("Queue Cnx Factory found"); Queue queue = (Queue) ctx.lookup(queueBindingName); System.out.println("Queue found: " + queue.getQueueName()); QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(username, password); System.out.println("Queue Connection created"); QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer queueConsumer = queueSession.createConsumer(queue); queueConsumer.setMessageListener(this); queueConnection.start(); System.out.println("Queue Connection started"); } catch (Exception e) { logger.error("Could not read JMS message.", e); } }
static public void main(String[] args) throws Exception { if (args.length < 2) { usage("Wrong number of arguments."); } String qcfBindingName = args[0]; String queueBindingName = args[1]; String username = null; String password = null; if (args.length == 4) { username = args[2]; password = args[3]; } LoggerContext loggerContext = (LoggerContext) LoggerFactory .getILoggerFactory(); new ContextInitializer(loggerContext).autoConfig(); new JMSQueueSink(qcfBindingName, queueBindingName, username, password); BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); // Loop until the word "exit" is typed System.out.println("Type \"exit\" to quit JMSQueueSink."); while (true) { String s = stdin.readLine(); if (s.equalsIgnoreCase("exit")) { System.out.println("Exiting. Kill the application if it does not exit " + "due to daemon threads."); return; } } }
public JMSQueueSink(String qcfBindingName, String queueBindingName, String username, String password) { try { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); env.put(Context.PROVIDER_URL, "tcp://localhost:61616"); Context ctx = new InitialContext(env); QueueConnectionFactory queueConnectionFactory; queueConnectionFactory = (QueueConnectionFactory) lookup(ctx, qcfBindingName); System.out.println("Queue Cnx Factory found"); Queue queue = (Queue) ctx.lookup(queueBindingName); System.out.println("Queue found: " + queue.getQueueName()); QueueConnection queueConnection = queueConnectionFactory .createQueueConnection(username, password); System.out.println("Queue Connection created"); QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer queueConsumer = queueSession.createConsumer(queue); queueConsumer.setMessageListener(this); queueConnection.start(); System.out.println("Queue Connection started"); } catch (Exception e) { logger.error("Could not read JMS message.", e); } }
static public void main(String[] args) throws Exception { if (args.length < 2) { usage("Wrong number of arguments."); } String qcfBindingName = args[0]; String queueBindingName = args[1]; String username = null; String password = null; if (args.length == 4) { username = args[2]; password = args[3]; } LoggerContext loggerContext = (LoggerContext) LoggerFactory .getILoggerFactory(); new ContextInitializer(loggerContext).autoConfig(); new JMSQueueSink(qcfBindingName, queueBindingName, username, password); BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); // Loop until the word "exit" is typed System.out.println("Type \"exit\" to quit JMSQueueSink."); while (true) { String s = stdin.readLine(); if (s.equalsIgnoreCase("exit")) { System.out.println("Exiting. Kill the application if it does not exit " + "due to daemon threads."); return; } } }
public JMSQueueSink(String qcfBindingName, String queueBindingName, String username, String password) { try { Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); env.put(Context.PROVIDER_URL, "tcp://localhost:61616"); Context ctx = new InitialContext(env); QueueConnectionFactory queueConnectionFactory; queueConnectionFactory = (QueueConnectionFactory) lookup(ctx, qcfBindingName); System.out.println("Queue Cnx Factory found"); Queue queue = (Queue) ctx.lookup(queueBindingName); System.out.println("Queue found: " + queue.getQueueName()); QueueConnection queueConnection = queueConnectionFactory .createQueueConnection(username, password); System.out.println("Queue Connection created"); QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer queueConsumer = queueSession.createConsumer(queue); queueConsumer.setMessageListener(this); queueConnection.start(); System.out.println("Queue Connection started"); } catch (Exception e) { logger.error("Could not read JMS message.", e); } }