1 | Context initJNDI(boolean useProps, String jndi, String url, String useAuth, String user, String pwd) {↵ | | 1 | Context initJNDI(boolean useProps, String jndi, String url, String useAuth, String user, String pwd) {↵
|
2 | if (useProps) {↵ | | 2 | if (useProps) {↵
|
3 | try {↵ | | 3 | try {↵
|
4 | return new InitialContext();↵ | | 4 | return new InitialContext();↵
|
5 | } catch (NamingException e) {↵ | | 5 | } catch (NamingException e) {↵
|
6 | log.error(e.getMessage());↵ | | 6 | log.error(e.getMessage());↵
|
7 | return null;↵ | | 7 | return null;↵
|
8 | }↵ | | 8 | }↵
|
9 | } else {↵ | | 9 | } else {↵
|
10 | return InitialContextFactory.lookupContext(jndi, url, useAuth, user, pwd);↵ | | 10 | return InitialContextFactory.lookupContext(jndi, url, useAuth, user, pwd);↵
|
11 | }↵ | | 11 | }↵
|
12 | }↵ | | 12 | }↵
|
|
| | | 13 | /**↵
|
| | | 14 | * Create the connection, session and topic subscriber↵
|
| | | 15 | * ↵
|
| | | 16 | * @param ctx↵
|
| | | 17 | * @param connfactory↵
|
| | | 18 | * @param topic↵
|
| | | 19 | */↵
|
13 | public void initConnection(Context ctx, String connfactory, String topic) {↵ | | 20 | public void initConnection(Context ctx, String connfactory, String topic) {↵
|
14 | try {↵ | | 21 | try {↵
|
15 | ConnectionFactory.getTopicConnectionFactory(ctx,connfactory);↵ | | 22 | ConnectionFactory.getTopicConnectionFactory(ctx,connfactory);↵
|
16 | this.CONN = ConnectionFactory.getTopicConnection();↵ | | 23 | this.CONN = ConnectionFactory.getTopicConnection();↵
|
17 | this.TOPIC = InitialContextFactory.lookupTopic(ctx, topic);↵ | | 24 | this.TOPIC = InitialContextFactory.lookupTopic(ctx, topic);↵
|
18 | this.SESSION = this.CONN.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);↵ | | 25 | this.SESSION = this.CONN.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);↵
|
19 | this.PUBLISHER = this.SESSION.createPublisher(this.TOPIC);↵ | | 26 | this.SUBSCRIBER = this.SESSION.createSubscriber(this.TOPIC);↵
|
20 | log.info("created the topic connection successfully");↵ | | 27 | log.info("created the topic connection successfully");↵
|
21 | } catch (JMSException e) {↵ | | 28 | } catch (JMSException e) {↵
|
22 | log.error("Connection error: " + e.getMessage());↵ | | 29 | log.error("Connection error: " + e.getMessage());↵
|
23 | }↵ | | 30 | }↵
|
24 | | | 31 |
|