Showing posts with label service bus. Show all posts
Showing posts with label service bus. Show all posts

Wednesday, 26 February 2020

OSB 12c : Dynamic Routing to Business/Proxy Service


Dynamic routing is a kind of  Content-based Routing pattern, which is used when the BusinessService/ProxyService path is required to be determined at run time, an alternative to Static Routing, which is used when the BusinessService/ProxyService path is established during design time.

As for example, if there are different services eg. BusinessService1, BusinessService2, ProxyService1 that are each based on the same interface, we can use dynamic routing.

The core of this feature is built on the following XML element:

<ctx:route>
<ctx:service isProxy=”true|false”>{$proxy|$businessService}</ctx:service>
<!– Optional : –>
<ctx:operation>{$operationName}</ctx:operation>
</ctx:route>




The isProxy is true or false according to whether the dynamic route is to a Proxy Service or to a Business Service respectively.

Operation is an optional element and is used when you want to invoke a particular operation of a multi-operation ProxyService.

Note: The text inside the Expression tab is a string literal. Any XQuery expressions must be wrapped by braces {}.

The above element in the expression of a dynamic routing action inside a route node, etc. looks like this when executed:

BS:
<ctx:route>
<ctx:service isProxy="false">ServiceCalloutTest/BusinessService1</ctx:service>
</ctx:route>

PS:
<ctx:route>
<ctx:service isProxy="true">ServiceCalloutTest/ProxyService1</ctx:service>
<ctx:operation>initiate</ctx:operation>
</ctx:route>

Now say based on some field element in the input or some variable value you fetch within your pipeline you want to route to a BS or a PS.

Your element variable assume here is alias which can have values say US, IND at runtime based on which you route to the service.

We will create RoutingTable variable on that basis like below using an assign activity.

<Services>
<Service>
<alias>US</alias>
<physical>ServiceCalloutTest/BusinessService1</physical>
</Service>
<Service>
<alias>IND</alias>
<physical>ServiceCalloutTest/BusinessService2</physical>
</Service>
</Services>


So finally in your Dynamic Routing activity below is the expression:

<ctx:route>
<ctx:service isProxy='false'>{$RoutingTable/Service[alias/text()=$alias]/physical/text()} </ctx:service>
</ctx:route>

In the request pipleline you can add activities for process the body/header etc based on what you need to send to the endpoint service















Save and activate your service and Test to verify if working as expected.


Helpful? Comment

Happy Learning.


Thursday, 20 February 2020

OSB 12c : Message Throttling for a Business Service

Why? - To control the flow of messages to a business service and prevent delays, you can enable and configure message throttling or throttling for business services in your Service Bus applications.

What? - When you use throttling to control message flow, a throttling queue is created, in which messages are queued when a business service reaches its maximum concurrency or when a group limitation reaches its maximum competition. Messages with the same priority are processed on a first-in-first-out basis.
The Throttling Queue is a queue in memory. Once a message has been in the Throttling Queue for an interval greater than the message expiration value configured for the business service, it becomes an expired message and is removed from the queue. When you delete or rename a business service, all messages in the throttling queue are deleted.
When you enable or disable Throttling, as well as the configuration of throttling properties, in the Properties tab of the home page of the business service in Fusion Middleware Control, all the modifications that you apply on this page take effect immediately.

How? - When Throttling is enabled, message flow is restricted to endpoints and messages are processed by priority. You can optionally prioritize messages using the routing options; otherwise, messages are deleted using the first in, first out method.

To configure the limitation for a business service:
1. In the Target Navigation panel of the Fusion Middleware Control, extend SOA > service-bus and click on the name of the project that contains the business service to configure.

2. The Service Bus Project home page appears, click on Properties

3. Check the Throttling State enabled checkbox :













4. Enter the following information:
Maximum Concurrency : The maximum number of records that the business service can process simultaneously. This value cannot be 0 (zero); it must be a positive integer.
Throttling Queue : The maximum number of messages in the Throttling Queue. A value of 0 indicates that there is no Throttling Queue.
Message Expiration : The number of milliseconds that a message can be in the queue before expiration. A value of 0 means that messages do not expire.

