Spring transaction support in Netty handlers

I use the following versions:

  • Spring 3.1.1.RELEASE
  • Netty 3.4.0.Final
  • Hibernate 3.5.6-final

Now I have a Netty server that works quite well - the root of the server, the pipeline factory, and the base "stub" of the server that owns everything are configured using Spring. In this stub, spring annotations @Transactionalwork fine.

However, in handlers that are stored in the state and are created dynamically, depending on the state the user is in, it @Transactionaldoes not work. I am sure I understand why. I even have a “solution”, but that’s not very good.

After decoders and encoders, I add an ExecutionHandler:

pipeline.addLast("execution", new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(16,1000000, 1000000)));

This seems to break spring transaction support. Since spring does not know about these threads, it cannot bind any transactions to them. Classes are proxied correctly, but when debugging, they have no related transactions.

My solution is crappy and needs to be replaced with a real solution:

Session sess = SessionFactoryUtils.getSession(getSessionFactory(), true);

This is bad because it relies on me to free the session, and it may not even be transactional, I did not check. This sucks in many ways.

In any case, the root of the question. Given the above technique, what's my way of getting my notes @Transactionalworking on Netty handlers?

Write ExecutionHandlerthat spring knows?

. Hibernate 4 - Spring -Flex, . , spring .

+3
1

netty spring , , , , spring beans.

0

All Articles