servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r358001 - /incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/servicemix/wsn/jms/JmsSubscription.java
Date Tue, 20 Dec 2005 14:45:37 GMT
Author: gnodet
Date: Tue Dec 20 06:45:33 2005
New Revision: 358001

URL: http://svn.apache.org/viewcvs?rev=358001&view=rev
Log:
Add simple pause/resume to wsn2005 subscriptions

Modified:
    incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/servicemix/wsn/jms/JmsSubscription.java

Modified: incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/servicemix/wsn/jms/JmsSubscription.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/servicemix/wsn/jms/JmsSubscription.java?rev=358001&r1=358000&r2=358001&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/servicemix/wsn/jms/JmsSubscription.java
(original)
+++ incubator/servicemix/trunk/servicemix-wsn2005/src/main/java/org/servicemix/wsn/jms/JmsSubscription.java
Tue Dec 20 06:45:33 2005
@@ -44,7 +44,6 @@
 import org.servicemix.wsn.jaxws.UnacceptableTerminationTimeFault;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
@@ -54,7 +53,6 @@
 	
 	private Connection connection;
 	private Session session;
-    private MessageConsumer consumer;
     private JmsTopicExpressionConverter topicConverter;
     private Topic jmsTopic;
 	
@@ -66,7 +64,7 @@
 	protected void start() throws SubscribeCreationFailedFault {
 		try {
 			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-            consumer = session.createConsumer(jmsTopic);
+			MessageConsumer consumer = session.createConsumer(jmsTopic);
             consumer.setMessageListener(this);
 		} catch (JMSException e) {
 			SubscribeCreationFailedFaultType fault = new SubscribeCreationFailedFaultType();
@@ -88,14 +86,36 @@
 
 	@Override
 	protected void pause() throws PauseFailedFault {
-		PauseFailedFaultType fault = new PauseFailedFaultType();
-		throw new PauseFailedFault("Pause not supported", fault);
+		if (session == null) {
+			PauseFailedFaultType fault = new PauseFailedFaultType();
+			throw new PauseFailedFault("Subscription is already paused", fault);
+		} else {
+			try {
+				session.close();
+			} catch (JMSException e) {
+				PauseFailedFaultType fault = new PauseFailedFaultType();
+				throw new PauseFailedFault("Error pausing subscription", fault, e);
+			} finally {
+				session = null;
+			}
+		}
 	}
 
 	@Override
 	protected void resume() throws ResumeFailedFault {
-		ResumeFailedFaultType fault = new ResumeFailedFaultType();
-		throw new ResumeFailedFault("Resume not supported", fault);
+		if (session != null) {
+			ResumeFailedFaultType fault = new ResumeFailedFaultType();
+			throw new ResumeFailedFault("Subscription is already running", fault);
+		} else {
+			try {
+				session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+				MessageConsumer consumer = session.createConsumer(jmsTopic);
+	            consumer.setMessageListener(this);
+			} catch (JMSException e) {
+				ResumeFailedFaultType fault = new ResumeFailedFaultType();
+				throw new ResumeFailedFault("Error resuming subscription", fault, e);
+			}
+		}
 	}
 
 	@Override
@@ -108,12 +128,15 @@
 
 	@Override
 	protected void unsubscribe() throws UnableToDestroySubscriptionFault {
+		super.unsubscribe();
 		if (session != null) {
 			try {
 				session.close();
 			} catch (JMSException e) {
 				UnableToDestroySubscriptionFaultType fault = new UnableToDestroySubscriptionFaultType();
 				throw new UnableToDestroySubscriptionFault("Unable to unsubscribe", fault, e);
+			} finally {
+				session = null;
 			}
 		}
 	}
@@ -163,17 +186,13 @@
 				Boolean ret = (Boolean) exp.evaluate(content, XPathConstants.BOOLEAN);
 				return ret.booleanValue();
 			} catch (SAXException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				log.warn("Could not filter notification", e);
 			} catch (IOException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				log.warn("Could not filter notification", e);
 			} catch (ParserConfigurationException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				log.warn("Could not filter notification", e);
 			} catch (XPathExpressionException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				log.warn("Could not filter notification", e);
 			}
 			return false;
 		}



Mime
View raw message