This post explains how you can read file in OSB. You can read any type of file like you can do in SOA.
Follow below steps to read file in Oracle Service Bus.
Step 1.) Create new OSB project and Proxy Service.
Follow below steps to read file in Oracle Service Bus.
Step 1.) Create new OSB project and Proxy Service.
- First of all create Session by clicking on "Create" Button and then click on "Project Explorer" to create new project.
- Enter the name of the project "ReadFile" and add it.
- Now click on newly created project "ReadFile" to add new folders.
- Add "proxyService" folders which contains proxy service that will poll/read the file from given location.
- Now click on newly created "proxyService" folder to create proxy service and choose "Proxy Service" as Resource Type.
Step 2.) Fill details in Proxy Service to read/poll file.
- Enter proxy service name and choose "Service Type" as "Messaging Service". Click on "Next" button.
- Choose "Request Message Type" based on what type of file you want to read/poll. In my case its text file so I will choose "Text". Choose "Response Message Type" as "None" because we don't need any response after reading the file. Click on "Next" button.
- Choose "file" protocol from drop down list.
- Provide the "Endpoint URI". Click on "Next" button.
file:///{Drive Id}/filedir/
- Next step is to provide File Transport Protocol details.
- File Mask: Default value is *.* that means you can send any type of file to the service. I created "test.txt" file in C:/read directory for this post.
- Polling Interval: It specifies the number of seconds between each polling event. Leave it as default.
- Read Limit: It specifies the maximum number of files to process during each polling event.Default value is 10. If you set it to 0 that means all files that match the file mask at the time of polling event will be processed. Leave it as default.
- Sort By Arrival : It forces the selection of files while polling based on their creation date. Remain it unchecked.
- Scan SubDirectories: It says OSB proxy look for files recursively in any existing subdirectories. Leave it unchecked.
- Pass By Reference : It tells copy the file to archive directory and pass a reference to the file in the message itself. Leave it unchecked.
- Post Read Action: It tells we can either delete the file or archive the file after the message has been processed. Choose "delete" for this sample.
- Stage Directory : It specifies where the files should be stored while they are being processed. So while polling, OSB first move file from polling directory to stage directory and process file from there.
- Archive Directory : Directory where we want to archive the file. This will not be available if you choose "delete" as Post Read Action.
- Error Directory: Directory where file will be sent of there is any problem or issue.
- Accept default values and you are done with your proxy service.
- Activate the session and to test proxy service put test.txt file in C:./read directory.
Create Business Service as per your requirement how you want to process file message.
Go through next post which explain how to write file in Oracle Service Bus.
Write file in OSB
Go through next post which explain how to write file in Oracle Service Bus.
Write file in OSB
Hi Pratik,
ReplyDeleteOSB always move the file to stage directory before it start to read it so I don't think OSB will not be able to delete the file, if it can read the file.
Hi Vivek,
ReplyDeleteI have 1 scenario, wherein we need read file from multiple directory. Can you please tell me how we can add multiple directory into the Endpoint URI.
Hi,
ReplyDeleteI have a scenario where I wanna place files in the target with different file system (apart from the landing directory File system). How can i achieve that?
Thanks in advance!!!