To deactivate the limitation for a business service, simply un-check the Throttling State box :









Helpful? Comment.

Happy Learning!

Friday, 17 November 2017

OSB 12c FileAdapter : Physical/Logical Output Directory has invalid value BINDING.JCA-11043

Once trying to deploy a OSB FileAdapter service and activating the changes I received the below Error:

Error(s) found in module 'FileAdapterService'.
Invalid JCA transport endpoint configuration, exception: BINDING.JCA-11043
Invalid Interaction parameter.
Invalid Interaction parameter.
Interaction parameter Physical/Logical Output Directory has invalid value {/placeholder}.
Please correct the value of the interaction parameter and redeploy the process.
 at FileAdapter.biz

Cause -
The issue is typically caused by a invalid directory definition in the business service.
Means, the file path that you have defined in the adapter is invalid.

Solution -
Correct the file path definition, check if the path is valid and has the right permissions.


Helpful? Please Comment.

Happy Learning!!

Thursday, 12 October 2017

OSB 12c : Email Polling with Attachment

This is what you should do if you want to use the email protocol to initiate your OSB service based on email in the Mail Inbox.

Overview:
The Proxy service polls the Mail Inbox for the new messages and invokes the Business service whenever there is a new message in the Inbox.
The polling interval can be specified in the Proxy Service configuration.

You can read the contents of the email or can process an email attachment.

We will be using the 12c JDeveloper to create the service. You can do the same on the service-bus console.

Steps:
1. Create an Service Bus Application and Project.



2. Name your application and project.





3. Once your application and project are created, create your folder structure like below:



4. First we will create a Service Account, with static username/password of the mail account.

 



5.  Save.
6. Now we will create a Business Service which will be invoked based on the email.

Note: This Business Service can do anything you want to do with the data you receive.
Example:
a. Invoke a service (say BPEL) with the email body payload as input or
b. Read the attachment and process to a file location using file transport

We will cover example b today.

7. Name the service and select file transport. We are not using the file adapter jca here.



8. Keep the Service Type below:

 

9. Define the server directory path starting with the root till the directory you want to place the file.



10. On the Business Service leave other values default, Save.
11. Open your composite.xml and on the External Services swim-lane  right click > Choose > Business Service > Select Business Service WriteEmail_BS > Ok






 You can also drag-drop your business service to the swim-lane.

12. On the middle swim-lane, Pipelines/Split Joins, right-click > Insert > Pipeline
13. Name your pipeline, change Location to Services\Proxy Service , Next


 
14. Define the Service Type as Messaging - Text/None and check Expose as a Proxy Service.
Name your Proxy Service with transport as email.



15. Finish.
16. Your composite should look like below:

 

17. Open the Proxy Service, click on the Transport tab and provide the mail server host and port



Here we are using Outlook Office 365 email server on port 993 or 143

18. Click on the Transport Details tab, select the service account we created, email protocol as imap, specify the polling interval as per requirement, select the Post Read Action as per the requirement and also specify the Download/Archive/Error directories accordingly and Save All.




19. Open you Pipeline, right-click and add a pipeline-pair node
20.  In the request pipeline stage add an Assign action. We will use it to get the attachment name.
This value is part of the context variable - $attachments
Use the below expression:



assign it to variable attachmentname.

 21. Add one Assign  and Replace actions to map the attachment contents to outgoing $body like below


 


22. Add one Publish action and set the target Service to the Business Service WriteEmail_BS.bix
23. Inside the Publish insert a Transport Header action, with below parameters




Test:

Send an email to the user account email.


This will trigger your service and as a result write the attachment to the file location on the server.


Helpful? Please Comment.

Happy Learning!!

OSB 12c : Dynamic Routing to Business/Proxy Service

Dynamic routing is a kind of  Content-based Routing pattern, which is used when the BusinessService/ProxyService path is required to be de...