![]() ![]() ![]() ![]() ![]() ![]() |
This chapter discusses the following topics:
This section describes how to create decision-making nodes in the PurchaseOrderFulfillmentJPD that you created in the Designing PurchaseOrderFulfillmentJPD. Decision making nodes are included in the PurchaseOrderFulfillmentJPD to publish the fulfillment results to the message broker channels.
genericPublishControl
with publishPriceInfoControl
.@com.bea.control.PublishControl.ClassPublish(channelName="/ALIntPOApp/OrderPriceInfo")
Note: | This PublishControl is used to publish the OrderPriceInfoDocument received from the external inventory system to the /ALIntPOApp/OrderPriceInfo channel. The PurchaseOrderAggregatorJPD will subscribe to the channel that receives the message. |
Figure 7-1 shows the renamed variable, and the new annotation.
public boolean isUpdateInventorySuccess() {
return priceInfo.getOrderPriceInfo().xgetRejectionCode() == null;
}
Note: | This method tests whether the inventory update is successful, by checking the rejection code in the OrderPriceInfoDocument received from the external inventory system. |
calcOrderPrice
. Click View Code, and type the following code:List<OrderLineItemPriceInfo> itemPriceList = priceInfo.getOrderPriceInfo().getOrderLineItemList();
Iterator<OrderLineItemPriceInfo> priceItr = itemPriceList.iterator();
while (priceItr.hasNext()) {
orderPrice += priceItr.next().getPrice();
}
Note: | In case of compilation errors, ensure that the following imports are added to the code: |
import java.util.Iterator;
import java.util.List;
import org.openuri.purchaseOrder.OrderLineItemPriceInfo;
Note: | Figure 7-3 shows the code in Perform node. |
Note: | The calcOrderPrice method calculates the total order price, which is used to transfer funds from the customer credit card. |
OrderMetadata
and priceInfo
from the Select variables to assign drop-down list. Figure 7-4 shows the variable options on the Send Data tab.Throw Exception
, and rename the method to throwEx
. Enter the following code in the Source view:TxHelper.getUserTransaction().setRollbackOnly();
String errorInfo = ccTranInfo.xgetErrorMessage().getStringValue();
throw new RuntimeException(ccTranInfo.xgetErrorMessage().getStringValue());
Note: | In case of compilation errors, ensure to add the following imports to the code: |
import weblogic.transaction.TxHelper;
You have now reviewed the response from the external inventory system and verified that the inventory update was successful, and no rejection code is set. When the inventory is updated, the OrderPriceInfo document is published to the /ALIntPOApp/OrderPriceInfo channel.
Figure 7-5 shows the process in Design view.
ccTxInfoPublishControl
.@com.bea.control.PublishControl.ClassPublish(channelName = "/ALIntPOApp/OrderCCTransactionInfo")
Figure 7-6 shows both the new variable and the annotation.
public boolean isMoneyTransferSuccess() {
return ccTranInfo.xgetRejectionCode() == null;
}
Check If Money Transfer is Successful
. orderMetadata
, and ccTranInfoDoc
from the Select variables to assign drop-down list. Figure 7-7 shows the variable options on the Send Data tab.throwEx2
. Enter the following code in the Source view:TxHelper.getUserTransaction().setRollbackOnly();
String errorInfo = ccTranInfo.xgetErrorMessage().getStringValue();
throw new RuntimeException(ccTranInfo.xgetErrorMessage().getStringValue());
Figure 7-8 shows the exception code in the Source view.
You have now reviewed the response from the external credit card system and verified that the money transfer was successful and no rejection code is set. If the money transfer transaction is successful, the CreditCardTransactionInfo document is published to the /ALIntPOApp/CCTransInfochannel.
You have designed the PurchaseOrderFulfillmentJPD to invoke the external inventory and credit card systems, in the context of the JPD's implicit transaction. In case of an error, the transaction is rolled back, and an exception is thrown.
In the transaction succeeds, the results are published to respective message broker channels.
The PurchaseOrderAggregatorJPD aggregates the results of the PurchaseOrderFulfillment JPD. This JPD dynamically subscribes to the message broker channels, to which the PurchaseOrderFulfillment JPD will publish the results of the inventory service and credit card service external systems.
This section describes how to design the PurchaseOrderAggregatorJPD to subscribe to the message broker channels and to aggregate the purchase order fulfillment results.
This section discusses the following tasks:
PurchaseOrderAggregatorJPD
as the Name of the Process. Type alint.process
as the Package, if the package is not already set.AggregatePurchaseOrder
, as shown in Figure 7-9.AggregatePurchaseOrder
in Method Name and click Add...java.lang.String orderId
org.openuri.purchaseOrder.ShippingAddressDocument shippingAddress
java.lang.String customerName
Table 7-1 lists the parameters and types of these variable names.
public java.lang.String customerName;
public java.lang.String OrderId;
public org.openuri.purchaseOrder.ShippingAddressDocument shippingAddr;
public org.openuri.purchaseOrder.OrderPriceInfo priceInfo;
public org.openuri.purchaseOrder.CCTransactionInfo ccTransactionInfo;
public org.openuri.purchaseOrder.PurchaseOrderId purchaseOrderId;
public org.openuri.purchaseOrder.ConsignmentInfo consignmentInfo;
public org.openuri.purchaseOrder.PurchaseOrderStatusDocument status;
Figure 7-11 shows instance variables in Source view.
AggregatePurchaseOrder
method name:@Protocol(jmsSoap = true, javaCall = true)
this.orderId = orderId;
this.shippingAddr = shippingAddress;
this.customerName = customerName;
// #END : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
purchaseOrderId = org.openuri.purchaseOrder.PurchaseOrderId.Factory.newInstance();
purchaseOrderId.setOrderId(this.orderId);
Figure 7-12 shows the code added in Source view.
orderPriceSbscrptnn
. orderPriceSbscrptnn
line in Source view.@com.bea.controls.SubscriptionControl.ClassSubscription(channelName = "/ALIntPOApp/OrderPriceInfo",
xquery = "data($metadata)",
xqueryVersion = com.bea.wli.common.XQuery.Version.v2004)
orderId
from the Select Variables to Assign drop-down list.ccTxInfoSbscrptnn
in Source view.ccTxInfoSbscrptnn
line in Source view:@com.bea.controls.SubscriptionControl.ClassSubscription(channelName = "/ALIntPOApp/OrderCCTransactionInfo",
xquery = "data($metadata)",
xqueryVersion = com.bea.wli.common.XQuery.Version.v2004)
orderId
from the Select Variables to Assign drop-down list.You have now designed the PurchaseOrderAggregatorJPD to subscribe to the message broker channels to which the results of the PurchaseOrderFulfillmentJPD are published.
try
{
priceInfo = org.openuri.purchaseOrder.OrderPriceInfo.Factory.parse(message.xmlText());
}
catch (XmlException e) {
throw new RuntimeException(e);
}
try {
ccTransactionInfo = org.openuri.purchaseOrder.CCTransactionInfo.Factory.parse(message.xmlText());
} catch (XmlException e) {
throw new RuntimeException(e);
}
Note: | You have now designed the PurchaseOrderAggregatorJPD to aggregate the results from the message broker channels. |
Note: | ServiceProviderAccessControl is the ALSB Control that you created in Creating AquaLogic Service Bus Control. |
this.consignmentInfo = org.openuri.purchaseOrder.ConsignmentInfo.Factory.parse(serviceProviderAccessControl.accessService(“ShippingService”, this.purchaseOrderId).xmlText());
Figure 7-13 shows the code you have just added.
archiveOrder
in JavaMethodName.public void archiveOrder() throws Exception {
File orderFile = new File("C:/ALIntApp/PurchaseOrder/New/PO-" + orderId + ".xml");
orderFile.renameTo(new File("C:/ALIntApp/PurchaseOrder/Archive/PO-" + orderId + ".xml"));
}
After you have added the Perform node, you must unsubscribe from the subscriptions.
In the next step, you send the Purchase Order status as a callback.
AggregatePurchaseOrderStatus
.PurchaseOrderStatusDocument x0
, as shown in Figure 7-14.status = org.openuri.purchaseOrder.PurchaseOrderStatusDocument.Factory.newInstance();
org.openuri.purchaseOrder.PurchaseOrderStatusDocument.PurchaseOrderStatus s = status.addNewPurchaseOrderStatus();
org.openuri.purchaseOrder.PurchaseOrderId poID = s.addNewPurchaseOrderId();
poID.setOrderId(this.orderId);
s.setConsignmentInfo(this.consignmentInfo);
s.setOrderLineItemInfo(this.priceInfo);
s.setCCTransactionInfo(this.ccTransactionInfo);
s.setCustomerName(this.customerName);
// #START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
// input transform
// method call
callback.AggregatePurchaseOrderStatus(this.status);
// output transform
// output assignments
// #END : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
Figure 7-15 shows the Source view.
Figure 7-16 shows the Purchase Order Aggregator JPD in Design view.
The business service end points are used by ALSB proxy services to invoke the Purchase Order Aggregator JPD for aggregating the purchase order results.
Select AquaLogic Service Bus from the Open Perspective dialog box.
PurchaseOrderAggregatorJPDBS
, and click Next. ServiceAccess\Resources
as the Artifact folder.PurchaseOrderAggregatorJPDContract.wsdl
, and then select PurchaseOrderAggregatorJPDSoap(port), click OK, as shown in Figure 7-18.jpd::/UseCaseWeb/alint/process/PurchaseOrderAggregatorJPD.jpd
. Click Add. and click Next. Figure 7-19 shows the default values selected.
The PurchaseOrderAggregatorJPDBS.biz
file is created in the Business Services folder in Project Explorer. In PurchaseOrderAggregatorJPDBS.biz, click the JPD tab. Ensure that the Callback Proxy Location is jms://localhost:7001/weblogic.jms.XAConnectionFactory/PurchaseOrderNotificationServiceRequest
.
Notes: | Callbacks are only supported over JMS when JPD transport is used. Therefore, you must configure it over JMS. |
Note: | While configuring the JPD transport for invoking JPD as a business service, you must specify the location to the callback proxy, which is configured for JMS (in callback pipeline). WLI sends the callback response to the queue on which callback proxy is configured (in callback pipeline). Along with the response, WLI also sends the original callback location, which is part of the original request, as a JMS transport header. You can configure the callback pipeline so that the callback is sent to this callback location. |
Note: | The original callback location is sent as a JMS property namely BEA_WLI_Target_Callback_Location . If the original callback location contains any additional query strings, those query strings are also be sent as JMS transport headers. You must retrieve this property from the message context variable $inbound , and this can be used to configure the outgoing business service for sending the callback, to the actual JPD callback client. |
![]() ![]() ![]() |