This documentation relates to FusionReactor 4.0.x - If you use another version please check here: All Versions
Download the complete documentation in PDF

Skip to end of metadata
Go to start of metadata

The FRAPI lets you call FusionReactor methods directly from your ColdFusion pages.  JavaDocs are available for the FRAPI and are available from the FusionReactor site. Click here to view the FRAPI JavaDocs.

Lets first start with some simple examples though...

This is one of the simplest FRAPI calls:

This page simply outputs a YES/NO value depending on the running state of FusionReactor.

Using FRAPI to look at running requests

Now for something a little more interesting:

This bit of code will print out a list of all requests currently running. (We've added a wait at the bottom so we can run it several times and get a result something like this:

The FusionRequestSurrogate

Calling frapi.getRunningRequests()returns an array of FusionRequestSurrogates. These objects contain proxied information from an internal FusionRequest (web request). It is safe to store references to this object, since the data it encapsulates is copied from the underlying FusionRequest. There is a lot of data that you can get about a request:

Setting a request's crash protection timeout

The following code will change the timeout setting for Crash Protection for this request:

We also have the ability to set markers in pages. Look at this example:

After this page has run, if we go into FusionReactor and look at the request details for this request we fill see this marker listed along with the time at which it was set:

The ability to set markers within your pages has many useful purposes including following the path of execution, measuring execution time or simply outputting debug information without changing the final output or needing to read through log files.

Example of changing the FusionReactor Configuration via FRAPI

It's possible using FRAPI to change pretty much anything in FusionReactor's configuration. In the example below we toggle an Enterprise Dashboard monitored remote server online/offline programmatically.

In the reactor.conf file the keys "remoting.server.X.*" control the ED monitored servers. The key of interest is "remoting.server.X.online" – you'll have to figure out what "X" is in your case; it's just a serial number. Once you have that, you can use FRAPI to toggle the online state. Here's some CF to do it: *NB you must not have reactor.conf still open in your editor, otherwise the FRAPI code won't be able to change it and you'll get an error, that'll require a restart to clear

If you're in CF and monitoring from within a CFM instance, the following CF code will toggle remoting server 0's state (online/offline)

If you want to change FRAM's configuration you will need to look at FRAM's reactor.conf ( /FusionReactor/instance/FRAM/conf/reactor.conf) to get the remoting server number. Then place the following JSP in /FusionReactor/tomcat/webapps/ROOT, and run it as http://localhost:8087/enterprise-toggle.jsp

Summary

As we hope you can see, the FRAPI is a very powerful new tool which has a lot of potential. As ever, if you have any feedback or suggestions for this or any other feature within FusionReactor, please let us know and we will try our best to include them in upcoming builds.

Labels: