Consider the following composite:
Here, FileRead & FileWrite and 2 file adapters.
File Read is reading file to send messages to mediator, whereas File Write is taking the input and writing the output to another file.
Here is the configuration of FileRead adapter:
The MultiPurchaseOrders.xsd is creating using the Native File Builder wizard, and here is its content:
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
xmlns:tns="http://TargetNamespace.com/FileRead"
targetNamespace="http://TargetNamespace.com/FileRead"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
nxsd:version="NXSD"
nxsd:stream="chars"
nxsd:encoding="US-ASCII"
>
<xsd:element name="Root-Element">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="PurchaseOrder" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CustID" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="ID" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="productName" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="itemType" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="price" type="xsd:decimal" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="quantity" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="status" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="ccType" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="ccNumber" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy=""" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<!--NXSDWIZ:C:\FileReadInput\raw_text.txt.txt:-->
<!--USE-HEADER:false:-->
The above schema was creating using the following data:
1111,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
The FileWrite adapter is also using the same schema, and here is how FileWrite Adapte was created:
So, what I was trying to do is to send 2 records at a time from one file to another. Here is the input to the composite:
1111,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
2222,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
3333,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
4444,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
5555,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
6666,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
7777,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
8888,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
9999,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
1010,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
And here is how the output looks like:
Since, I tries this multiple times before, so the sequence have reached the count of 18. As you can see, there are 12 records instead of 10 ( with 2 records coming from previous request, with ID 9999 & 1010 ).
The EM shows the correct instance count, ie 5, as shown below:
After deleting old files and instances, I ran the test case again by put the input file to C:\FileRead directory, and here is how the output looks like:
As you can see, 2 records are missing. This is because FileWrite adapter have only received 1 message as of now since 2 records create 1 message that is send from FileRead adapter.
However, FileWrite is configured to accept 2 messages so its waiting for another message.
The point here is that FileWrite adapter waits if the Batch message count is not reached.
Now, test the same for FileRead adapter. Here is the input that I am going to send as input now to check if FileRead adapter also waits for batch count to be reached:
1111,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
2222,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
3333,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
4444,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
5555,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
6666,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
7777,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
8888,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
9999,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
0000,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
1000,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
After deleting all the instances and earlier input files, I ran the test case again and here is the ouptut:
As you can see, all the records are written. Here is how the instance count looks like in EM console:
There are 6 instances, so each composite contains 2 records, and sending it as a single message except one. And here is that instance which contains only 1 record:
The question is if FileRead adapter is configured to read 2 records in a batch, then why even a single message is picked up and send?
FileWrite adapter was waiting for another request to complete the batch, whereas FileRead adapter did't. Any specific reason of why its like that?
Here, FileRead & FileWrite and 2 file adapters.
File Read is reading file to send messages to mediator, whereas File Write is taking the input and writing the output to another file.
Here is the configuration of FileRead adapter:
The MultiPurchaseOrders.xsd is creating using the Native File Builder wizard, and here is its content:
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
xmlns:tns="http://TargetNamespace.com/FileRead"
targetNamespace="http://TargetNamespace.com/FileRead"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
nxsd:version="NXSD"
nxsd:stream="chars"
nxsd:encoding="US-ASCII"
>
<xsd:element name="Root-Element">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="PurchaseOrder" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CustID" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="ID" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="productName" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="itemType" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="price" type="xsd:decimal" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="quantity" type="xsd:int" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="status" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="ccType" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy=""" />
<xsd:element name="ccNumber" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy=""" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<!--NXSDWIZ:C:\FileReadInput\raw_text.txt.txt:-->
<!--USE-HEADER:false:-->
The above schema was creating using the following data:
1111,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
The FileWrite adapter is also using the same schema, and here is how FileWrite Adapte was created:
So, what I was trying to do is to send 2 records at a time from one file to another. Here is the input to the composite:
1111,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
2222,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
3333,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
4444,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
5555,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
6666,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
7777,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
8888,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
9999,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
1010,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
And here is how the output looks like:
Since, I tries this multiple times before, so the sequence have reached the count of 18. As you can see, there are 12 records instead of 10 ( with 2 records coming from previous request, with ID 9999 & 1010 ).
The EM shows the correct instance count, ie 5, as shown below:
After deleting old files and instances, I ran the test case again by put the input file to C:\FileRead directory, and here is how the output looks like:
As you can see, 2 records are missing. This is because FileWrite adapter have only received 1 message as of now since 2 records create 1 message that is send from FileRead adapter.
However, FileWrite is configured to accept 2 messages so its waiting for another message.
The point here is that FileWrite adapter waits if the Batch message count is not reached.
Now, test the same for FileRead adapter. Here is the input that I am going to send as input now to check if FileRead adapter also waits for batch count to be reached:
1111,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
2222,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
3333,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
4444,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
5555,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
6666,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
7777,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
8888,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
9999,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
0000,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
1000,2121,Bluetooth Headset,Electronics,49.99,1,Initial,Mastercard,8765-8765-8765-8765
After deleting all the instances and earlier input files, I ran the test case again and here is the ouptut:
As you can see, all the records are written. Here is how the instance count looks like in EM console:
There are 6 instances, so each composite contains 2 records, and sending it as a single message except one. And here is that instance which contains only 1 record:
The question is if FileRead adapter is configured to read 2 records in a batch, then why even a single message is picked up and send?
FileWrite adapter was waiting for another request to complete the batch, whereas FileRead adapter did't. Any specific reason of why its like that?
No comments:
Post a Comment