Issue 1:
David Parks opened SPR-8367 and commented

Reference JIRA: https://jira.springsource.org/browse/SPR-6180?focusedCommentId=66682#comment-66682

Any use cases which require an HttpContext attribute to be set aren't covered in this implementation, and the extensions required make the whole thing so messy as to make using the Rest Template more of a burden than a benefit. Here is the particular case that I've been fussing with today to little avail, setting preemptive authentication (i.e. send basic authentication headers by default rather than performing 2 requests to authenticate):

http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html#d4e1023

The problem being that the RestTemplate implementation as it is has no support for setting HttpContext parameters (the template calls the Http.execute(HttpUriRequest) which uses only the non-accessible default HttpContext), there aren't any good ways to set the default context parameters on the HttpClient in 4.x Apache HTTP Components. You end up needing to extend HttpClient to provide for default HttpContext params on the HttpClient object and the whole thing just becomes a spaghetti mess from there making the template more pain than pleasure.

Affects: 3.1 M2

Referenced from: commits f9144ea

3 votes, 7 watchers

Issue 2:
gobreak opened SPR-2091 and commented

I have tried using JBossMQ and ActiveMQ to receive async message by DefaultMessageListenerContainer.

Transaction Manager from JBoss are used and set properly as a bean property for DefaultMessageListenerContainer.

To trigger the XA rollback, I throw a runtime exception in the onMessage() callback of the MessageListener.

However, the message is still commit.

The bean setting:

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">

<property name="userTransaction" ref="userTransaction"/>

</bean>

<bean id="userTransaction"

class="org.springframework.jndi.JndiObjectFactoryBean">

<property name="jndiName">

<value>java:comp/UserTransaction</value>

</property>

</bean>

<bean id="listenerContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="XAJmsConnectionFactory" />
<property name="destination" ref="XADestination" />
<property name="messageListener" ref="coreInboundBeanImpl" />
<property name="transactionManager" ref="transactionManager"/>
</bean>

Finally, I needed to extend DefaultMessageListenerContainer and override the receive() method using JMSTemplate instead of the message consumer as follow:

public Message receive(long timeOut) throws JMSException{

template.setConnectionFactory(getConnectionFactory());

template.setDefaultDestination(getDestination());

template.setReceiveTimeout(timeOut);

if (getMessageSelector() == null || "".equals(getMessageSelector().trim()))

return template.receive(getDestination());

else

return template.receiveSelected(getDestination(), getMessageSelector());

}

I use JMSTemplate because I find it performs XA without any noticed problem.

Using the above implementation can successfully rollback as well as commit the message. I am seeking for better solution on this topic.

Affects: 2.0 M4

Issue Links:

#6872 Cannot do XA Rollback Using DefaultMessageListenerContainer in Spring 2.0 RC1 ("is duplicated by")

#6873 Cannot do XA Rollback Using DefaultMessageListenerContainer in Spring 2.0 RC1 ("is duplicated by")