1 2 Previous Next 25 Replies Latest reply on Jun 6, 2007 12:57 PM by Burr Sutter

    Routing with Rules

    Andre Fernando Salvati Novice


      Hi,

      I'm sending an attribute as a Property inside the Message and I want to get this message inside a fact expressionan action with JBoss Rules. Does any of the guys working with ESB have an exemple where it's possible execute the following line:

      if message.getProperties().getProperty("operation")

      when
      m : Message()
      eval( ( (String) .getProperties().getProperty("command")).equals("insert") )


      Thanks.

        • 1. Re: Routing with Rules
          Andre Fernando Salvati Novice

          Sorry,

          last post was supposed to be a preview... :)

          I'm sending an attribute as a Property inside the Message and I want to get this message inside a fact expression with JBoss Rules. Does any of the guys working with ESB have an exemple where it's possible execute the following line without eval() instruction (just with plain JBoss Rules):

          when
           m : Message()
           eval( ( (String) .getProperties().getProperty("command")).equals("insert") )
          

          Thanks.

          • 2. Re: Routing with Rules
            Mark Little Master

            Try taking this to the JBossRules forum?

            • 3. Re: Routing with Rules
              Burr Sutter Master

              I have been wondering the same thing. We need to add more examples on how to get to different "parts" of the Message inside of the rules used for CBR.
              I Kurt has been enhancing this area as well recently so it will be more obvious how you get to the areas of the Message which are not Body.getContents().

              • 4. Re: Routing with Rules
                Mark Little Master

                 

                "mark.little@jboss.com" wrote:
                Try taking this to the JBossRules forum?


                My bad. Next time I'll read *all* of the entry ;-)

                • 5. Re: Routing with Rules
                  Kurt Stam Master

                  Hi Andre,

                  I recently added code to the JRules integration, to do just this.

                  Take a look at:


                  Note that JbossRules treats objects as shallow objects to achieve highly optimized performance, so what if you want to evaluate an object deeper in the object tree? Either you make serialize your message to XML, and you can use XPATH, or you can sepcify 'object-paths', which extracts objects from the message, using an ESB Message Object Path. The path should follow the syntax:
                  location.objectname.[beanname].[beanname]...
                  location : one of {body, property, attachment}
                  objectname: name of the object name, attachments can be named or numbered, so for attachments this can be a number too.
                  beannames: optionally you traverse a bean graph by specifying bean names; examples :
                  property. Order, gets the property object named "Order"
                  attachment.1, gets the first attachment Object
                  attachment.FirstAttachment, gets the attachment named 'FirstAttachment'
                  attachment.1.Order, calls getOrder() on the attached Object.
                  body.BODY_CONTENT, gets the byte[] of the body.
                  body.Order1.lineitem, obtains the object named "Order1" from the body of the message. Next it will call getLineitem() on this object. More elements can be added to the query to traverse the bean graph.
                  Make sure to import the objects into your rule. The Object Mapper cannot traverse collections, so if you need to do that you have to a (Smooks-) transformation on the message first, to unroll the collection.


                  which is taken from:


                  http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/docs/services/ContentBasedRouting.pdf

                  --Kurt

                  • 6. Re: Routing with Rules
                    Andre Fernando Salvati Novice

                    Hi Kurt/Burr,

                    I'm sure that this will make easier deal with Messages inside Rules.

                    Could you show me a DRL file? We have doubts regarding the correct syntax inside rules.

                    Thanks.

                    • 9. Re: Routing with Rules
                      mike peyvandi Newbie

                      How can I use the same approach, If I want to send messages to the gateway, i.e. to a queue? In this case I don't know anything about esb message, to create the object path !

                      Seems, jboss esb geard towards XML based messaging. getbody().getContents() should simple return an object... to make our life easier.... a esb user feedback!

                      Is there any end to end example including jboss-esb.xml to push an object in the pipeline and re-route it using rules?

                      • 10. Re: Routing with Rules
                        Mark Little Master

                         

                        "system.out" wrote:
                        Seems, jboss esb geard towards XML based messaging.


                        Not true. Read the programmer's guide for a start. There's a large section on Message and how you can use the TWO different implementations within the core or add you own. Only one of the implementations we ship is XML based.

                        getbody().getContents() should simple return an object... to make our life easier.... a esb user feedback!


                        getContents is deprecated in favour of getByteArray. Even before then, if you wanted to get an object back then why not use the Object-specific methods on the Message? Again, read the programmers guide for more information.

                        • 11. Re: Routing with Rules
                          mike peyvandi Newbie

                           

                          "mark.little@jboss.com wrote:
                          getContents is deprecated in favour of getByteArray. Even before then, if you wanted to get an object back then why not use the Object-specific methods on the Message? Again, read the programmers guide for more information.


                          How can I use the object-specifc methods on the message if I am sending a message through esb-unaware client, i.e. through gateways?

                          Also, would be nice to have an example in quickstart passing an object instead of xml string and routing it using jbossrules.

                          • 12. Re: Routing with Rules
                            Mark Little Master

                             

                            "system.out" wrote:
                            "mark.little@jboss.com wrote:
                            getContents is deprecated in favour of getByteArray. Even before then, if you wanted to get an object back then why not use the Object-specific methods on the Message? Again, read the programmers guide for more information.


                            How can I use the object-specifc methods on the message if I am sending a message through esb-unaware client, i.e. through gateways?


                            I think you lost me there. How are you using the getContents/getByteArray in that case?


                            Also, would be nice to have an example in quickstart passing an object instead of xml string and routing it using jbossrules.


                            We're always looking for contributors.

                            • 13. Re: Routing with Rules
                              mike peyvandi Newbie

                              I am trying to build something similar to fun-cbr but using objects in messaeg that needs to be evaluated by jboss rules.
                              Correct me if I am wrong: I assume when you use gateways as a bridge between esb-unaware user and esb-engine, gateway creates byteArray out of object and put it in the message body. Is that correct?

                              If yes, then how can I put my object in esb message differently, as you suggested?

                              We're always looking for contributors.

                              I would be more than happy to contribute, when I have the solution :)

                              • 14. Re: Routing with Rules
                                Burr Sutter Master

                                You would use a custom action to first "hang" your custom objects in places that you can remember to later be available in your rules.

                                I do wish I had an example for you but we've just not had the time to build up a quickstart that illustrates this capability. Plus you really needed the changes that Kurt made post MR2 to make it work.

                                We'll get an example of this soon enough or you might just beat us to it. :-)

                                Burr

                                1 2 Previous Next