Announcement Announcement Module
Collapse
No announcement yet.
DefaultMessageListenerContainer & transactionManager closing Issues Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 -

    Code:
    2007-04-14 11:38:46,390 DEBUG [org.jboss.mq.il.uil2.SocketManager] Failed to handle: org.jboss.mq.il.uil2.msgs.CloseMsg6054725[msgType: m_connectionClosing, msgID: -2147483303, error: null]
    java.io.IOException: Client is not connected
    
    2007-04-14 11:38:46,390 DEBUG [org.jboss.mq.il.uil2.SocketManager] Failed to send error reply
    java.io.IOException: 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, 09:54 PM.

  • #2
    Hello,

    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.

    regards
    lyserg

    Comment


    • #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.

      Code:
       <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
              <property name="environment">
                  <props>
                      <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>
                  </props>
              </property>
          </bean>
      
          <!-- JMS Queue Connection Factory -->
          <bean id="internalJmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiTemplate" ref="jndiTemplate" />
              <property name="jndiName" value="UIL2ConnectionFactory" />
          </bean>
          
          <!-- JMS Destination -->
          <bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiTemplate" ref="jndiTemplate" />
              <property name="jndiName" value="queue/PostrRequestSendQueue" />
          </bean>
      
          <!-- 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" />
          </bean>
      
      <!-- 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" />
      	</bean>
      
      	<!-- 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" />
      	</bean>
      Code:
      2007-04-16 18:55:00,586 DEBUG [org.jboss.mq.il.uil2.SocketManager] Failed to handle: org.jboss.mq.il.uil2.msgs.CloseMsg4258232[msgType: m_connectionClosing, msgID: -2147356076, error: null]
      java.io.IOException: Client is not connected
              at org.jboss.mq.il.uil2.SocketManager.internalSendMessage(SocketManager.java:264)
              at org.jboss.mq.il.uil2.SocketManager.sendReply(SocketManager.java:238)
              at org.jboss.mq.il.uil2.ServerSocketManagerHandler.handleMsg(ServerSocketManagerHandler.java:131)
              at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleMsg(SocketManager.java:395)
              at org.jboss.mq.il.uil2.msgs.BaseMsg.run(BaseMsg.java:398)
              at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
              at java.lang.Thread.run(Thread.java:613)
      2007-04-16 18:55:00,586 DEBUG [org.jboss.mq.il.uil2.SocketManager] Failed to send error reply
      java.io.IOException: Client is not connected
              at org.jboss.mq.il.uil2.SocketManager.internalSendMessage(SocketManager.java:264)
              at org.jboss.mq.il.uil2.SocketManager.access$800(SocketManager.java:53)
              at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleMsg(SocketManager.java:408)
              at org.jboss.mq.il.uil2.msgs.BaseMsg.run(BaseMsg.java:398)
              at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
              at java.lang.Thread.run(Thread.java:613)
      2007-04-16 18:55:00,587 DEBUG [org.jboss.mq.il.uil2.SocketManager] End WriteTask.run
      2007-04-16 18:55:00,588 DEBUG [org.jboss.mq.il.uil2.SocketManager] End ReadTask.run
      2007-04-16 18:55:00,589 DEBUG [org.jboss.mq.il.uil2.UILClientILService] Stopping
      2007-04-16 18:55:00,590 DEBUG [org.jboss.mq.il.uil2.SocketManager] End WriteTask.run

      Comment


      • #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) -

        http://www.jboss.com/index.html?modu...036291#4036291

        http://www.jboss.com/index.html?modu...wtopic&t=86482

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

        Comment


        • #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.

          Comment


          • #6
            Problem with DefaultMessageListener and JtaTransactionManager

            Hi,

            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 MethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:307)
            at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:198)
            at $Proxy52.getStatus(Unknown Source)
            at org.springframework.transaction.jta.UserTransactio nAdapter.getStatus(UserTransactionAdapter.java:80)
            at org.springframework.transaction.jta.JtaTransaction Manager.isExistingTransaction(JtaTransactionManage r.java:820)
            at org.springframework.transaction.support.AbstractPl atformTransactionManager.getTransaction(AbstractPl atformTransactionManager.java:351)
            at org.springframework.transaction.interceptor.Transa ctionAspectSupport.createTransactionIfNecessary(Tr ansactionAspectSupport.java:263)
            at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:101)
            at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
            at org.springframework.aop.interceptor.ExposeInvocati onInterceptor.invoke(ExposeInvocationInterceptor.j ava:89)
            at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
            at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
            at $Proxy53.getContract(Unknown Source)
            at com.test.jms.MessageSender.sendMessage(MessageSend er.java:39)
            at org.apache.jsp.send_jsp._jspService(send_jsp.java: 58)
            at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
            at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
            at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:334)
            at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
            at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
            at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
            at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)
            at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
            at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:175)
            at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:74)
            at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
            at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve .invoke(CachedConnectionValve.java:156)
            at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:664)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.MasterSlaveWorkerThread .run(MasterSlaveWorkerThread.java:112)
            at java.lang.Thread.run(Thread.java:595)
            2009-09-22 12:46:10,953 INFO [org.apache.activemq.broker.BrokerService] ActiveMQ Message Broker (localhost, ID:PC028682-1636-1253603663328-0:0) is shutting down

            and
            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 [org.jboss.tm.TxManager@70cdd2]; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class
            org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:315)


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

            Much Thanks,
            An

            Comment

            Working...
            X