Package org.apache.uima.adapter.jms.client.BaseUIMAAsynchronousEngineCommon_impl

Examples of org.apache.uima.adapter.jms.client.BaseUIMAAsynchronousEngineCommon_impl.ClientRequest


   */
  public void stopProducingCases() {
    List<DelegateEntry> outstandingCasList = serviceDelegate.getDelegateCasesPendingReply();
    for (DelegateEntry entry : outstandingCasList) {
      // The Cas is still being processed
      ClientRequest clientCachedRequest = (ClientRequest) clientCache
              .get(entry.getCasReferenceId());
      if (clientCachedRequest != null && !clientCachedRequest.isMetaRequest()
              && clientCachedRequest.getCasReferenceId() != null) {
        stopProducingCases(clientCachedRequest);
      }
    }
  }
View Full Code Here


   * finish and finally returns the input CAS.
   *
   */
  public void stopProducingCases(String aCasReferenceId) {
    // The Cas is still being processed
    ClientRequest clientCachedRequest = (ClientRequest) clientCache.get(aCasReferenceId);
    if (clientCachedRequest != null) {
      stopProducingCases(clientCachedRequest);
    }
  }
View Full Code Here

            "UIMAJMS_sending_msg_to_endpoint__FINEST",
            new Object[] { destination });
       
        if ( pm.containsKey(AsynchAEMessage.CasReference) )
        {
          ClientRequest cacheEntry = (ClientRequest)
          engine.getCache().get(pm.get(AsynchAEMessage.CasReference));
          if ( cacheEntry != null )
          {
            //  Use Process Timeout value for the time-to-live property in the
            //  outgoing JMS message. When this time is exceeded
            //  while the message sits in a queue, the JMS Server will remove it from
            //  the queue. What happens with the expired message depends on the
            //  configuration. Most JMS Providers create a special dead-letter queue
            //  where all expired messages are placed. NOTE: In ActiveMQ expired msgs in the DLQ
            //  are not auto evicted yet and accumulate taking up memory.
           
            long timeoutValue = cacheEntry.getProcessTimeout();

            if ( timeoutValue > 0 )
            {
              // Set msg expiration time
              producer.setTimeToLive(timeoutValue);
            }
            if pm.getMessageType() == AsynchAEMessage.Process )
            {
              //          ClientRequest cacheEntry = (ClientRequest)
              //            engine.getCache().get(pm.get(AsynchAEMessage.CasReference));
              cacheEntry.setCASDepartureTime(System.nanoTime());
            }
          }
        }
        producer.send(message);
      } catch (Exception e) {
View Full Code Here

      rejectRequest = true;
      try {
        //  Is this is a Process request
        if (pm.getMessageType() == AsynchAEMessage.Process) {
          //  fetch the cache entry for this CAS
          ClientRequest cacheEntry = (ClientRequest) engine.getCache().get(
                  pm.get(AsynchAEMessage.CasReference));
          if ( cacheEntry != null ) {
            //  We are rejecting any Process requests until connection to broker
            //  is recovered
            cacheEntry.setProcessException();
            //  if the request was via synchronous API dont notify listeners
            //  instead the code will throw exception to the client
            boolean notifyListener = (cacheEntry.isSynchronousInvocation() == false);
            //  handle rejected request
            if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
              UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(),
                      "reject", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                      "UIMAJMS_client_rejected_process_request_broker_down__INFO", new Object[] { messageKind });
            }
            //  Sets the state of a remote delegate to handle subsequent requests
            engine.serviceDelegate.setState(Delegate.TIMEOUT_STATE);
            //  handle exception but dont rethrow the exception
            engine.handleException(e, cacheEntry.getCasReferenceId(), null, cacheEntry, notifyListener, false);
          }
        } else {
          //  Dont handle GetMeta Ping. Let it flow through. The Ping will be done once the connection is recovered
          if ( !engine.serviceDelegate.isAwaitingPingReply()) {
            if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
View Full Code Here


    // Wait for messages from application threads. The uima ee client engine
    // will call doStop() which sets the global flag 'done' to true.
    PendingMessage pm = null;
    ClientRequest cacheEntry = null;
    boolean doCallback = false;
    while (!done) {
      // Remove the oldest message from the shared 'queue'
      // // Wait for a new message
      try {
        pm = messageQueue.take();
      } catch (InterruptedException e) {
      }
      if (done) {
        break; // done in this loop
      }
      //  Check if the request should be rejected. If the connection to the broker is invalid and the request
      //  is not GetMeta Ping, reject the request after the connection is made. The reject() method created
      //  an exception and notified client of the fact that the request could not continue. The ping is a
      //  special case that we dont reject even though the broker connection has been lost. It is allow to
      //  fall through and will be sent as soon as the connection is recovered.
      boolean rejectRequest = reject(pm);
      if ( !engine.running) {
        break;
      }
      //  blocks until the connection is re-established with a broker
      engine.recoverSharedConnectionIfClosed();
      //  get the producer initialized from a valid connection
      producer = getMessageProducer();
      //  Check if the request should be rejected. It would be the case if the connection was invalid and
      //  subsequently recovered. If it was invalid, we went through error handling and the request is stale.
      if ( !rejectRequest && engine.running) {
          if ( engine.serviceDelegate.isAwaitingPingReply() &&
                pm.getMessageType() == AsynchAEMessage.GetMeta ){
            if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
              UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(),
                      "run", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                      "UIMAJMS_client_dispatching_getmeta_ping__INFO", new Object[] { });
            }
           }
           try {
             // Request JMS Message from the concrete implementation
             Message message = null;
             // Determine if this a CAS Process Request
             boolean casProcessRequest = isProcessRequest(pm);
             // Only Process request can be serialized as binary
             if (casProcessRequest && (engine.getSerialFormat() != SerialFormat.XMI)) {
               message = createBytesMessage();
             } else {
               message = createTextMessage();
             }

             initializeMessage(pm, message);
             if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
               UIMAFramework.getLogger(CLASS_NAME).logrb(
                       Level.FINE,
                       CLASS_NAME.getName(),
                       "run",
                       JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                       "UIMAJMS_sending_msg_to_endpoint__FINE",
                       new Object[] {
                           UimaMessageValidator.decodeIntToString(AsynchAEMessage.Command, message
                                   .getIntProperty(AsynchAEMessage.Command)),
                           UimaMessageValidator.decodeIntToString(AsynchAEMessage.MessageType, message
                                   .getIntProperty(AsynchAEMessage.MessageType)), destination });
             }
             if (casProcessRequest) {
               cacheEntry = (ClientRequest) engine.getCache().get(
                       pm.get(AsynchAEMessage.CasReference));
               if (cacheEntry != null) {
                   CAS cas = cacheEntry.getCAS();
                   // enable logging
                   if (System.getProperty("UimaAsCasTracking") != null) {
                     message.setStringProperty("UimaAsCasTracking", "enable");
                   }
          
                 // Use Process Timeout value for the time-to-live property in the
                 // outgoing JMS message. When this time is exceeded
                 // while the message sits in a queue, the JMS Server will remove it from
                 // the queue. What happens with the expired message depends on the
                 // configuration. Most JMS Providers create a special dead-letter queue
                 // where all expired messages are placed. NOTE: In ActiveMQ expired msgs in the DLQ
                 // are not auto evicted yet and accumulate taking up memory.
                 long timeoutValue = cacheEntry.getProcessTimeout();

                 if (timeoutValue > 0 && addTimeToLive ) {
                   // Set high time to live value
                   message.setJMSExpiration(10 * timeoutValue);
                 }
                 if (pm.getMessageType() == AsynchAEMessage.Process) {
                   cacheEntry.setCASDepartureTime(System.nanoTime());
                 }
                 cacheEntry.setCASDepartureTime(System.nanoTime());
        
                 doCallback = true;
                
             } else {
                 if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
                     UIMAFramework.getLogger(CLASS_NAME).logrb(
                             Level.WARNING,
                             CLASS_NAME.getName(),
                             "run",
                             JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                             "UIMAJMS_failed_cache_lookup__WARNING",
                             new Object[] {
                               pm.get(AsynchAEMessage.CasReference),
                                 UimaMessageValidator.decodeIntToString(AsynchAEMessage.Command, message
                                         .getIntProperty(AsynchAEMessage.Command)),
                                 UimaMessageValidator.decodeIntToString(AsynchAEMessage.MessageType, message
                                         .getIntProperty(AsynchAEMessage.MessageType)), destination });
                   }
                }
              
             }
             // start timers
             if( casProcessRequest ) {
               CAS cas = cacheEntry.getCAS();


               // Add the cas to a list of CASes pending reply. Also start the timer if necessary
               engine.serviceDelegate.addCasToOutstandingList(cacheEntry.getCasReferenceId(), cas.hashCode(), engine.timerPerCAS); // true=timer per cas
               if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
                 UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                        "sendCAS", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                        "UIMAJMS_cas_added_to_pending_FINE", new Object[] { cacheEntry.getCasReferenceId(), String.valueOf(cas.hashCode()), engine.serviceDelegate.toString()});
               }

            
             } else if ( pm.getMessageType() == AsynchAEMessage.GetMeta &&
                     engine.serviceDelegate.getGetMetaTimeout() > 0 ) {
               // timer for PING has been started in sendCAS()
               if ( !engine.serviceDelegate.isAwaitingPingReply()) {
                 engine.serviceDelegate.startGetMetaRequestTimer();
               }
             } else {
               doCallback = false// dont call onBeforeMessageSend() callback on CPC
             }
             //  Dispatch asynchronous request to Uima AS service
             producer.send(message);
            
             if ( doCallback ) {
               UimaASProcessStatus status = new UimaASProcessStatusImpl(new ProcessTrace_impl(),cacheEntry.getCAS(),
                       cacheEntry.getCasReferenceId());
               // Notify engine before sending a message
               if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
                   UIMAFramework.getLogger(CLASS_NAME).logrb(
                           Level.FINE,
                           CLASS_NAME.getName(),
                           "run",
                           JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                           "UIMAJMS_calling_onBeforeMessageSend__FINE",
                           new Object[] {
                             pm.get(AsynchAEMessage.CasReference),
                             String.valueOf(cacheEntry.getCAS().hashCode())
                           });
                
               // Note the callback is a misnomer. The callback is made *after* the send now
               // Application receiving this callback can consider the CAS as delivere to a queue
               engine.onBeforeMessageSend(status);
View Full Code Here

  }

  public void handleError(Exception e, ErrorContext errorContext) {
    String casReferenceId = null;
    CAS cas = null;
    ClientRequest cachedRequest = null;
    casReferenceId = (String) errorContext.get(AsynchAEMessage.CasReference);

    synchronized(errorMux) {
      if (!clientUimaAsEngine.running) {
        cancelDelegateTimer();
        return;
      }
     
      int command = ((Integer) errorContext.get(AsynchAEMessage.Command)).intValue();
      try {
        if (e instanceof MessageTimeoutException) {
          switch (command) {
            case AsynchAEMessage.Process:
              //casReferenceId = (String) errorContext.get(AsynchAEMessage.CasReference);
              if (casReferenceId != null) {
                cachedRequest = (ClientRequest) clientUimaAsEngine.clientCache.get(casReferenceId);
                if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)
                        && getEndpoint() != null) {
                  UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
                          "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                          "UIMAJMS_process_timeout_WARNING",
                          new Object[] { getEndpoint().getEndpoint(), clientUimaAsEngine.getBrokerURI(), cachedRequest.getHostIpProcessingCAS() });
                }
                if (cachedRequest != null && cachedRequest.isRemote()) {
                  cas = cachedRequest.getCAS();
                }
                boolean isPingTimeout = false;
                if (errorContext.containsKey(AsynchAEMessage.ErrorCause)) {
                  isPingTimeout = AsynchAEMessage.PingTimeout == (Integer) errorContext
                          .get(AsynchAEMessage.ErrorCause);
                }
                if (isPingTimeout && isAwaitingPingReply()) {
                  //  reset only if the connection is valid
                  if ( clientUimaAsEngine.state != ClientState.RECONNECTING) {
                    resetAwaitingPingReply();
                  }
                  pingTimeout = true;
                  UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
                          "handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                          "UIMAJMS_client_ping_timed_out__WARNING", new Object[] { getKey() });
                  clientUimaAsEngine.notifyOnTimout(cas, clientUimaAsEngine.getEndPointName(),
                          BaseUIMAAsynchronousEngineCommon_impl.ProcessTimeout, casReferenceId);
                } else {
                  if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
                    UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
                            "handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                            "UIMAJMS_client_process_timeout__WARNING", new Object[] { super.getCasProcessTimeout() });
                  }
                  clientUimaAsEngine.notifyOnTimout(cas, clientUimaAsEngine.getEndPointName(),
                          BaseUIMAAsynchronousEngineCommon_impl.ProcessTimeout, casReferenceId);
                }
              }
              clientUimaAsEngine.clientSideJmxStats.incrementProcessTimeoutErrorCount();
              break;

            case AsynchAEMessage.GetMeta:
              if (isAwaitingPingReply()) {
               
                if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
                UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
                        "handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                        "UIMAJMS_client_ping_timed_out__WARNING", new Object[] { clientUimaAsEngine.getEndPointName(),getCasPendingDispatchListSize(),getCasPendingReplyListSize()});
                }
                super.resetAwaitingPingReply();
               
                synchronized( super.pendingDispatchList ) {
                  //  Fail all CASes in the PendingDispatch list
                  Iterator<Delegate.DelegateEntry> it = getDelegateCasesPendingDispatch().iterator();
                  while( clientUimaAsEngine.running && it.hasNext() ) {
                    DelegateEntry de = it.next();
                    cachedRequest = (ClientRequest) (clientUimaAsEngine.getCache()).get(de.getCasReferenceId());
                    if ( cachedRequest != null ) {
                      if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
                        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
                                "handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                                "UIMAJMS_client_reject_by_forced_timeout__WARNING", new Object[] { de.getCasReferenceId(), String.valueOf(cachedRequest.getCAS().hashCode())});
                      }
                      //dumpDelayedList();
                      try {
                        clientUimaAsEngine.handleException(new UimaASProcessCasTimeout("Service Not Responding to Ping - CAS:"+de.getCasReferenceId(), new UimaASPingTimeout("Forced Timeout on CAS in PendingDispatch list. The CAS Has Not Been Dispatched since the Service Appears to be Unavailable")), de.getCasReferenceId(), null,cachedRequest, !cachedRequest.isSynchronousInvocation(), false);
                      } catch( Exception ex) {
                        ex.printStackTrace();
                      }
                    }
                    if ( clientUimaAsEngine.running ) {
                      it.remove();
                    }
                  }
                }
              } else {
                  if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
                      UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
                              "handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                              "UIMAJMS_meta_timeout_WARNING", new Object[] { getKey() });
                    }
                // Notifies Listeners and removes ClientRequest instance from the client cache
                clientUimaAsEngine.notifyOnTimout(cas, clientUimaAsEngine.getEndPointName(),
                        BaseUIMAAsynchronousEngineCommon_impl.MetadataTimeout, casReferenceId);
                clientUimaAsEngine.clientSideJmxStats.incrementMetaTimeoutErrorCount();
              }
              break;

            case AsynchAEMessage.CollectionProcessComplete:

              break;
          }
        }
      } catch (Exception ex) {
        if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
          UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
                  "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
                  "UIMAEE_exception__WARNING", ex);
        }
      }
      // Dont release the CAS if synchronous API was used
      if (cas != null && !cachedRequest.isSynchronousInvocation()) {
        cas.release();
      }

    }
  }
