2 Replies Latest reply on Sep 3, 2013 12:53 PM by kcbabo

    Using the setProperty and SY Context

    srini8881

      Hi,

       

      I am trying to set the property in a camel route XML file and then route the request to a SY Bean.  In the bean I am @Injecting a SY Context.  I am fetching the property using context.getProperty().

       

      My question is with regard to the scope of this context.  Is this property in the Context is for every message or is it for the application? 

       

      Meaning,

       

      For an incoming message, when I am setting property with they key as "key1", "value1". 

      If within another thread processing another message, sets the property as "key1", "value2".  Will my first message's value changes as well?  (in other words my question is the Context message dependent and thread safe?)

       

       

      Thanks

      Srini.

        • 1. Re: Using the setProperty and SY Context
          srini8881

          So figured out the trick.

           

          setProperty from the camel route is always at the EXCHANGE scope.  setHeader is at MESSAGE scope. So i reckon using setHeader would make it dependent to the message.

           

          NOTE:  Remember that when using the setHeader, the key of the header changes to small letters.  For example:

          <setHeader headerName="Apple">

          ....

          </setHeader>

          when we try to fetch the header value in the bean service, we should say context.getProperty("apple").  This case change has consumed an hour of my time :-(

           

          Thanks

          Srini

          • 2. Re: Using the setProperty and SY Context
            kcbabo

            NOTE:  Remember that when using the setHeader, the key of the header changes to small letters.  For example:

            <setHeader headerName="Apple">

            ....

            </setHeader>

            when we try to fetch the header value in the bean service, we should say context.getProperty("apple").  This case change has consumed an hour of my time :-(

             

            This is a feature of Camel itself, so there's not much we can do about it from a SY POV.  That said, it's definitely an important thing to point out as it's not obvious and easy to get confused.  I'm flagging this thread with a docs label so that we can include it in our documentation set.

             

            thanks,

            keith