Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 03947200C88 for ; Fri, 2 Jun 2017 22:11:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 02F24160BD2; Fri, 2 Jun 2017 20:11:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4A214160BBA for ; Fri, 2 Jun 2017 22:11:08 +0200 (CEST) Received: (qmail 89526 invoked by uid 500); 2 Jun 2017 20:11:02 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 89514 invoked by uid 99); 2 Jun 2017 20:11:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jun 2017 20:11:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id B9A9718002C for ; Fri, 2 Jun 2017 20:11:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.708 X-Spam-Level: X-Spam-Status: No, score=-3.708 tagged_above=-999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URI_HEX=1.313, URI_TRY_3LD=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id C19Ku7i-kCSE for ; Fri, 2 Jun 2017 20:11:00 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 3C7535F2FD for ; Fri, 2 Jun 2017 20:10:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0586A7E9C2 for ; Fri, 2 Jun 2017 20:10:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0586A7E9C2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=apache.org Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jbertram@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0586A7E9C2 Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ECA8C87947 for ; Fri, 2 Jun 2017 20:10:57 +0000 (UTC) Received: from zmail22.collab.prod.int.phx2.redhat.com (zmail22.collab.prod.int.phx2.redhat.com [10.5.83.26]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E43F0180BAF4 for ; Fri, 2 Jun 2017 20:10:57 +0000 (UTC) Date: Fri, 2 Jun 2017 16:10:57 -0400 (EDT) From: Justin Bertram To: users@activemq.apache.org Message-ID: <1086845930.17782796.1496434257857.JavaMail.zimbra@redhat.com> In-Reply-To: <1496431207771-4726976.post@n4.nabble.com> References: <1496246907718-4726828.post@n4.nabble.com> <1496303676126-4726859.post@n4.nabble.com> <1496304308796-4726860.post@n4.nabble.com> <1496423492670-4726958.post@n4.nabble.com> <190602210.17741686.1496427316842.JavaMail.zimbra@redhat.com> <1496431207771-4726976.post@n4.nabble.com> Subject: Re: ActiveMQ Embedded with Tomcat missing messages while restart MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.10.122.4, 10.4.195.1] Thread-Topic: ActiveMQ Embedded with Tomcat missing messages while restart Thread-Index: WUoTiqpwE8Va1ntaX6FluHWqcXkIig== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 02 Jun 2017 20:10:58 +0000 (UTC) archived-at: Fri, 02 Jun 2017 20:11:09 -0000 I don't see in your code where you're calling rollback either on any Hibernate or JMS resource. Typically in this kind of scenario you'd want the consumption of the message and the database operation to be atomic to ensure the integrity of your data (i.e. one message equals one database operation). Without atomicity you risk losing or duplicating data. These kinds of guarantees are really easy to configure in a Java EE environment (e.g. using container-managed transactions and an XA JDBC datasource), but I'm not familiar enough with Spring to make any recommendations. The bottom line here is that I think your application and/or architecture is the problem here and not the message broker. Justin ----- Original Message ----- From: "rsahadevan" To: users@activemq.apache.org Sent: Friday, June 2, 2017 2:20:07 PM Subject: Re: ActiveMQ Embedded with Tomcat missing messages while restart HI Justin, What you understood is correct. Consumer is writing to database. I tried with rollback and is not happening. Commit is failing in the DB and not happening rollback into activemq_msgs. This is the reason I was thinking about this approach . Please let me know anything I am missing in config public void onMessage(Message message) { try { PlatformTransactionManager transactionManager = Context.getBean(Context.Name.TRANSACTION_MANAGER); TransactionStatus transaction = transactionManager.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED)); updateDynamicBalance(new Integer(message.getIntProperty("entityId")),new Integer(message.getIntProperty("userId")),new BigDecimal(message.getDoubleProperty("amount")),message.getStringProperty("mediationKey")); transaction.flush(); return; } catch (Exception e) { LOG.error("Generating payment", e); } Spring Config ----------------- -- View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-Embedded-with-Tomcat-missing-messages-while-restart-tp4726828p4726976.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.