You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by St...@faa.gov on 2015/05/11 19:42:21 UTC

Implementing a Custom Message Id Cache

Hi -

I have a requirement to prevent duplicate message id's for a period of at least 5 minutes, but not forever. It looks like the DefaultMessageIdCache will cache them forever. So, some time ago, I implemented a custom cache that derives from org.apache.cxf.ws.addressing.MessageIdCache, and uses ehcache under the hood. I thought that that was working ok. But apparently the cached data is not expiring, and as far as I can tell, my custom MessageIdCache is never even being called. This is how I wired it up:

    <jaxws:endpoint id="CXFSTS-BST" implementor="#bstSTSProviderBean"
        address="/STS-BST" wsdlLocation="/WEB-INF/wsdl/FAA-IAM-STS.wsdl"
        xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-trust/200512/"
        serviceName="ns1:BSTSecurityTokenService" endpointName="ns1:STS_Port">
        <jaxws:features>
            <wsa:addressing allowDuplicates="false">
                <property name="messageIdCache" ref="iamMessageIdCache"/>
            </wsa:addressing>
        </jaxws:features>
                ...

I grabbed that property from somewhere, but I can't find it now; is there some other way that I can specify my own message id cache? I'm using CXF 2.7.13.

Thanx,
Stephen W. Chappell

RE: Implementing a Custom Message Id Cache

Posted by St...@faa.gov.
Ok, I solved this one. I'm not even sure why I ever thought it worked the way I had it. This is probably obvious to mostly everyone, but for anyone who is interested, this is what I found: the schema for the wsa:addressing feature lists messageIdCache as being an attribute on the addressing element of type xs:string, and doesn't list any sub-elements. So what I had clearly wouldn't work. Further, if I try to set the messageIdCache attribute to the id of my cache's bean, Spring will choke, because a string is not a MessageIdCache. So I had to ditch the wsa:addressing feature notation and use regular bean notation:

<jaxws:features>
	<bean class="org.apache.cxf.ws.addressing.WSAddressingFeature">
		<property name="allowDuplicates" value="false"/>
                	<property name="messageIdCache" ref="iamMessageIdCache"/>
	</bean>
</jaxws:features>

Once everything was wired up correctly, then everything worked as expected.

Thanx,

Stephen W. Chappell

-----Original Message-----
From: Chappell, Stephen CTR (FAA) 
Sent: Monday, May 11, 2015 1:42 PM
To: users@cxf.apache.org
Subject: Implementing a Custom Message Id Cache

Hi -

I have a requirement to prevent duplicate message id's for a period of at least 5 minutes, but not forever. It looks like the DefaultMessageIdCache will cache them forever. So, some time ago, I implemented a custom cache that derives from org.apache.cxf.ws.addressing.MessageIdCache, and uses ehcache under the hood. I thought that that was working ok. But apparently the cached data is not expiring, and as far as I can tell, my custom MessageIdCache is never even being called. This is how I wired it up:

    <jaxws:endpoint id="CXFSTS-BST" implementor="#bstSTSProviderBean"
        address="/STS-BST" wsdlLocation="/WEB-INF/wsdl/FAA-IAM-STS.wsdl"
        xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-trust/200512/"
        serviceName="ns1:BSTSecurityTokenService" endpointName="ns1:STS_Port">
        <jaxws:features>
            <wsa:addressing allowDuplicates="false">
                <property name="messageIdCache" ref="iamMessageIdCache"/>
            </wsa:addressing>
        </jaxws:features>
                ...

I grabbed that property from somewhere, but I can't find it now; is there some other way that I can specify my own message id cache? I'm using CXF 2.7.13.

Thanx,
Stephen W. Chappell