svn commit: r564072 - in /ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis: OagisServices.java OagisShipmentServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r564072 - in /ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis: OagisServices.java OagisShipmentServices.java

jonesde
Author: jonesde
Date: Wed Aug  8 19:01:30 2007
New Revision: 564072

URL: http://svn.apache.org/viewvc?view=rev&rev=564072
Log:
Changed to call showShipment async and persisted to effect a retry that will help with certain errors

Modified:
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java
    ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java

Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java?view=diff&rev=564072&r1=564071&r2=564072
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisServices.java Wed Aug  8 19:01:30 2007
@@ -449,7 +449,9 @@
                 }
             } else if (bsrVerb.equalsIgnoreCase("SHOW") && bsrNoun.equalsIgnoreCase("SHIPMENT")) {
                 try {
-                    subServiceResult = dispatcher.runSync("showShipment", UtilMisc.toMap("document",doc));
+                    //subServiceResult = dispatcher.runSync("showShipment", UtilMisc.toMap("document",doc));
+                    // DEJ20070808 changed to run asynchronously and persisted so that if it fails it will retry
+                    dispatcher.runAsync("showShipment", UtilMisc.toMap("document",doc), true);
                 } catch (GenericServiceException e) {
                     String errMsg = "Error running service showShipment: "+e.toString();
                     errorList.add(UtilMisc.toMap("description", errMsg, "reasonCode", "GenericServiceException"));

Modified: ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java?view=diff&rev=564072&r1=564071&r2=564072
==============================================================================
--- ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java (original)
+++ ofbiz/trunk/specialpurpose/oagis/src/org/ofbiz/oagis/OagisShipmentServices.java Wed Aug  8 19:01:30 2007
@@ -221,9 +221,23 @@
                 String shipmentPackageSeqId = UtilXml.childElementValue(shipUnitElement, "of:SHPUNITSEQ"); // of
                 List invItemElementList = UtilXml.childElementList(shipUnitElement, "ns:INVITEM"); //n
                 if(UtilValidate.isNotEmpty(invItemElementList)) {
-                    Iterator invItemElementItr = invItemElementList.iterator();
-                    while(invItemElementItr.hasNext()) {                
-                        Element invItemElement = (Element) invItemElementItr.next();
+                    // sort the INVITEM elements by ITEM so that all shipments are processed in the same order, avoids deadlocking problems we've seen with concurrently processed orders
+                    List invitemMapList = FastList.newInstance();
+                    Iterator invItemElementIter = invItemElementList.iterator();
+                    while(invItemElementIter.hasNext()) {                
+                        Element invItemElement = (Element) invItemElementIter.next();
+                        String productId = UtilXml.childElementValue(invItemElement, "of:ITEM"); // of
+                        Map invitemMap = FastMap.newInstance();
+                        invitemMap.put("productId", productId);
+                        invitemMap.put("invItemElement", invItemElement);
+                        invitemMapList.add(invitemMap);
+                    }
+                    UtilMisc.sortMaps(invitemMapList, UtilMisc.toList("productId"));
+                    
+                    Iterator invitemMapIter = invitemMapList.iterator();
+                    while(invitemMapIter.hasNext()) {
+                        Map invitemMap = (Map) invitemMapIter.next();
+                        Element invItemElement = (Element) invitemMap.get("invItemElement");
                         String productId = UtilXml.childElementValue(invItemElement, "of:ITEM"); // of
                         
                         try {