Announcement Announcement Module
No announcement yet.
DefaultMessageListenerContainer & transactionManager closing Issues Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • DefaultMessageListenerContainer & transactionManager closing Issues

    I am trying to setup a transactionManager on my MessageListener so I can use Hibernate transactions from the listener. It is working somewhat but I am seeing a lot of errors in the debug log btw. I am using JBossMQ -

    2007-04-14 11:38:46,390 DEBUG [] Failed to handle:[msgType: m_connectionClosing, msgID: -2147483303, error: null] Client is not connected
    2007-04-14 11:38:46,390 DEBUG [] Failed to send error reply Client is not connected
    This issue only happens if I use a transactionManager - I have tried both JmsTransactionManager and HibernateTransactionManager - both result in the above errors being thrown constantly (and high cpu usage) as the DMLC threads are created and destroyed.

    It seems as if for every thread a transaction is given to the thread and on release this error is thrown.

    As a side note - I was thinking maybe its better if I start and close the transaction inside my MessageListener so the transaction is actually taken out of the pool until I recieve a message. It seems that the DMLC model (constant polling) requires alot of cpu usage when a transactionManager is specified.

    Anybody got any ideas?
    Last edited by alvins; Apr 13th, 2007, 08:54 PM.

  • #2

    for me it is unclear what you men by transactions ?

    There are at least two options to run you Spring MDP Container with Transaction, the first one is running you MessageListener Container with a local jms transaction. Then you're hibernate transaction is a own one, so there is no coordination between them.

    If you want to run both messageListenerContainer and the Hibernate Transaction inside one transaction, then you will need an JTA TransactionManager that coordinates both transaction.

    For me running defaultmessagelistenercontainer with /without all kinds of transactions doesn't result in high cpu usage.

    The only case where i have 100% cpu usage is, when i use defualtmessagelistener container with transaction, and the transaction is rolled back every time.



    • #3
      Thanks for the quick reply.

      I am trying to user database transactions (hibernate). But I just realised that my business/service layer is wrapped up in spring transaction proxies so they already handle the database transaction side of things.

      So I guess I need jms transactions. When I enable jmsTransaction I get the errors I talked about in my first post - unsure why.

      I have included the spring config below and excerpt of the log if it helps.

       <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
              <property name="environment">
                      <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
                      <prop key="java.naming.provider.url">localhost</prop>
                      <prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop>
          <!-- JMS Queue Connection Factory -->
          <bean id="internalJmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiTemplate" ref="jndiTemplate" />
              <property name="jndiName" value="UIL2ConnectionFactory" />
          <!-- JMS Destination -->
          <bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiTemplate" ref="jndiTemplate" />
              <property name="jndiName" value="queue/PostrRequestSendQueue" />
          <!-- JMS Queue Template -->
          <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate102">
              <property name="connectionFactory" ref="internalJmsQueueConnectionFactory" />
              <property name="defaultDestination" ref="destination" />
              <property name="receiveTimeout" value="30000" />
              <property name="deliveryPersistent" value="false" />
      <!-- this is the Message Driven POJO (MDP) -->
      	<bean id="messageListener" class="com.postr.openfire.jms.PostrOpenfireQueueListener" />
      	<!-- Transaction jms management -->
      	<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
      	  <property name="connectionFactory" ref="internalJmsQueueConnectionFactory" />
      	<!-- and this is the message listener container -->
      	<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer102">
      	  <property name="concurrentConsumers" value="5"/>
      	  <property name="connectionFactory" ref="internalJmsQueueConnectionFactory" />
      	  <property name="destination" ref="destination" />
      	  <property name="messageListener" ref="messageListener" />
      	  <property name="transactionManager" ref="jmsTransactionManager" />
      	  <property name="sessionTransacted" value="true" />
      2007-04-16 18:55:00,586 DEBUG [] Failed to handle:[msgType: m_connectionClosing, msgID: -2147356076, error: null] Client is not connected
              at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$
      2007-04-16 18:55:00,586 DEBUG [] Failed to send error reply Client is not connected
              at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$
      2007-04-16 18:55:00,587 DEBUG [] End
      2007-04-16 18:55:00,588 DEBUG [] End
      2007-04-16 18:55:00,589 DEBUG [] Stopping
      2007-04-16 18:55:00,590 DEBUG [] End


      • #4
        I've found a reference to this problem in the JBoss forum but doesn't look like there is a fix (JBoss 4.0.5.GA) -

        Someone else must have come across this issue?
        Last edited by alvins; Apr 16th, 2007, 08:13 AM.


        • #5
          I can't comment on the specific JBoss error, but JmsTransactionManager is not well suited to the task you are giving it - it does a lot of the stuff that the MessageListenerContainer itself already does. If you don't want / don't have an XA database connection and message connection, you might be closer to where you want to be if you used the same transaction manager as you use in your service tier. In that case you would have a "poor man's" global transaction. The only case where global transaction semantics break down in this configuration is where the database commits but the message service fails - then you get a duplicate message. This is quite unlikely to happen for the most part, so people generally accept the issue, and deal with it defensively at some level in the service layer. Often it is worth the extra cost of the defense because a real global transaction can be very expensive.


          • #6
            Problem with DefaultMessageListener and JtaTransactionManager


            I am trying to run a sample Jms application with embedded
            ActiveMQ broker in Spring on JBoss AS 4.0.5

            I have set transaction manager as JtaTransactionManager.
            I have defined AOP pointcut on my service class which calls
            dao methods.Message sender class calls the
            service class.

            I deployed the application as a war file and message sending
            triggered by invoking servlet.
            JBoss starts up with no error. However at runtime when I try
            to run the sender, I get the following error :

            [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/JavaMessagingFramework].[jsp]] Servlet.service() for servlet jsp threw exception
            java.lang.IllegalArgumentException: object is not an instance of declaring class
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Native
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(De
            at java.lang.reflect.Method.invoke(
            at npointUsingReflection(
            at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(
            at $Proxy52.getStatus(Unknown Source)
            at org.springframework.transaction.jta.UserTransactio nAdapter.getStatus(
            at org.springframework.transaction.jta.JtaTransaction Manager.isExistingTransaction(JtaTransactionManage
            at atformTransactionManager.getTransaction(AbstractPl
            at org.springframework.transaction.interceptor.Transa ctionAspectSupport.createTransactionIfNecessary(Tr
            at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:101)
            at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :171)
            at org.springframework.aop.interceptor.ExposeInvocati onInterceptor.invoke(ExposeInvocationInterceptor.j ava:89)
            at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :171)
            at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(
            at $Proxy53.getContract(Unknown Source)
            at com.test.jms.MessageSender.sendMessage(MessageSend
            at org.apache.jsp.send_jsp._jspService( 58)
            at org.apache.jasper.runtime.HttpJspBase.service(Http
            at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
            at org.apache.jasper.servlet.JspServletWrapper.servic e(
            at org.apache.jasper.servlet.JspServlet.serviceJspFil e(
            at org.apache.jasper.servlet.JspServlet.service(JspSe
            at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
            at ternalDoFilter(
            at Filter(
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(
            at ternalDoFilter(
            at Filter(
            at org.apache.catalina.core.StandardWrapperValve.invo ke(
            at org.apache.catalina.core.StandardContextValve.invo ke(
            at alve.invoke(
            at oke(
            at org.apache.catalina.core.StandardHostValve.invoke(
            at org.apache.catalina.valves.ErrorReportValve.invoke (
            at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve .invoke(
            at org.apache.catalina.core.StandardEngineValve.invok e(
            at org.apache.catalina.connector.CoyoteAdapter.servic e(
            at org.apache.coyote.http11.Http11Processor.process(H
            at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt
            at Socket(
            at .run(
            2009-09-22 12:46:10,953 INFO [] ActiveMQ Message Broker (localhost, ID:PC028682-1636-1253603663328-0:0) is shutting down

            Root cause :
            root cause

            org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: tried calling method [public abstract int javax.transaction.TransactionManager.getStatus() throws javax.transaction.SystemException] on target [[email protected]]; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class

            Can someone help with this? Am I using the wrong class somewhere?

            Much Thanks,