Monday 20 April 2015

TIBCO Business Events: Execute External command

There are few occasions where Business Events need to execute operating system's commands. Just like TIBCO Business Works external command, TIBCO Business Events can also execute "External commands". But there are some limitations. Unlike TIBCO BW, TIBCO BE cannot invoke external command synchronously, so that the RTC should not hang or involve in long time execution.

To execute an external command, use
void System.exec(String command).

Depending on the Operating System the command text must be passed. for example

Windows
=======
System.exec("cmd /c START D:/STUDYMETERIAL/hello.bat");

Where "cmd /c" represent this is being executed in Windows.
START represents, the command is going to execute as a different process.
D:/STUDYMETERIAL/hello.bat is the batch file, containing the sequence of batch commands that need to execute.


Unix
=====
System.exec("sh D:/STUDYMETERIAL/hello.sh &");
Where "sh" represent this is being executed in UNIX as shell script.
"&" represents, the command is going to execute as a different process.
D:/STUDYMETERIAL/hello.sh is the Shell file, containing the sequence of shell commands that need to execute.

Friday 17 April 2015

TIBCO Business event & JConsole: Lets move into Business Event Engine

Most of the time while working with TIBCO Business event, developers revolve around the business logics and Business Events entities. It often happen, developers logical expectation from code don't match with actual execution. In those cases, to debug the issue developers often put "System.debugOut" where ever needed to check what when wrong, and eventually find it. 

Lets consider a scenario. We are storing some data in a concept and at certain point we need to know what data is stored or Is the rule triggered or Did the event come in or Is my destination active and many more. In general, we will go ahead, stop the engine, put some print statement, redeploy the code and check what went wrong. But, what if the code is in production environment,where redeployment is not an option? 

JConsole is the answer to this situation. we can do a lot of operations using JConsole. Few of the operations are list below.


  • View a Concept Instance in the Memory.
  1. Open JConsole.
  2. Connect to the PID which is corresponding to the inference Engine (for me it is ALERT-MANAGEMENT) not Cache engine.
  3. To check if the PID is corresponding to inference Agent,  Go to MBeans --> com.tibco.be-->Agent-->1(any number)-->Methods-->Working Memory--> Operations --> GetRuleSession.
  4. Go to MBeans --> com.tibco.be-->Agent-->1(any number)-->Methods-->Object management--> Operations -> GetInstance.
  5. Pass the concept ID (not ExtID) as parameter p1. keep p2 empty. click on GetInstance.
  6. Check all the parameter values of the respective instance, by changing the "Tabular navigation.


  • Get the list of Rules in the deployed Inference Engine
  1. Open JConsole and connect the PID  corresponding to required Inference engine
  2. Go to MBeans --> com.tibco.be-->Agent-->1(any number)-->Methods-->Working Memory--> Operations --> GetRules
  3. It will show the list of all the rules in the Inference engine. Navigate through the "Tabular navigation" to go through the list of rules. It can also be found here if the rule is Active or not
  4. To get the spesific rule details. go to MBeans --> com.tibco.be-->Agent-->1(any number)-->Methods-->Working Memory--> Operations --> GetRule. Pass p1 as <Rule_URI>  
            e.g /MyRule/Rule/AdvisoryRule.   
  • Activate And Deactivate Rule
  1. Open JConsole and connect the PID  corresponding to required Inference engineGo to MBeans --> com.tibco.be-->Agent-->1(any number)-->Methods-->Working Memory--> Operations --> DeactivateRule
  2. Pass p1 as <Rule_URI>
    e.g /MyRule/Rule/SomeRule

    Once the rule is deactivated. It would not be triggered although the declaration and condition satisfy.
  3. Once the rule is deactivated, it can be activate again using
    MBeans --> com.tibco.be-->Agent-->1(any number)-->Methods-->Working Memory--> Operations --> ActivateRule 
  4. pass P1 = <Rule_URI>

  • Starting and Stoping profiler
  1. Open JConsole and connect the PID  corresponding to required Inference engine
  2. Go to MBeans --> com.tibco.be-->Agent-->1(any number)-->Methods-->Profiler--> Operations --> StartFileBasedProfiler
  3. Pass p1 as location of the csv file where it save the details of the execution                                  e.g c:/temp/BeProfile.csv
  4. p2 as <level>  -1 to any positive value . By default -1
    p2 as <duration>  -1 to any positive value. By default -1
  5. to stop the profiler MBeans --> com.tibco.be-->Agent-->1(any number)-->Methods-->Profiler--> Operations --> StopFileBasedProfiler
    ** two profiler cannot be started at the same time.
    ** data in the csv file can only visible after stopping the profiler

Tuesday 14 April 2015

TIBCO Business Events: Can a single Cache Server supports multiple Inference Engines?

"Yes" would not be the correct answer to this question neither "No" is the wrong answer. Partially this is true and partially it is not. Actually it is possible when all the engines including inference engine, query engine and the cache engine share the same ear file. This restriction is to ensure that, signature of all the entities must be known to cache engine. Although the separation of the entities can be done at CDD (Cluster deployment Descriptor) level. One may creates different collections of rules, rule functions, destinations and assign this collections to different Inference and Query engines except Cache engine as shown below.


So, in simple words single Cache engine can serve for single project containing multiple other engines. But a single Cache engine cannot work for multiple project or EARs.

Monday 30 March 2015

Business Events: JDBC Connection fails from BE Studio/Runtime

Is the JDBC connection fails while trying to test the from Business events Studio? Even many times while running the BE code in local machine, errors are generated, reflecting failure of the JDBC connection. This is a very common issue. It is observed during the first run, just after the installation of Business Events.

This is due to the fact, Business Events do not comes with preconfigured TRAs for JDBC connection. So, it needs to be configured explicitly.

Follow the below steps to configure JDBC connection.

1. If you are getting this error at design time (while checking the connection from eclipse)
   -- edit studio.tra {location <BE_HOME>\studio\eclipse\configuration}
           edit the property (add the following at the end of the line)
               studio.extended.classpath= C:/tibco/be/5.1/studio/eclipse/thirdparty    {Assuming the JDBC jars are at loacation C:/tibco/be/5.1/studio/eclipse/thirdparty} 

2. If you are getting this error at run time
--edit be-engine.tra
       add property
           tibco.env.JDBC_HOME=C:/tibco/be/5.1/studio/eclipse/thirdparty {Assuming the JDBC jars are at loacation C:/tibco/be/5.1/studio/eclipse/thirdparty}

        and edit property
            tibco.class.path.extended %CUSTOM_EXT_PREPEND_CP%%PSP%%STD_EXT_CP%%PSP%%CUSTOM_EXT_APPEND_CP%%PSP%%JDBC_HOME%


3. If you are the still getting this error, check your Oracle listener is running. Try to connect it from any other application like SQLDeveloper or TIBCO BW etc.

BusinessEvents: Rulefunction is not available for preprocessor in CDD

It happen many times, that you have created a rulefunction and that is not available in preprocessor selection list in CDD.

Well preprocessors are a specific type of rulefunction, if the criteria are not matched properly while defining the rulefunction, then the rulefunction would not be available as a preprocessor.

The crucial factor is the scope. It should contain only one entity in the scope, no less no more. Also, that entity must me an event (concepts are not allowed.)

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.