View Full Code Here

  }
  public String enrichProcessCASTimeoutMessage(int aCommand, String casReferenceId, long timeToWait, String timeoutMessage) {
    StringBuffer sb = new StringBuffer(timeoutMessage);
    try {
      if ( casReferenceId != null && clientUimaAsEngine.getCache().containsKey(casReferenceId) ) {
        ClientRequest cr =
          (ClientRequest)clientUimaAsEngine.getCache().get(casReferenceId);
        if ( cr != null ) {
          sb.append(". Process CAS on host: "+cr.getHostIpProcessingCAS()+" exceeded configured timeout threshold of "+timeToWait+" ms");
        }
      }
    } catch( Exception e) {
      e.printStackTrace();
    }
View Full Code Here

      rejectRequest = true;
      try {
        //  Is this is a Process request
        if (pm.getMessageType() == AsynchAEMessage.Process) {
          //  fetch the cache entry for this CAS
          ClientRequest cacheEntry = (ClientRequest) engine.getCache().get(
                  pm.get(AsynchAEMessage.CasReference));
          if ( cacheEntry != null ) {
            //  We are rejecting any Process requests until connection to broker
            //  is recovered
            cacheEntry.setProcessException();
            //  if the request was via synchronous API dont notify listeners
            //  instead the code will throw exception to the client
            boolean notifyListener = (cacheEntry.isSynchronousInvocation() == false);
            //  handle rejected request
            if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
              UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(),
                      "reject", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                      "UIMAJMS_client_rejected_process_request_broker_down__INFO", new Object[] { messageKind });
            }
            //  Sets the state of a remote delegate to handle subsequent requests
            engine.serviceDelegate.setState(Delegate.TIMEOUT_STATE);
            //  handle exception but dont rethrow the exception
            engine.handleException(e, cacheEntry.getCasReferenceId(), null, cacheEntry, notifyListener, false);
          }
        } else {
          //  Dont handle GetMeta Ping. Let it flow through. The Ping will be done once the connection is recovered
          if ( !engine.serviceDelegate.isAwaitingPingReply()) {
            if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
View Full Code Here


    // Wait for messages from application threads. The uima ee client engine
    // will call doStop() which sets the global flag 'done' to true.
    PendingMessage pm = null;
    ClientRequest cacheEntry = null;
    boolean doCallback = false;
    while (!done) {
      // Remove the oldest message from the shared 'queue'
      // // Wait for a new message
      try {
        pm = messageQueue.take();
      } catch (InterruptedException e) {
      }
      if (done) {
        break; // done in this loop
      }
      //  Check if the request should be rejected. If the connection to the broker is invalid and the request
      //  is not GetMeta Ping, reject the request after the connection is made. The reject() method created
      //  an exception and notified client of the fact that the request could not continue. The ping is a
      //  special case that we dont reject even though the broker connection has been lost. It is allow to
      //  fall through and will be sent as soon as the connection is recovered.
      boolean rejectRequest = reject(pm);
      if ( !engine.running) {
        break;
      }
      //  blocks until the connection is re-established with a broker
      engine.recoverSharedConnectionIfClosed();
      //  get the producer initialized from a valid connection
      producer = getMessageProducer();
      //  Check if the request should be rejected. It would be the case if the connection was invalid and
      //  subsequently recovered. If it was invalid, we went through error handling and the request is stale.
      if ( !rejectRequest && engine.running) {
          if ( engine.serviceDelegate.isAwaitingPingReply() &&
                pm.getMessageType() == AsynchAEMessage.GetMeta ){
            if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
              UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(),
                      "run", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                      "UIMAJMS_client_dispatching_getmeta_ping__INFO", new Object[] { });
            }
           }
           try {
             // Request JMS Message from the concrete implementation
             Message message = null;
             // Determine if this a CAS Process Request
             boolean casProcessRequest = isProcessRequest(pm);
             // Only Process request can be serialized as binary
             if (casProcessRequest && (engine.getSerialFormat() != SerialFormat.XMI)) {
               message = createBytesMessage();
             } else {
               message = createTextMessage();
             }

             initializeMessage(pm, message);
             if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
               UIMAFramework.getLogger(CLASS_NAME).logrb(
                       Level.FINE,
                       CLASS_NAME.getName(),
                       "run",
                       JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                       "UIMAJMS_sending_msg_to_endpoint__FINE",
                       new Object[] {
                           UimaMessageValidator.decodeIntToString(AsynchAEMessage.Command, message
                                   .getIntProperty(AsynchAEMessage.Command)),
                           UimaMessageValidator.decodeIntToString(AsynchAEMessage.MessageType, message
                                   .getIntProperty(AsynchAEMessage.MessageType)), destination });
             }
             if (casProcessRequest) {
               cacheEntry = (ClientRequest) engine.getCache().get(
                       pm.get(AsynchAEMessage.CasReference));
               if (cacheEntry != null) {
                   CAS cas = cacheEntry.getCAS();

                 // Use Process Timeout value for the time-to-live property in the
                 // outgoing JMS message. When this time is exceeded
                 // while the message sits in a queue, the JMS Server will remove it from
                 // the queue. What happens with the expired message depends on the
                 // configuration. Most JMS Providers create a special dead-letter queue
                 // where all expired messages are placed. NOTE: In ActiveMQ expired msgs in the DLQ
                 // are not auto evicted yet and accumulate taking up memory.
                 long timeoutValue = cacheEntry.getProcessTimeout();

                 if (timeoutValue > 0 && addTimeToLive ) {
                   // Set high time to live value
                   message.setJMSExpiration(10 * timeoutValue);
                 }
                 if (pm.getMessageType() == AsynchAEMessage.Process) {
                   cacheEntry.setCASDepartureTime(System.nanoTime());
                 }
                 cacheEntry.setCASDepartureTime(System.nanoTime());
        
                 doCallback = true;
                
             } else {
                 if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
                     UIMAFramework.getLogger(CLASS_NAME).logrb(
                             Level.WARNING,
                             CLASS_NAME.getName(),
                             "run",
                             JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                             "UIMAJMS_failed_cache_lookup__WARNING",
                             new Object[] {
                               pm.get(AsynchAEMessage.CasReference),
                                 UimaMessageValidator.decodeIntToString(AsynchAEMessage.Command, message
                                         .getIntProperty(AsynchAEMessage.Command)),
                                 UimaMessageValidator.decodeIntToString(AsynchAEMessage.MessageType, message
                                         .getIntProperty(AsynchAEMessage.MessageType)), destination });
                   }
                }
              
             }
             // start timers
             if( casProcessRequest ) {
               CAS cas = cacheEntry.getCAS();
               // Add the cas to a list of CASes pending reply. Also start the timer if necessary
               engine.serviceDelegate.addCasToOutstandingList(cacheEntry.getCasReferenceId(), cas.hashCode(), engine.timerPerCAS); // true=timer per cas
               if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
                 UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                        "sendCAS", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                        "UIMAJMS_cas_added_to_pending_FINE", new Object[] { cacheEntry.getCasReferenceId(), String.valueOf(cas.hashCode()), engine.serviceDelegate.toString()});
               }

            
             } else if ( pm.getMessageType() == AsynchAEMessage.GetMeta &&
                     engine.serviceDelegate.getGetMetaTimeout() > 0 ) {
               // timer for PING has been started in sendCAS()
               if ( !engine.serviceDelegate.isAwaitingPingReply()) {
                 engine.serviceDelegate.startGetMetaRequestTimer();
               }
             }
             //  Dispatch asynchronous request to Uima AS service
             producer.send(message);
             if ( doCallback ) {
               UimaASProcessStatus status = new UimaASProcessStatusImpl(new ProcessTrace_impl(),cacheEntry.getCAS(),
                       cacheEntry.getCasReferenceId());
               // Notify engine before sending a message
               if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
                   UIMAFramework.getLogger(CLASS_NAME).logrb(
                           Level.FINE,
                           CLASS_NAME.getName(),
                           "run",
                           JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
                           "UIMAJMS_calling_onBeforeMessageSend__FINE",
                           new Object[] {
                             pm.get(AsynchAEMessage.CasReference),
                             String.valueOf(cacheEntry.getCAS().hashCode())
                           });
                
               // Note the callback is a misnomer. The callback is made *after* the send now
               // Application receiving this callback can consider the CAS as delivere to a queue
               engine.onBeforeMessageSend(status);
View Full Code Here

TOP

Related Classes of org.apache.uima.adapter.jms.client.BaseUIMAAsynchronousEngineCommon_impl.ClientRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.