views:

22

answers:

1

The following code snippet attempts to create a Tib DaemonManager connecting to a particular rvd, and then query for that rvd's services.

public static void main(String[] args) throws RuntimeException {
    DaemonManager daemonManager = new DaemonManager("http://foo.com:7580");
    if(daemonManager.getDaemonType() == DaemonManager.RVD) {
        DaemonProxy daemonProxy = daemonManager.getDaemonProxy();
        final RvdProxy rvdProxy = (RvdProxy) daemonProxy;
        Service[] services = rvdProxy.getServices();
        System.out.println(services.length); //prints 0
        for (Service service : services) {
            System.out.println(service.getNetwork());
        }
    }
}

This prints zero, even though the web interface for this rvd lists multiple available services. Why might this happen?

The daemon I am connecting to is running v 7.5.1 of the software, and the rvconfig.jar that I am using is from v 7.5.1 as well.

Is there a gotcha when using Tibco's DaemonManager that is causing me to come unstuck?

+3  A: 

I used Wireshark to look at the traffic being sent between my RvdProxy and the RVD itself, and it looks like a lot of HTTP GET traffic. For example:

0000  00 1e 0b a4 d1 7c 00 12  d9 7c 8a bf 08 00 45 00   .....|.. .|....E.
0010  03 87 a4 58 40 00 3d 06  66 90 0a 09 14 15 0a 0a   ...X@.=. f.......
0020  07 61 1d 9c bf 09 fe 1e  d6 82 6e 77 b9 52 80 18   .a...... ..nw.R..
0030  00 1b 05 43 00 00 01 01  08 0a ac 1c 6f 67 07 b2   ...C.... ....og..
0040  86 1f 72 3d 23 30 30 38  30 38 30 3e 3c 66 6f 6e   ..r=#008 080><fon
0050  74 20 66 61 63 65 3d 48  65 6c 76 65 74 69 63 61   t face=H elvetica
0060  2c 41 72 69 61 6c 20 73  69 7a 65 3d 32 20 63 6f   ,Arial s ize=2 co
0070  6c 6f 72 3d 23 46 46 46  46 46 46 3e 3c 62 3e 43   lor=#FFF FFF><b>C

Sure enough, upon further inspection, it turns out that the requests being made by the proxy are to the web pages served by the Daemon itself - so the proxy API is just a screen-scraper.

But why am I getting no services if they appear on the web pages that are being screen-scraped?

Switch on debugging:

System.setProperty("com.tibco.tibrv.config.debug","classes-to-debug")

And you find that the pattern being used to extract the services from the web-page...

/services,GET~~~~~\
service_detail\\?(\\d+)>\\1</a>.*?size=2>(\\d+\\.\\d+\\.\\d+\\.\\d+)</td>.*?size=2>
(\\d+)</td>.*?size=2>(\\d+)</td>~~~~~\

...fails to match anything! In my case it is because my service networks are not of the form (\\d+\\.\\d+\\.\\d+\\.\\d+) but rather of the form ;(\\d+\\.\\d+\\.\\d+\\.\\d+) - note the leading semicolon. This subtle difference is the source of all of my problems!

This looks like a bug in the rvconfig jar - which needs to be raised with Tibco! :(

butterchicken
This is one sweet answer.
Adamski