You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2009/06/30 16:03:26 UTC
svn commit: r789735 -
/incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java
Author: cwiklik
Date: Tue Jun 30 14:03:25 2009
New Revision: 789735
URL: http://svn.apache.org/viewvc?rev=789735&view=rev
Log:
UIMA-1391 Added two new methods to allow application to stop Cas Multiplier
Modified:
incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java
Modified: incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java?rev=789735&r1=789734&r2=789735&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java (original)
+++ incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java Tue Jun 30 14:03:25 2009
@@ -20,6 +20,7 @@
package org.apache.uima.adapter.jms.client;
import java.io.File;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -839,6 +840,46 @@
{
return sender.getMessageProducer(destination);
}
+ /**
+ * Request Uima AS client to initiate sending Stop requests to a service for all outstanding
+ * CASes awaiting reply.
+ *
+ */
+ public void stopProducingCases() {
+ Iterator<String> it = getCache().keySet().iterator();
+ while ( it.hasNext()) {
+ ClientRequest request = (ClientRequest)getCache().get(it.next());
+ if ( request.getCasReferenceId() != null && !request.isMetaRequest()) {
+ stopProducingCases(request.getCasReferenceId());
+ }
+ }
+ }
+ /**
+ * Request Uima AS client to initiate sending Stop request to a service for a given CAS id
+ * If the service is a Cas Multiplier, it will stop producing new CASes, will wait until all
+ * child CASes finish and finally returns the input CAS.
+ *
+ */
+ public void stopProducingCases(String aCasReferenceId) {
+ try {
+ if ( serviceDelegate.getFreeCasDestination() != null ) {
+ TextMessage msg = createTextMessage();
+ msg.setIntProperty(AsynchAEMessage.Payload, AsynchAEMessage.None);
+ msg.setStringProperty(AsynchAEMessage.CasReference, aCasReferenceId);
+ msg.setIntProperty(AsynchAEMessage.MessageType, AsynchAEMessage.Request);
+ msg.setIntProperty(AsynchAEMessage.Command, AsynchAEMessage.Stop);
+ msg.setStringProperty(UIMAMessage.ServerURI, brokerURI);
+ MessageProducer msgProducer =
+ getMessageProducer(serviceDelegate.getFreeCasDestination());
+ if ( msgProducer != null ) {
+ // Send FreeCAS message to a Cas Multiplier
+ msgProducer.send(msg);
+ }
+ }
+ } catch ( Exception e) {
+ e.printStackTrace();
+ }
+ }
}