4 Replies Latest reply on Dec 18, 2007 5:55 AM by marklittle

    ContentBasedRouter does not work!

    viniciuscarvalho

      JBoss ESB version: 4.2.1.GA
      Hello there! I was trying to get the CBR to work, and after many failures I decided to look at the code... :(

      Well, It's no surprise my rules do not find any destination. It depends on a property named object-path. Here's the stack call for the CBR :

      
       public Message process(Message message) throws ActionProcessingException
       {
       try {
       List<Service> outgoingDestinations = executeRules(message);
      
      

      Ok, so it tries to get the outgoingDestinations at this point. No problem so far...
       protected List<Service> executeRules(Message message)
       throws MessageRouterException
       {
       List<Service> outgoingDestinations = new ArrayList<Service>();
       try {
       List<Object> objectList = _mapper.createObjectList(message,
       _messagePathList);
      

      Now the above code is the source of the problems, as the property _messagePathList, is initialized with an empty arrayList (dunno why does CBR needs that, isnt that something for the BusinessRuleService???)

      So the next piece of code shows that with an empty _messageList, I get an empty destinations, so, nothing can be found.


       public List<Object> createObjectList (Message message,List<String> messageObjectPathList)
       throws ObjectMappingException
       {
       List<Object> objectList = new ArrayList<Object>();
       if (messageObjectPathList!=null) {
       for (String messageObjectPath: messageObjectPathList)
       {
       Object value = getObjectFromMessage(message, messageObjectPath);
       if (value==null) {
       logger.warn("The value of " + messageObjectPath + " is null");
       } else {
       if (value instanceof Collection) {
       Collection valuesList = (Collection) value;
       for (Object object : valuesList) {
       objectList.add(object);
       }
       } else if (value instanceof Map) {
       Map valuesMap = (Map) value;
       for (Object object : valuesMap.entrySet()) {
       objectList.add(object);
       }
       } else {
       objectList.add(value);
       }
       }
       }
       }
       return objectList;
       }
      


      I was kinda confused where to post (here or developer forum). Just would like to know if I need to add the objec-path, and if so, the docs should be modified. CBR is a crucial piece of software in our project :)

      Regards

        • 1. Re: ContentBasedRouter does not work!
          kurtstam

          Can you check out i.e. the quickstarts fun_cbr or simple_cbr? The destinations are mapped with

          <property name="destinations">
           <route-to destination-name="blue" service-category="BlueTeam" service-name="GoBlue" />
           <route-to destination-name="red" service-category="RedTeam" service-name="GoRed" />
           <route-to destination-name="green" service-category="GreenTeam" service-name="GoGreen" />
           </property>
          


          Object-paths are used to transfer objects from the message to the rules
          engine.

          Hope this helps,

          --Kurt

          • 2. Re: ContentBasedRouter does not work!
            viniciuscarvalho

            Yes Kurt you are right! It was my mistake sorry. What I'm doing is creating a webservice that will put inside the JBossMessage the contents of its message payload (not the soap envelope, Im using @WebServiceProvider with Payload type). Inside the DSLHelper it looks for the payload of the body, and that is only an empty envelope. I just need to figure how to set the payload not he body.
            Im using message.getBody().add(byteArrayFromInputSource);

            Regards

            • 3. Re: ContentBasedRouter does not work!
              kurtstam

              If this is a new issue please create a new topic.

              • 4. Re: ContentBasedRouter does not work!
                marklittle

                If you think the documentation is unclear on any of this, please create a JIRA.