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/01/23 22:31:57 UTC
svn commit: r737197 - in
/incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main:
java/org/apache/uima/adapter/jms/client/ resources/
Author: cwiklik
Date: Fri Jan 23 13:31:56 2009
New Revision: 737197
URL: http://svn.apache.org/viewvc?rev=737197&view=rev
Log:
UIMA-1271 Fixes client API serialization for GetMeta. Adds new parameter in reply msg advertising service binary serialization support
Modified:
incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java
incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java
incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/resources/jms_adapter_messages.properties
Modified: incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java?rev=737197&r1=737196&r2=737197&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java (original)
+++ incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseMessageSender.java Fri Jan 23 13:31:56 2009
@@ -207,12 +207,14 @@
try {
// Request JMS Message from the concrete implementation
Message message = null;
- if ( engine.getSerializationStrategy().equals("xmi")) {
- message = createTextMessage();
- } else {
+ // Determine if this a CAS Process Request
+ boolean casProcessRequest = isProcessRequest(pm);
+ // Only Process request can be serialized as binary
+ if ( casProcessRequest && engine.getSerializationStrategy().equals("binary") ) {
message = createBytesMessage();
+ } else {
+ message = createTextMessage();
}
-
initializeMessage( pm, message );
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINEST)) {
@@ -222,7 +224,7 @@
"UIMAJMS_sending_msg_to_endpoint__FINEST",
new Object[] { UimaMessageValidator.decodeIntToString(AsynchAEMessage.Command, message.getIntProperty(AsynchAEMessage.Command)), UimaMessageValidator.decodeIntToString(AsynchAEMessage.MessageType,message.getIntProperty(AsynchAEMessage.MessageType)), destination });
}
- if ( pm.containsKey(AsynchAEMessage.CasReference) )
+ if ( casProcessRequest )
{
ClientRequest cacheEntry = (ClientRequest)
engine.getCache().get(pm.get(AsynchAEMessage.CasReference));
@@ -292,6 +294,9 @@
break;
}
}
+ private boolean isProcessRequest( PendingMessage pm ) {
+ return pm.getMessageType() == AsynchAEMessage.Process;
+ }
private void handleException(Exception e, String aDestination) {
workerThreadFailed = true;
exception = e;
Modified: incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java?rev=737197&r1=737196&r2=737197&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java (original)
+++ incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java Fri Jan 23 13:31:56 2009
@@ -665,9 +665,8 @@
{
ProcessTrace pt = new ProcessTrace_impl();
UimaASProcessStatusImpl status = new UimaASProcessStatusImpl(pt);
- Exception exception = retrieveExceptionFormMessage(message);
+ Exception exception = retrieveExceptionFromMessage(message);
-// Exception exception = (Exception) ((ObjectMessage) message).getObject();
status.addEventStatus("CpC", "Failed", exception);
notifyListeners(null, status, AsynchAEMessage.CollectionProcessComplete);
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINEST)) {
@@ -677,10 +676,12 @@
}
else
{
- //Make the receiving thread to complete
+ // After receiving CPC reply there may be cleanup to do. Delegate this
+ // to platform specific implementation (ActiveMQ or WAS)
cleanup(); //Make the receiving thread to complete
synchronized (endOfCollectionMonitor)
{
+ // Notify sleeping thread that the CPC reply was received
receivedCpcReply = true;
endOfCollectionMonitor.notifyAll();
}
@@ -746,7 +747,7 @@
{
ProcessTrace pt = new ProcessTrace_impl();
UimaASProcessStatusImpl status = new UimaASProcessStatusImpl(pt);
- Exception exception = retrieveExceptionFormMessage(message);
+ Exception exception = retrieveExceptionFromMessage(message);
clientSideJmxStats.incrementMetaErrorCount();
status.addEventStatus("GetMeta", "Failed", exception);
notifyListeners(null, status, AsynchAEMessage.GetMeta);
@@ -764,6 +765,23 @@
}
else
{
+ // Check serialization supported by the service against client configuration.
+ // If the client is configured to use Binary serialization *but* the service
+ // doesnt support it, change the client serialization to xmi. Old services will
+ // not return in a reply the type of serialization supported which implies "xmi".
+ // New services *always* return "binary" as a default serialization. The client
+ // however may still want to serialize messages using xmi though.
+ if ( !message.propertyExists(AsynchAEMessage.Serialization)) {
+ // Dealing with an old service here, check if there is a mismatch with the
+ // client configuration. If the client is configured with binary serialization
+ // override this and change serialization to "xmi".
+ if ( getSerializationStrategy().equalsIgnoreCase("binary")) {
+ System.out.println("\n\t***** WARNING: Service Doesn't Support Binary Serialization. Client Defaulting to XMI Serialization\n");
+ // Override configured serialization
+ setSerializationStrategy("xmi");
+ UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(), "handleMetadataReply", JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_client_serialization_ovveride__WARNING", new Object[] { });
+ }
+ }
String meta = ((TextMessage) message).getText();
ByteArrayInputStream bis = new ByteArrayInputStream(meta.getBytes());
XMLInputSource in1 = new XMLInputSource(bis, null);
@@ -832,7 +850,7 @@
return ( AsynchAEMessage.Exception == payload ? true : false);
}
- private Exception retrieveExceptionFormMessage( Message message) throws Exception
+ private Exception retrieveExceptionFromMessage( Message message) throws Exception
{
Exception exception = null;
if ( message instanceof ObjectMessage && ((ObjectMessage)message).getObject() instanceof Exception )
@@ -1025,7 +1043,7 @@
private boolean isShutdownException( Message message ) throws Exception
{
- Exception exception = retrieveExceptionFormMessage(message);
+ Exception exception = retrieveExceptionFromMessage(message);
if ( exception != null )
{
if ( exception instanceof ServiceShutdownException ||
@@ -1044,7 +1062,7 @@
{
clientSideJmxStats.incrementProcessErrorCount();
}
- Exception exception = retrieveExceptionFormMessage(message);
+ Exception exception = retrieveExceptionFromMessage(message);
exception.printStackTrace();
Modified: incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/resources/jms_adapter_messages.properties
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/resources/jms_adapter_messages.properties?rev=737197&r1=737196&r2=737197&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/resources/jms_adapter_messages.properties (original)
+++ incubator/uima/sandbox/trunk/uima-as/uimaj-as-jms/src/main/resources/jms_adapter_messages.properties Fri Jan 23 13:31:56 2009
@@ -157,4 +157,5 @@
UIMAJMS_stopped_listener_INFO = >>>> Controller: {0} - Listener On Queue: {1} Stopped
UIMAJMS_send_failed_deleted_queue_INFO = >>>> Controller: {0} - Failed to Send Message To Queue: {1}. The Queue Has Been Deleted.
UIMAJMS_msg_size__FINE = Controller: {0} Sending {1} Message of Type: {2} to Endpoint: {3} Message Size: {4}
-UIMAJMS_client_sending_ping__FINE = Uima AS Client Sent PING Message To Service: {0}
\ No newline at end of file
+UIMAJMS_client_sending_ping__FINE = Uima AS Client Sent PING Message To Service: {0}
+UIMAJMS_client_serialization_ovveride__WARNING = \n\t***** WARNING: Service Doesn't Support Binary Serialization. Uima AS Client Defaulting to XMI Serialization\n
\ No newline at end of file