|
Do you need help with your Java programming?
Click here for instant help with your Java code. |
Creating a TopicConnectionFactory
This example shows how to create a javax.jms.TopicConnectionFactory. To be able to create a TopicConnectionFactory instance, you'll first need to instantiate a InitialContext object to look up the TopicConnectionFactory in the server's naming service (JNDI tree). The TopicConnectionFactory is used to create connections to a message server. The behavior and attributes of the TopicConnectionFactory are configured by the system administrator of the messaging server. Each vendor implements the the TopicConnectionFactory differently, so the configuration options may vary from one vendor to another. |
//Assuming that the InitialContext is already created. TopicConnectionFactory connectionFactory = new (TopicConnectionFactory)initCtx.lookup(topicFactory); |
Two overloaded versions of the createTopicConnection() method are provided by the TopicConnectionFactory: |
package javax.jms; public interface TopicConnectionFactory extends ConnectionFactory { public TopicConnection createTopicConnection() throws JMSException, JMSSecurityException; public TopicConnection createTopicConnection(String username, String password) throws JMSException, JMSSecurityException; } |
| Do you know your Java? | |
| Take a Ten-Question-Java-Quiz! | |
Search for code examples on this site
