Created
January 24, 2012 21:35
-
-
Save bechhansen/1672854 to your computer and use it in GitHub Desktop.
JMS Queue add
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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