You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ea...@apache.org on 2008/08/19 23:09:57 UTC
svn commit: r687157 -
/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java
Author: eae
Date: Tue Aug 19 14:09:56 2008
New Revision: 687157
URL: http://svn.apache.org/viewvc?rev=687157&view=rev
Log:
UIMA-1145 Commit Jerry's patch
Modified:
incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java
Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java?rev=687157&r1=687156&r2=687157&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java Tue Aug 19 14:09:56 2008
@@ -171,32 +171,37 @@
producer = getMessageProducer();
int counter=0;
-/// MessageProducer producer = getMessageProducer();
-
// Wait for messages from application threads. The uima ee client engine
- // will call
- // doStop() which sets the global flag 'done' to true.
+ // will call doStop() which sets the global flag 'done' to true.
+ PendingMessage pm = null;
while (!done) {
synchronized (pendingMessageList) {
// First check if there are any pending messages in the shared
// 'queue'
- if (pendingMessageList.size() == 0) {
- // Block waiting for a message
+ while (pendingMessageList.size() == 0) {
+ // Block waiting for a message
try {
pendingMessageList.wait(0);
} catch (InterruptedException e) {
}
+ // Check if the engine is terminating. When the client is stopping
+ // it will signal 'pendingMessageList'. Check the state of the client
+ // and break out from the wait loop if the client is stopping
+ if (done) {
+ break; // done in this loop
+ }
}
+ // Check if the uima as client is in stopped state. If it is, don't read
+ // a message from the queue and just break out from the while loop. When
+ // the client is stopped, the 'pendingMessageList' is signaled but there
+ // is no message to read. The signal is done to force this thread to
+ // break out of wait().
+ if (done) {
+ break; // done here
+ }
+ // Remove the oldest message from the shared 'queue'
+ pm = (PendingMessage) pendingMessageList.remove(0);
}
- // The uima ee engine may have decided to stop, so first check to
- // see if
- // we should continue since the thread may have slept for a while
- // (in wait() )
- if (done) {
- break; // done here
- }
- // Remove the oldest message from the shared 'queue'
- PendingMessage pm = (PendingMessage) pendingMessageList.remove(0);
try {
// Request JMS Message from the concrete implementation
@@ -231,8 +236,6 @@
}
if ( pm.getMessageType() == AsynchAEMessage.Process )
{
- // ClientRequest cacheEntry = (ClientRequest)
- // engine.getCache().get(pm.get(AsynchAEMessage.CasReference));
cacheEntry.setCASDepartureTime(System.nanoTime());
}
}