/**
* Initialize the JNDI initial context
*
* @param useProps
* @param jndi
* @param url
* @param useAuth
* @param user
* @param pwd
* @return the JNDI initial context or null
*/
public Context initJNDI(boolean useProps, String jndi, String url, String useAuth, String user, String pwd) {
if (useProps) {
try {
return new InitialContext();
}
catch (NamingException
e) {
log.error(e.getMessage());
return null;
}
}
else {
return InitialContextFactory.lookupContext(jndi, url, useAuth, user, pwd);
}
}
/**
* Create the connection, session and topic subscriber
*
* @param ctx
* @param connfactory
* @param topic
*/
public void initConnection(Context ctx, String connfactory, String topic) {
try {
ConnectionFactory.getTopicConnectionFactory(ctx, connfactory);
this.CONN = ConnectionFactory.getTopicConnection();
this.TOPIC = InitialContextFactory.lookupTopic(ctx, topic);
this.SESSION = this.CONN.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
this. [[#variabledfd2000]]= this.SESSION. [[#variabledfd1f40]](this.TOPIC);
log.info("created the topic connection successfully");
}
catch (JMSException
e) {
log.error("Connection error: " + e.getMessage());
}
}
|