User: pra
Date: 01/05/03 13:06:38
Modified: src/main/org/jboss/test/mdb/test Main.java
Log:
Fixed close of connections, to end thread in JMS
Revision Changes Path
1.4 +31 -7 jbosstest/src/main/org/jboss/test/mdb/test/Main.java
Index: Main.java
===================================================================
RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/mdb/test/Main.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Main.java 2001/02/28 09:41:06 1.3
+++ Main.java 2001/05/03 20:06:38 1.4
@@ -52,6 +52,9 @@
// Provider specific
static String TOPIC_FACTORY = "TopicConnectionFactory";
static String QUEUE_FACTORY ="QueueConnectionFactory";
+
+ QueueConnection queueConnection;
+ TopicConnection topicConnection;
//JMSProviderAdapter providerAdapter;
Context context;
@@ -120,19 +123,23 @@
}
private QueueSession getQueueSession() throws Exception {
- QueueConnectionFactory queueFactory =
- (QueueConnectionFactory)context.lookup(QUEUE_FACTORY);
-
- QueueConnection queueConnection = queueFactory.createQueueConnection();
+ if (queueConnection == null) {
+ QueueConnectionFactory queueFactory =
+ (QueueConnectionFactory)context.lookup(QUEUE_FACTORY);
+
+ queueConnection = queueFactory.createQueueConnection();
+ }
return queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
}
private TopicSession getTopicSession() throws Exception{
- TopicConnectionFactory topicFactory =
- (TopicConnectionFactory)context.lookup(TOPIC_FACTORY);
- TopicConnection topicConnection = topicFactory.createTopicConnection();
+ if (topicConnection == null) {
+ TopicConnectionFactory topicFactory =
+ (TopicConnectionFactory)context.lookup(TOPIC_FACTORY);
+ topicConnection = topicFactory.createTopicConnection();
+ }
return topicConnection.createTopicSession(
// No transaction
false,
@@ -150,6 +157,14 @@
deployed = true;
}
+ protected void tearDown()
+ throws Exception {
+ if (topicConnection != null)
+ topicConnection.close();
+ if (queueConnection != null)
+ queueConnection.close();
+ }
+
public static void main(String arg[]) {
Main main = null;
try {
@@ -165,12 +180,21 @@
System.out.println("Testing exception, every other message should be
rolled back, excpect a lot of stacktraces");
main.testQueue("queue/ex");
+
+
} catch (Exception e) {
e.printStackTrace();
+
System.out.println();
System.out.println("_____________________________________________");
System.out.println("Sorry, test failed.");
+ } finally {
+ try {
+ main.tearDown();
+ }catch(Exception e) {
+ e.printStackTrace();
+ }
}
}
} // Main
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development