Skip to content

Instantly share code, notes, and snippets.

@bechhansen
Created January 24, 2012 21:35
Show Gist options
  • Select an option

  • Save bechhansen/1672854 to your computer and use it in GitHub Desktop.

Select an option

Save bechhansen/1672854 to your computer and use it in GitHub Desktop.
JMS Queue add
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");
InitialContext context = new InitialContext(environment);
ConnectionFactory connectionFactory = (ConnectionFactory)ctx.lookup("ConnectionFactory");
Queue queue = (Queue)ctx.lookup("queue/test");
javax.jms.Connection connection = connectionFactory.createConnection();
javax.jms.Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(queue);
TextMessage message = session.createTextMessage();
message.setText("message");
messageProducer.send(message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment