Skip to content

Commit

Permalink
Used oms-rest service runner to call the OMS rest api. Also reduced s…
Browse files Browse the repository at this point in the history
…ervice transaction timeout from 3600 tp 120
  • Loading branch information
dixitdeepak committed Aug 1, 2024
1 parent 211c15c commit 4622b45
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 44 deletions.
11 changes: 2 additions & 9 deletions service/co/hotwax/common/CommonServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@

<service verb="check" noun="OmsConnection">
<actions>
<script>
omsBaseUrl = co.hotwax.util.MaargUtil.getOmsInstanceUrl(ec.ecfi);
</script>
<set field="omsBaseUrl" from="co.hotwax.util.MaargUtil.getOmsInstanceUrl(ec.ecfi)"/>
<if condition="!omsBaseUrl">
<entity-find-one entity-name="moqui.service.message.SystemMessageRemote" value-field="omsSystemMessageRemote">
<field-map field-name="systemMessageRemoteId" value="HC_OMS_CONFIG"/>
</entity-find-one>
<if condition="!omsSystemMessageRemote || !omsSystemMessageRemote.remotePublicKey">
<return error="true" message="OMS token not configured." />
</if>
<return error="true" message="OMS instance not configured." />
</if>
</actions>
</service>
Expand Down
35 changes: 1 addition & 34 deletions service/co/hotwax/order/routing/InventoryReservationServices.xml
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://moqui.org/xsd/service-definition-3.xsd">

<service verb="run" noun="OmsApi" type="interface">
<in-parameters>
<parameter name="token"/>
<parameter name="omsBaseUrl"/>
</in-parameters>
</service>
<service verb="run" noun="OmsFacilityAllocation" type="remote-rest" location="${omsBaseUrl}/api/service/orderFulfillmentAllocation?token=${token}" method="post" transaction-timeout="3600">
<implements service="co.hotwax.order.routing.InventoryReservationServices.run#OmsApi"/>
<service verb="run" noun="FacilityAllocation" type="oms-rest" location="service/orderFulfillmentAllocation" method="post" transaction-timeout="120">
<in-parameters>
<parameter name="facilityAllocation" type="List"/>
<parameter name="orderId"/>
</in-parameters>
</service>
<service verb="run" noun="FacilityAllocation" transaction-timeout="3600">
<in-parameters>
<parameter name="facilityAllocation" type="List" required="true"/>
<parameter name="orderId" required="true"/>
</in-parameters>
<out-parameters>
<parameter name="result"/>
</out-parameters>
<actions>
<!-- In case of schedule job run no user logged in, use system user to get the token-->
<set field="userName" from="ec.user.username" default-value="${System.getProperty('default.brokering.user')}"/>
<script>
omsBaseUrl = co.hotwax.util.MaargUtil.getOmsInstanceUrl(ec.ecfi);
token = co.hotwax.util.MaargUtil.getOmsJwtToken(ec.ecfi, userName);
</script>
<if condition="!token">
<return error="true" message="Unable to generate oms token, check JWT configuration"/>
</if>
<if condition="!omsBaseUrl">
<return error="true" message="OMS base url not found"/>
</if>
<service-call name="co.hotwax.order.routing.InventoryReservationServices.run#OmsFacilityAllocation" transaction-timeout="3600"
in-map="[orderId: orderId, token: token, facilityAllocation: facilityAllocation]" transaction="force-new"
out-map="result"/>
</actions>
</service>
</services>
2 changes: 1 addition & 1 deletion service/co/hotwax/order/routing/OrderRoutingServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@
<script>
try {
outResult = ec.service.sync().name("co.hotwax.order.routing.InventoryReservationServices.run#FacilityAllocation")
.requireNewTransaction(true).transactionTimeout(3600)
.requireNewTransaction(true).transactionTimeout(120)
.parameters([orderId: orderId, facilityAllocation: facilityAllocation])
.call()
if (ec.message.hasError()) {
Expand Down

0 comments on commit 4622b45

Please sign in to comment.