Announcement Announcement Module
Collapse
No announcement yet.
when start the application ,the containerListener occurs a transaction exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • when start the application ,the containerListener occurs a transaction exception

    As soon as my application starts ,the listener will occur the exceptions as follows,but these exceptions do not always come out ,in my local machine there are no the exceptions ,but I deploy the war package on two computers , one of them come out the exceptions.
    Code:
    org.springframework.amqp.AmqpException: failed to commit RabbitMQ transaction
    	at org.springframework.amqp.rabbit.connection.RabbitResourceHolder.commitAll(RabbitResourceHolder.java:150)
    	at org.springframework.amqp.rabbit.transaction.RabbitTransactionManager.doCommit(RabbitTransactionManager.java:181)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
    	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:147)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:436)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$300(SimpleMessageListenerContainer.java:58)
    	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:548)
    	at java.lang.Thread.run(Thread.java:662)
    Caused by: java.io.IOException
    	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
    	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
    	at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)
    	at com.rabbitmq.client.impl.ChannelN.txCommit(ChannelN.java:1004)
    	at com.rabbitmq.client.impl.ChannelN.txCommit(ChannelN.java:61)
    	at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:348)
    	at $Proxy29.txCommit(Unknown Source)
    	at org.springframework.amqp.rabbit.connection.RabbitResourceHolder.commitAll(RabbitResourceHolder.java:147)
    	... 8 more
    Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - channel is not transactional, class-id=90, method-id=20), null, ""}
    	at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
    	at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
    	at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343)
    	at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)
    	at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)
    	... 16 more
    this is my listener configuration, I have a service class can start listener when the application starts.
    Code:
    <rabbit:listener-container id="ocrWorker"
    		concurrency="20" connection-factory="rabbitConnectionFactory"
    		prefetch="20" transaction-manager="rabbitTransactionManager"
    		transaction-size="10" auto-startup="false" message-converter="orcMessageConvert" >
    		<rabbit:listener method="doMessageQueueWork"
    			queue-names="queue.etlOcrServer.recognize" ref="ocrListener" />
    	</rabbit:listener-container>

  • #2
    You need to set
    Code:
    channel-transacted="true"
    on the listener-container.

    Also, it is generally not necessary to supply an external transaction-manager; the container will manage its own transactions.

    Comment


    • #3
      thanks , at last I delete
      transaction-manager="rabbitTransactionManager"
      ,then the application works well.But why do the exceptions not always come out in all machines and my local machine can works well ? .and you say the container will manage its own transactions,if I set channel-transacted="true",we don't need to config transaction-manager?

      Comment


      • #4
        I can't explain exactly without seeing a log but my guess is there is a race condition in that a non-transactional channel is being used by the container. Sometimes it works, sometimes it doesn't. Setting channel-transacted means channels will always be transacted, regardless of whether an external transaction manager is configured but, like I said, you generally only need a transaction manager if you need to synchronize AMQP transactions with some other transaction, such as JDBC.

        Comment


        • #5
          I set the value of channel-transacted as false,after application start ,I find the mode of some channels which connect to the rabbitMq from application is "T",but some are not ,what is the reason ?,and transaction-manager means the container will synchronize message transactions with some other transaction?if some transaction roll back,my amqp transaction also roll back and the message will rejected into the queue? if I config a jpaTransactionManager as transaction-manager ,what does the effect it wil occur ? thanks

          Comment


          • #6
            If you are sharing a caching connection factory between components, some of which are transacted, some are not, the cache maintains two lists.

            If you want transactional behavior in your listener, set channel-transacted to TRUE like I said above. You don't need a RabbitTransactionManager here. If you want to synchronize your AMQP transactions with, say, JPA transactions, then supply the JpaTransactionManager here. That way, the JPA transaction will be started here, and the AMQP commit will be synchronized with it (the two commits are done as closely as possible together).

            Comment


            • #7
              when I used 1.1.1 released,I find that if I set channel-transacted to FALSE and assume that the concurrency="20" ,then the rabbitmq server will have 40 channels ,20 of them are T others are not T.I don't share a caching connection factory for two or more components.Then I used 1.1.2 Released I find that I set channel-transacted to TRUE and 10 to concurrency,the server shows 11 channels link to queue,ten of them is T,but there is a channle is not T,so what is the NOT-T channel's function?
              if I set channel-transacted to FALSE and 10 to concurrency then ,the whole ten channels is NOT-T .
              Last edited by andy lin; Oct 25th, 2012, 10:57 PM.

              Comment


              • #8
                The non-transactional channel was created by the RabbitAdmin to declare any queues etc.

                Comment

                Working...
                X