Lines 84-97
Link Here
|
84 |
String initialContextFactory, String providerUrl, String connfactory, String destinationName, |
84 |
String initialContextFactory, String providerUrl, String connfactory, String destinationName, |
85 |
String durableSubscriptionId, boolean useAuth, |
85 |
String durableSubscriptionId, boolean useAuth, |
86 |
String securityPrincipal, String securityCredentials) throws NamingException, JMSException { |
86 |
String securityPrincipal, String securityCredentials) throws NamingException, JMSException { |
87 |
Context ctx = InitialContextFactory.getContext(useProps, |
87 |
boolean initSuccess = false; |
88 |
initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials); |
88 |
try{ |
89 |
CONN = Utils.getConnection(ctx, connfactory); |
89 |
Context ctx = InitialContextFactory.getContext(useProps, |
90 |
SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE); |
90 |
initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials); |
91 |
Destination dest = Utils.lookupDestination(ctx, destinationName); |
91 |
CONN = Utils.getConnection(ctx, connfactory); |
92 |
SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId); |
92 |
SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE); |
93 |
queue = null; |
93 |
Destination dest = Utils.lookupDestination(ctx, destinationName); |
94 |
log.debug("<init> complete"); |
94 |
SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId); |
|
|
95 |
queue = null; |
96 |
log.debug("<init> complete"); |
97 |
initSuccess = true; |
98 |
} finally { |
99 |
if(!initSuccess) { |
100 |
close(); |
101 |
} |
102 |
} |
95 |
} |
103 |
} |
96 |
|
104 |
|
97 |
/** |
105 |
/** |
Lines 117-135
Link Here
|
117 |
String initialContextFactory, String providerUrl, String connfactory, String destinationName, |
125 |
String initialContextFactory, String providerUrl, String connfactory, String destinationName, |
118 |
String durableSubscriptionId, boolean useAuth, |
126 |
String durableSubscriptionId, boolean useAuth, |
119 |
String securityPrincipal, String securityCredentials) throws NamingException, JMSException { |
127 |
String securityPrincipal, String securityCredentials) throws NamingException, JMSException { |
120 |
Context ctx = InitialContextFactory.getContext(useProps, |
128 |
boolean initSuccess = false; |
121 |
initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials); |
129 |
try{ |
122 |
CONN = Utils.getConnection(ctx, connfactory); |
130 |
Context ctx = InitialContextFactory.getContext(useProps, |
123 |
SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE); |
131 |
initialContextFactory, providerUrl, useAuth, securityPrincipal, securityCredentials); |
124 |
Destination dest = Utils.lookupDestination(ctx, destinationName); |
132 |
CONN = Utils.getConnection(ctx, connfactory); |
125 |
SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId); |
133 |
SESSION = CONN.createSession(false, Session.AUTO_ACKNOWLEDGE); |
126 |
if (queueSize <=0) { |
134 |
Destination dest = Utils.lookupDestination(ctx, destinationName); |
127 |
queue = new LinkedBlockingQueue<Message>(); |
135 |
SUBSCRIBER = createSubscriber(SESSION, dest, durableSubscriptionId); |
128 |
} else { |
136 |
if (queueSize <=0) { |
129 |
queue = new LinkedBlockingQueue<Message>(queueSize); |
137 |
queue = new LinkedBlockingQueue<Message>(); |
|
|
138 |
} else { |
139 |
queue = new LinkedBlockingQueue<Message>(queueSize); |
140 |
} |
141 |
SUBSCRIBER.setMessageListener(this); |
142 |
log.debug("<init> complete"); |
143 |
initSuccess = true; |
144 |
} |
145 |
finally { |
146 |
if(!initSuccess) { |
147 |
close(); |
148 |
} |
130 |
} |
149 |
} |
131 |
SUBSCRIBER.setMessageListener(this); |
|
|
132 |
log.debug("<init> complete"); |
133 |
} |
150 |
} |
134 |
|
151 |
|
135 |
/** |
152 |
/** |
Lines 208-218
Link Here
|
208 |
public void close() { // called from threadFinished() thread |
225 |
public void close() { // called from threadFinished() thread |
209 |
log.debug("close()"); |
226 |
log.debug("close()"); |
210 |
try { |
227 |
try { |
211 |
CONN.stop(); |
228 |
if(CONN != null) { |
|
|
229 |
CONN.stop(); |
230 |
} |
212 |
} catch (JMSException e) { |
231 |
} catch (JMSException e) { |
213 |
log.error(e.getMessage()); |
232 |
log.error(e.getMessage()); |
214 |
} |
233 |
} |
215 |
Utils.close(SUBSCRIBER, log); |
234 |
Utils.close(SUBSCRIBER, log); |
|
|
235 |
Utils.close(SUBSCRIBER, log); |
216 |
Utils.close(SESSION, log); |
236 |
Utils.close(SESSION, log); |
217 |
Utils.close(CONN, log); |
237 |
Utils.close(CONN, log); |
218 |
} |
238 |
} |