Hi,

I've got a web service that is used to populate an Ajax-type interface.
However, the call is very slow, due to a variety of reasons, but that data
is generally pretty stagnant. So, I had this in mind: Use the Timer componet
to periodically call the service to service and store the resulting XML in
the Cache Component. Unfortunately, I haven't had any luck getting the Cache
component to work, even after somewhat carefully following the examples. For
instance, I have a lwContainer that includes the following servicemix.xml
definition:

<sm:activationSpec componentName="timer" service="my:timer"
destinationService="my:myService">
        <sm:component>
l               <bean 
class="org.apache.servicemix.components.quartz.QuartzComponent">
                        <property name="triggers">
                                <map>
                                        <entry>
                                                <key>
                                                        <bean 
class="org.quartz.SimpleTrigger">
                                                                <property 
name="repeatInterval" value="50000"/>
                                                                <property 
name="repeatCount" value="-1"/>
                                                        </bean>
                                                </key>
                                                <bean 
class="org.quartz.JobDetail">
                                                        <property name="name" 
value="job"/>
                                                        <property name="group" 
value="ServiceMix"/>
                                                </bean>
                                        </entry>
                                </map>
                        </property>
                </bean>
        </sm:component>
</sm:activationSpec>

<sm:activationSpec componentName="myService" service="my:myService"
destinationService="my:myServiceImpl">
        <sm:component>
                <bean xmlns=""
class="org.apache.servicemix.components.cache.CacheComponent">
                        <property name="cache">
                                <bean 
class="org.apache.servicemix.components.cache.LRUCache">
                                        <constructor-arg value="100"/>
                                </bean>
                        </property>
                        <!-- lets define the cache key expression -->
                        <property name="keyExpression">
                                <bean
class="org.apache.servicemix.expression.JaxenStringXPathExpression">
                                        <constructor-arg value="//name"/>
                                </bean>
                        </property>
                </bean>
        </sm:component>
</sm:activationSpec>

(my:myServiceImpl just is a groovy script taken verbatim from the CacheTest
class). 

Now, my understanding is that the incoming XML into the CacheComponent will
be stored using a key defined by the XPATH expression //name (which would be
job, as it arrives from the Timer).

Within my JSR 181 component, I am then doing the following (only showing the
relavent parts);

        public void setContext(javax.jbi.component.ComponentContext context) {
                System.out.println("===================Context getting 
populated...");
                this.context = context;
        }

        private void myMethod() {
                ServiceMixClient client = new 
ServiceMixClientFacade(this.context);
                QName service = new QName("http://servicemix.apache.org/demo/";,
"myService");
                EndpointResolver cachedService  =
client.createResolverForService(service);

                Object object = null;
                try {
                        // the XML shown in the request is taken verbatim
from the Timer output
                        object = client.request(cachedService, null, null,
"<timer><name>job</name><group>ServiceMix</group><fullname>ServiceMix.job</fullname><description/><fireTime>Wed
Oct 18 15:46:53 PDT 2006</fireTime></timer>");

                } catch (JBIException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                if (object instanceof Node) {
                        object = new DOMSource((Node) object);
                }

                System.out.println("****************** Cache: Received 
response: " +
object);
        }

No matter what I do, the object response always comes back as null (it shows
that it's of type #document). I have log4j debugging turned on, and I see
the CacheComponent getting the message, so that part is working (and prior
to that, I see the Timer sending it data).

I suspect I'm not getting how the CacheComponent should be used? Are my
problems related to me calling  client.request  from within a JSR component?

Thanks so much for your help!!

jeff

p.s, Servicemix Rocks!! btw!
-- 
View this message in context: 
http://www.nabble.com/Cache-Component-Problems-tf2470240.html#a6887510
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to