Wednesday, August 5, 2020

Pushing Request to queue using JMS adapter in SOA 12c

Hello everyone! In this post, I'm going to show you how we use jms adapter to publish a message to queue in SOA 12c. So lets get started.


1. Create a SOA project with empty composite.


Drag and drop a BPEL with Synchronous interaction Type. Check the check box "Expose as a SOAP service". You can create a schema with input and output variables or you can just leave them as default.


2. Drag and drop a JMS adapter to the External Services side. give it a suitable name and click Next.


Select the Messaging service and click Next..


Select your connection and click Next.


Select the Interface as "Specified later".


Select the Operation Type as Produce Message.


Browse your Queue JNDI for "Destination Name(Queue)" and give the correct JNDI name for "JNDI Name" value which is your actual JMS JNDI. Don't get confused this with queue JNDI.


In the next screen, browse the schema by clicking on highlighted magnifier icon.


Select your BPEL input from XSD schema.


Click Next.


Click Finish.


Wire the BPEL  to JMS adapter.


3. Edit the BPEL and drag and drop an Invoke activity to invoke the JMS adapter. Select the JMS partner link and create an input variable.


Now, drag and drop an Assign activity just after Receive activity to map the BPEL input to Invoke Input variable. Click Apply and click OK.


Drag and drop another Assign activity after Invoke. Add a custom message to BPEL output variable. Click Apply and then OK.


Your final composite should look like below. Now deploy your service to test it.


Enter something in the Request payload.


You'll see the Response as below.



5. Now, we need to check the JMS queue if the message has been published to the queue. Got to weblogic console page. Click on Service>Messaging>JMS Modules.


Click on your JMS Module.


Click on your queue which you gave in JMS adapter configuration.


Go to Monitoring.


Check the check box and click on "Show Messages".


Click on the Message ID to view the message.


And here is your message that is published to queue.


Happy learning and Cheers:)

Monday, August 3, 2020

Inserting multiple records into table from a text file in Oracle SOA 12c

Hi! In this post, I'm going to show you how we can insert multiple records into the database table using data from a text file. I'm using sample Emp data that needs to be inserted into db. So, I created a table with just three columns and my table structure is as below.


1. Create a SOA project with suitable name.



Drag and drop a File adapter to the Exposed Services side. Give a name to it. Click Next.



Leave the default interface as "Define from Operation and schema(specified later).



Select the JNDI name.



Select the Operation Type as Read.



Browse the folder where you have the text file that contains data and click Next. Here I've unchecked the option "Delete files after successful retrieval" because I don't want it to be deleted after reading. It is up to you whether you check or uncheck this option.



Specify the pattern of the file(s) it should take. In my case, I gave the pattern as "EmpData*.txt" which means it would take the files starting with EmpData that are of .txt type.
For example, in my case, I have a file named EmpData.txt. If I have the files such as EmpData123.txt, EmpData85.txt., they would also be taken for processing. Check the option Files contain Multiple Messages. Click Next.



Leave the default Polling Frequency, you can change it if you want. Click Next.



Here, we need to create a schema. So click on the highlighted icon to create a native schema.



You can change the name if you want. Click Next.



Select the file type as Delimited.



Select the file that you want to give as sample. Click Next.



Click Next.



Give a name for the element that will represent record. It will use it to generate the element in XML creation.



Click Next.



I have the header names in my file. So I want to use the first record as field names. If you don't have the header records, don't check this option "Use the first record as the field names".



It will generate XML based on the data. You can test it by clicking on Test option.



Click Finish.



Now that we've done with schema creation, it will take the schema that is just created. Click Next.


In the next step, click Finish.



2. Drag and drop a BPEL from the Components window. Select No Service in the "Template Type".



Wire the BPEL to file adapter.



3. Drag and drop a db adapter into the External References side. Give it a suitable name and click Next.



Select the connection and click Next.



Select the Operation Type as Insert Only and click Next.



Click on the "Import Tables" to import a table.



Select the required table and click Next.



Click Next.



Select the column that you want as the primary key and click Next. It will automatically take if you already have one.



Click Next.



Select the columns where you want to insert data.



Click Next.



Click Next.



Click Finish. With this, we've completed creating a database adapter based on Insert operation.



4. Wire the BPEL to the db adapter as well.



Edit the BPEL and drag and drop a Receive activity. Select the Partner link as the file adapter and create an Input variable. Click Apply and then OK.



Drag and drop an Invoke activity just after Receive activity. Select the Insert database partner link and create an Input variable. Click Apply and click OK.



Now, drag and drop an Assign activity to map the input variables from File to database adapter. Click Apply and then OK.



With this, you've completed all the steps in designing a service that takes input from a text file and inserts records into the database table.


Deploy your composite and search the Flow Instances.


Now check your table to see if the records have been inserted into it.



Hope this post helped you. If you have any queries, hit them in the comment section below. See you in the next post. Until then, Happy Learning. Cheers!!

Featured Posts

Sample Real Time Assignment in Oracle SOA