eca execution ordering & transaction commit problems

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

eca execution ordering & transaction commit problems

justin.g.robinson
I've got 2 order related services that are supposed to run one after the
other, synchronous.
Problem is there ordering. The one service takes info collected in an order
survey and creates a SubscriptionUser Entity. For this entity to be created
it needs data from many tables, this data only all becomes at a certain
point it seems. Originally I triggered it with the eca:

 <eca service="changeOrderStatus" event="commit" run-on-error="false">
        <condition field-name="statusId" operator="equals"
value="ORDER_APPROVED"/>
        <action service="subs.createSubscriptionUserFromSurveyResponse"
mode="sync"/>
 </eca>

I tested this and the entity was being created fine. But then this
fullfillment service which appeared to run later, requires the
SubscriptionUser entity that was created to do it's work & I found that it
wasn't yet in the database when the fullfillment service runs. Knowing from
logging output that the fullfillment service runs after ORDER_APPROVED I
thought to trigger the service at some time before, like by using <eca
service="storeOrder", but the SubscriptionUser entity uses a view entity
which joins many tables & all this data isn't available at the "storeOrder"
point.

The fulfillment service seems to be triggered from:

<eca service="changeOrderItemStatus" event="commit">
        <condition field-name="statusId" operator="equals"
value="ITEM_APPROVED"/>
        <action service="checkDigitalItemFulfillment" mode="sync"/>
</eca>

Which seems rather abitary actually, since the checkDigitalItemFulfillment
then goes and looks up all order items under the OrderHeader and itterates
through them calling the service associated with the product content.
changeOrderItemStatus invokes setItemStatus in OrderServices.java, for each
item presumably. But then wouldn't the product content fulfillment get done
multiple times & it doesn't so am not sure.

I just need to make checkDigitalItemFulfillment run after
subs.createSubscriptionUserFromSurveyResponse has saved to the database. So
I removed the eca service="changeOrderItemStatus" statement from the order
apps seca & added the following to my components seca:

 <eca service="changeOrderStatus" event="commit" run-on-error="false">
        <condition field-name="statusId" operator="equals"
value="ORDER_APPROVED"/>
        <action service="subs.createSubscriptionUserFromSurveyResponse"
mode="sync"/>
 </eca>

 <eca service="subs.createSubscriptionUserFromSurveyResponse"
event="commit">
        <action service="checkDigitalItemFulfillment" mode="sync"/>
 </eca>


But the lookup in the content's fulfillment service that gets the
SubscriptionUser entity saved in createSubscriptionUserFromSurveyResponse,
returns zero results, even though when I go look in the database the
SubscriptionUser entity is there.

I even tried changing the event to:

<eca service="subs.createSubscriptionUserFromSurveyResponse" event="return">
        <action service="checkDigitalItemFulfillment" mode="sync"/>
 </eca>

Hoping by time it returned it would be in that database. No luck. The fact
that it's not in the databse yet must have to do with transactions or the
cache.

Does anyone have an idea what I could be missing?
Regards,
Justin
Venture-Net Research & Development