[Design of JBoss ESB] - Re: Design of a Content Based Routing Service
by ddunkin
I think this could be accomplished through DSL and helper classes. Here's some untested code to show the direction:
Here's what the new rules might look like:
| #created on: Oct 30, 2006
| package com.jboss.soa.esb.routing.cbr
|
| #list any import classes here.
| import org.jboss.soa.esb.message.Message;
| import org.jboss.soa.esb.message.format.MessageType;
|
| #declare any global variables here
| global java.util.List destinationServices;
|
| expander JBossESB.dsl
|
| rule "Routing Rule - XML based message"
|
| when
| xmlContentMatches "/PurchaseOrder"
| then
| System.out.println("JBoss_XML");
| destinationServices.add("test_category:JBOSS_XMLDestination");
| end
|
The DSL:
| #JBossESB Content Based Routing DSL
| [when]xmlContentMatches "{xpath}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( org.jboss.soa.esb.services.routing.cbr.DslHelper.xmlContentMatches(msg, "{xpath}") )
| [when]xmlContentEquals "{xpath}", "{value}"=msg : Message( type == MessageType.JBOSS_XML ) and eval( org.jboss.soa.esb.services.routing.cbr.DslHelper.xmlContentEquals(msg, "{xpath}", "{value}") )
|
Helper class that does the actual XPath matching:
| package org.jboss.soa.esb.services.routing.cbr;
|
| import java.io.ByteArrayInputStream;
|
| import javax.xml.xpath.XPath;
| import javax.xml.xpath.XPathConstants;
| import javax.xml.xpath.XPathExpressionException;
| import javax.xml.xpath.XPathFactory;
|
| import org.jboss.soa.esb.message.Message;
| import org.xml.sax.InputSource;
|
| public class DslHelper {
| private static XPathFactory xpf = XPathFactory.newInstance();
|
| public static boolean xmlContentMatches(Message msg, String xpathExp) throws XPathExpressionException {
| XPath xpath = xpf.newXPath();
| InputSource inputSource = new InputSource(new ByteArrayInputStream(msg.getBody().getContents()));
| Object node = xpath.evaluate(xpathExp, inputSource, XPathConstants.NODE);
| return node != null;
| }
|
| public static boolean xmlContentEquals(Message msg, String xpathExp, String value) throws XPathExpressionException {
| XPath xpath = xpf.newXPath();
| InputSource inputSource = new InputSource(new ByteArrayInputStream(msg.getBody().getContents()));
| String node = (String) xpath.evaluate(xpathExp, inputSource, XPathConstants.STRING);
| return value.equals(node);
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3982752#3982752
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3982752
19 years, 5 months
[Design of JBoss jBPM] - Re: execution transitions, data flow and other associations
by brittm
Tom, its my understanding that a Link in BPEL is simply a mechanism that sends a message and waits for a response. In other words, a wait state with a messaging structure defined. Of course, that can be used for synchronization purposes.
What we need for sync without merge is something much more defined. Something that allows processes to 'subscribe' a node to a 'sync group' based on some common variable (like an order number), and then react to various conditions of that group as each participating node is executed.
Configuration could allow participating nodes to react in different ways to various conditions within the sync group, such as:
* If I'm the first to arrive, take my transition a.
* If I'm not the first, take my transition b.
* If I'm the last to arrive, take my transition c.
* Or when the last participant has arrived, take my transition d.
Done properly, this would allow for dynamic processes in which the definition doesn't need to know ahead of time how many instances (or what type of instances) will be participating in a sync group. This kind of dynamic behavior is huge.
Probably within the next week or two I'll have something like this implemented orthagonally to jBPM, but of course, like Shared Subprocess, I'd love to see these concepts integrated into the project.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3982730#3982730
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3982730
19 years, 5 months