title: Spring transaction support in Netty handlers
body: <p>I am using the following versions:</p>
  
  <ul>
  <li>Spring 3.1.1.RELEASE</li>
  <li>Netty 3.4.0.Final</li>
  <li>Hibernate 3.5.6-Final</li>
  </ul>
  
  <p>Now, I have a Netty server that works fairly well - the root of the server, the pipeline factories and the base "stub" of the server that owns everything are all set up with Spring. In this stub, spring <code>@Transactional</code> annotations work just fine.</p>
  
  <p>However, in the handlers, which are stateful and created dynamically depending on what state the user is in - <code>@Transactional</code> doesn't work. I'm fairly sure I understand why. I even have a "solution" - but it's not very good.</p>
  
  <p>After the decoders and encoders, I add an ExecutionHandler:</p>
  
  <pre><code>pipeline.addLast("execution", new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(16,1000000, 1000000)));
  </code></pre>
  
  <p>This appears to be where the Spring transaction support is breaking. Since Spring is unaware of these threads, it can't bind any transactions to them. The classes are proxied correctly, but in debug they have no associated transactions.</p>
  
  <p>My solution is crappy, and it needs to be replaced by a real solution:</p>
  
  <pre><code>Session sess = SessionFactoryUtils.getSession(getSessionFactory(), true);
  </code></pre>
  
  <p>That's bad because it relies on me to release the session, and it may not even be transactional, I haven't checked. It sucks in a lot of ways.</p>
  
  <p>Anyway - the root of the question. Given the above tech, what's my path to getting my <code>@Transactional</code> notations working on the Netty handlers?</p>
  
  <p>Write an <code>ExecutionHandler</code> that's Spring aware?</p>
  
  <p>NOTE: I can't upgrade to Hibernate 4, due to lack of compatibility with Spring-Flex, used in another project in the group. Probably the same story for the Spring version, can't remember.</p>