Message Broker has an existing Java API which we made heavy use of for this work. Much of the work involved was to catch method and field accesses in the PHP script and turn them into Java API calls on Message Broker. For example, take a look at the following message tree:
Here's a first attempt at navigating through this message tree to the title:
$xml = $input->getLastChild();
$doc = $xml->getFirstChild();
$ch1 = $doc->getFirstChild();
$ch2 = $ch1->getNextSibling()
$title = $ch2->getFirstChild();
Yuck! This is really horrible, lots of method calls and very little fluency. Ok we can do better, let's try again:
$xml = $input->getChild(‘XMLNSC’);
$doc = $xml->getChild(‘document’);
$ch2 = $doc->getChild(‘chapter’, 1);
$title = $ch2->getAttribute(‘title’);
Well it's a bit better but still far too much like hard work.
$title =
$input->XMLNSC->document->chapter[1][‘title’]
That's better! A really expressive way of navigating through messages. This is only scratching the surface of the PHP integration and the slides cover many other examples such as array integration, message shredding and content based routing.

0 comments:
Post a Comment