Monday, 30 March 2015

Synchronous Communication from Business Events.

==============================================

Is it possible to get a response Synchronously from a Business Events rule?

Yes, it is possible to get Synchronous reply from BusinessEvents. There are few situation where it is very much require to do so.
1.  Calling a SOAP service from TIBCO BusinessEvents.
2.  Getting some responses in Inference Engine from Query Engine. 

In order to achieve these requirements use HTTP channel and invoke the function HTTP.sendRequest().

Here is the synopsis.
===============
1. Create a "Request event" with default HTTP destination.
2. Create a "Response event".
3. In the rule. 
    a. create the instance of the request event.
    b. invoke HTTP.sendRequest(URL of the service, request event Instance, URI of the response 
                                                    Event, TimeOut)
        e.g    Event.responseEvent  respone =  HTTP.sendRequest( 
                                                               "http://localhost:6666/Channels/HTTP/GetCustomerDetails", 
                                                                requestEvent, 
                                                                "/Events/responseEvent",-1);

Code

4.  From Query Engine or from other Inference engine reply the call using Event.replyEvent().

But we need to consider the performance factor while doing so. It is not always a good practice to doing so. But at occasions if there is no other way apart from synchronous call from RTC this POC can be use for that.

**Please feel free to post your queries and comments. Also, If the POC is required for the same, let me know as comment.

No comments:

Post a Comment