Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.9, 2.7.6
-
CXf client frontends cxf-rt-frontend-jaxws, cxf-rt-transports-jms version 2.7.5
-
Novice
Description
When configuring a JaxWsProxyFactoryBean client with a JMSConduit either programmatically, or via spring configuration, the JMSTimeToLive header property is not set.
Java code:
JMSConfiguration jmsConfig = new JMSConfiguration();
JNDIConfiguration jndiConfig = new JNDIConfiguration();
JndiTemplate jndiTemplate = new JndiTemplate();
Properties env = new Properties();
JMSConfigFeature jmsFeature = new JMSConfigFeature();
List <Feature> featureList= new ArrayList <Feature>();
env.put(Context.PROVIDER_URL, JMS_BROKER_URL);
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
jndiTemplate.setEnvironment(env);
jndiConfig.setJndiConnectionFactoryName(CONNECTION_FACTORY_NAME);
jndiConfig.setEnvironment(env);
jmsConfig.setJndiTemplate(jndiTemplate);
jmsConfig.setJndiConfig(jndiConfig);
jmsConfig.setTimeToLive(TIME_TO_LIVE);
jmsConfig.setTargetDestination(JMS_DESTINATION);
jmsConfig.setReplyDestination(JMS_REPLY_DESTINATION);
jmsFeature.setJmsConfig(jmsConfig);
featureList.add(jmsFeature);
proxyFactoryProto.setFeatures(featureList);
proxyFactoryProto.create();
or via spring:
<bean id="proxyFactoryProto" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.myservice.HelloWorld"/>
<property name="transportId" value="#
"></property>
<property name="features">
<list>
<ref bean="jmsConfigFeature"/>
</list>
</property>
</bean>
<bean id="jmsConfigFeature" class="org.apache.cxf.transport.jms.JMSConfigFeature">
<property name="jmsConfig" ref="jmsConfig"/>
</bean>
<bean id="jmsConfig" class="org.apache.cxf.transport.jms.JMSConfiguration">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="timeToLive" value="5000"/>
<property name="targetDestination" value="service.hello"/>
<property name="replyDestination" value="service.hello.reply"/>
</bean>
To fix it simply uncomment the following code at org.apache.cxf.transport.jms.JMSUtils.setJMSMessageHeaderProperties()
//if (messageProperties.isSetTimeToLive())
{ // jmsMessage.setJMSExpiration(expiration); // }and fix with:
if (messageProperties.isSetTimeToLive()) {
jmsMessage.setJMSExpiration(messageProperties.getJMSExpiration());
}