Monday 21 July 2014

Solution for InvalidVersionException (Order Version Error in ATG)

While updating the order we might get atg.commerce.order.InvalidVersionException: This order (oXXXXXXX) is out of date.
To fix this problem you must always make sure to update an order within a transaction using the same version. 
In general, the design pattern for updating an order is as follows:
1.      Acquire lock-manager write lock on profile id from the /atg/commerce/order/LocalLockManager
2.      Begin Transaction
3.      Synchronize on the Order object.
4.      Modify Order
5.      Call ((OrderImpl) pOrder).updateVersion();
6.      Call OrderManager.updateOrder()
7.      Release Order synchronization
8.      End Transaction

9.      Release lock-manager write lock on profile id from the /atg/commerce/order/LocalLockManager


Sample Code:

TransactionManager tm = getOrderManager().getTransactionManager();
TransactionDemarcation td = new TransactionDemarcation ();
boolean rollback = false;
try {
                td.begin(mTransactionManager, TransactionDemarcation.REQUIRES_NEW);
                SivarCustomOrderImpl sivarCustomOrder=(SivarCustomOrderImpl) getSivarOrderManager().loadOrder(orderId);
                synchronized (sivarCustomOrder) {
                                sivarCustomOrder.setOpportunityStatus(SivarCartConstants.OPP_STATUS_PENDING);
((SivarCustomOrderImpl) sivarCustomOrder).updateVersion();
                                getSivarOrderManager().updateOrder(sivarCustomOrder);
                }
} catch (TransactionDemarcationException re) {
                rollback=true;
                if (isLoggingError()) {
                                logError(re.getMessage());
                }
}  finally {
                try {
                                td.end(rollback);
                } catch (TransactionDemarcationException e) {
                                if (isLoggingError()) {
                                                logError("TransactionDemarcationException while transaction end: " + e.getMessage(), e);
                                }
                }
}

Note: It's a sample code for your reference.


Saturday 4 January 2014

Litmus 7 ATG Interview Questions


1.       Tell me about your working experience?
2.       Which module of ATG have you worked on?
3.       What is your contribution in your project?
4.       Tell me how Form Handler and Droplet works?
5.       Can we use request scoped component from global scoped component or vice versa?
6.       What extra advantages do ATG provide in eCommerce? (Be specific. Or else cross questions will come :P)
7.       What is ATG Repository?
8.       Do you have idea on ATG Commerce?
9.       How many cache are there in ATG Rep.?
10.   Diff between simple cache and  distributed cache?
11.   Where we use which cache? In DB level.
12.   Tell me about diff cascade modes of ATG?
13.   How many types of table we have in ATG Repository?
14.   Where we use multi table? How to make reference for that? Why?
15.   Diff between auxiliary table and multi table?
16.   What is item-cache-out and what is item-cache-size? How to handle that?

He asked 2 more questions. I have never heard those term. So I forgot  :P