Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 44186 invoked from network); 17 Dec 2007 10:07:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Dec 2007 10:07:56 -0000 Received: (qmail 71392 invoked by uid 500); 17 Dec 2007 10:07:44 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 71377 invoked by uid 500); 17 Dec 2007 10:07:44 -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 71368 invoked by uid 99); 17 Dec 2007 10:07:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Dec 2007 02:07:44 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=SPF_PASS,URIBL_BLACK X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [80.190.253.131] (HELO mail.baseserver.net) (80.190.253.131) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Dec 2007 10:07:19 +0000 Received: from [192.168.2.227] (unknown [195.177.48.115]) by mail.baseserver.net (Postfix) with ESMTP id 475EE9B5A3 for ; Mon, 17 Dec 2007 11:07:19 +0100 (CET) Subject: Re: Already acknowledged messages are sent again at server restart (duplicate messages) From: Martin Grotzke To: users@activemq.apache.org In-Reply-To: References: <1197579899.3247.100.camel@localhost.localdomain.tld> <1197724582.3422.6.camel@localhost.localdomain.tld> <1197849047.3113.4.camel@localhost.localdomain.tld> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-wQsXYsWfkQwrYrPrV08q" Date: Mon, 17 Dec 2007 11:07:18 +0100 Message-Id: <1197886038.3460.5.camel@localhost.localdomain.tld> Mime-Version: 1.0 X-Mailer: Evolution 2.12.2 (2.12.2-2.fc8) X-Virus-Checked: Checked by ClamAV on apache.org --=-wQsXYsWfkQwrYrPrV08q Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Ok, yestery I already changed the dependency to activemq-5.0.0 and deployed one application on the test-system. other (remote) applications on the test-system are still running activemq-4.1.1, but AFAICS the communication between 5.0.0 and 4.1.1 was fine - no problems. Now we plan to upgrade our production applications to 5.0.0 tomorrow, so hopefully I can tell you more in 2 or 3 days, if we still encounter the duplicate messages. Thanx for now, cheers, Martin On Sun, 2007-12-16 at 20:48 -0500, Hiram Chirino wrote: > Not sure. But I'd also recommend you move on to the 5.0.0 release. >=20 > On Dec 16, 2007 6:50 PM, Martin Grotzke wr= ote: > > Ok, I will change this. Might this be the reason for the duplicate > > messages? > > > > Cheers, > > Martin > > > > > > > > On Sat, 2007-12-15 at 13:42 -0500, Hiram Chirino wrote: > > > Nope.. The broker name also has to be different. Have them connect > > > with something like vm://brokera and vm://brokerb > > > > > > On Dec 15, 2007 8:16 AM, Martin Grotzke wrote: > > > > Hello, > > > > > > > > because I just read this in another thread: > > > > > > > > > Also make sure the all the brokers have unique broker names. > > > > > > > > I forgot to mention, that we have two web applications (contexts) > > > > running in one tomcat, and both with a broker. ConnectionFactories = in > > > > both apps connect to them both with brokerUrl "vm://localhost". > > > > > > > > Via jmx I can see, that two brokers exist, with different BrokerIds= . > > > > > > > > Is this ok so far, or might it be a possible reason for the strange > > > > behavior? > > > > > > > > Cheers, > > > > Martin > > > > > > > > > > > > > > > > On Thu, 2007-12-13 at 22:04 +0100, Martin Grotzke wrote: > > > > > Hi, > > > > > > > > > > currently we have the issue of messages, that are sent again at s= erver > > > > > restart on our production system. Unfortunately, on the test-syst= em this > > > > > is not reproducable. > > > > > > > > > > I have seen, that in this mailing list and in the issue tracker t= his > > > > > issue has been already discussed several times, but I couldn't fi= nd > > > > > anything that might help to track down this issue. > > > > > > > > > > So what are we doing? We are using ActiveMQ 4.1.1 with the jvm tr= ansport > > > > > embedded within a tomcat and configured via spring. > > > > > > > > > > Mhh, more details you find below: configuration, producer, consum= er, > > > > > logs. So is anything wrong with this? Is it ok to use one session= for > > > > > two message listeners (to the same backend)? Should we use transa= ctions? > > > > > Should we use AativeMQ 5? > > > > > Or what else might be the reason for the problem? > > > > > > > > > > Thanx a lot in advance, > > > > > cheers, > > > > > Martin > > > > > > > > > > > > > > > And now the details... > > > > > > > > > > The broker (spring) configuration looks like this: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > activemq.xml: > > > > > > > > > > > > > > > > > > > brokerName=3D"localhost" dataDirectory=3D"/tmp/activemq= /data"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The jmsTemplate and connectionFactory configuration is the follow= ing: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > scope=3D"singleton" depends-on=3D"broker"> > > > > > > > > > > > > > > > vm://localhost > > > > > false<= /property> > > > > > false > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The producer code looks like this, using the jmsTemplate shown ab= ove: > > > > > > > > > > public void sendSomeMessage ( final SomeSerializable someSeri= alizable ) { > > > > > _jmsTemplate.send( Topics.TOPIC_1, new SomeMessageCreator= () { > > > > > public Message createMessage( Session session ) throw= s JMSException { > > > > > final ObjectMessage result =3D session.createObjectMe= ssage( someSerializable ); > > > > > // here is used a property that is later used for sel= ecting messages, > > > > > // perhaps this isn't really required...? > > > > > result.setStringProperty( MessageProperties.EVENT_TYP= E.name(), Topics.TOPIC_1.name() ); > > > > > return result; > > > > > }); > > > > > } > > > > > > > > > > > > > > > On the consumer side we have a "MessageListenerContainer", that s= ets up > > > > > several message listeners. Its configuration and the configuratio= n of > > > > > the connection factory is this: > > > > > > > > > > > > > > class=3D"com.freiheit.shopping24.shop.message.business.im= pl.MessageListenerContainer" > > > > > destroy-method=3D"shutdown" scope=3D"singleton"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > class=3D"org.apache.activemq.spring.ActiveMQConnectionFac= tory" > > > > > scope=3D"singleton" depends-on=3D"broker"> > > > > > vm://localhost > > > > > true > > > > > false > > > > > false > > > > > true > > > > > > > > > > > > > > > The MessageListenerContainer looks like the following: > > > > > > > > > > class MessageListenerContainer { > > > > > > > > > > private Connection _connection; > > > > > > > > > > MessageListenerContainer ( > > > > > final ConnectionFactory listenerConnectionFactory, > > > > > final Action1 action1, > > > > > final Action2 action2, > > > > > final Action3 action3, > > > > > final Action4 action4 ) { > > > > > > > > > > try { > > > > > _connection =3D listenerConnectionFactory.createConne= ction(); > > > > > _connection.setClientID( "some-client-id" ); > > > > > > > > > > // two sessions for two different backends > > > > > final Session session1 =3D _connection.createSession(= false, Session.CLIENT_ACKNOWLEDGE ); > > > > > final Session session2 =3D _connection.createSession(= false, Session.CLIENT_ACKNOWLEDGE ); > > > > > > > > > > // send event1 to backend1 and backend2 > > > > > registerEventAndAction( session1, Topics.TOPIC_1, act= ion1.getClass().getSimpleName(), > > > > > new SomeMessageListener( action1 ) ); > > > > > registerEventAndAction( session2, Topics.TOPIC_1, act= ion2.getClass().getSimpleName(), > > > > > new SomeMessageListener( action2 ) ); > > > > > > > > > > // send event2 to backend1 and backend2 > > > > > registerEventAndAction( session1, Topics.TOPIC_2, act= ion3.getClass().getSimpleName(), > > > > > new SomeOtherMessageListener( action1 ) ); > > > > > registerEventAndAction( session2, Topics.TOPIC_2, act= ion4.getClass().getSimpleName(), > > > > > new SomeOtherMessageListener( action2 ) ); > > > > > > > > > > _connection.start(); > > > > > } catch ( JMSException e ) { > > > > > LOG.fatal( "Could not start MessageListenerContainer.= ", e ); > > > > > throw new RuntimeException( "Could not start MessageL= istenerContainer", e ); > > > > > } > > > > > } > > > > > > > > > > private void registerEventAndAction( Session session, > > > > > Topics topic, > > > > > String actionName, > > > > > MessageListener messageListener ) { > > > > > try { > > > > > // here we have the selector on the property EVENT_TY= PE with the name of > > > > > // the Topics enum, but I don't know if we really nee= d this - a colleague has > > > > > // written this ;-) > > > > > TopicSubscriber subscriber =3D session.createDurableS= ubscriber( topic, topic.name() + "-" + > > > > > actionName, MessageProperties.EVENT_TYPE + "= =3D\'" + topic.name() + "\'", false ); > > > > > subscriber.setMessageListener( messageListener ); > > > > > } catch ( JMSException e ) { > > > > > LOG.fatal( "Could not create subscriber.", e ); > > > > > } > > > > > } > > > > > > > > > > public void shutdown () { > > > > > if ( _connection !=3D null ) { > > > > > try { > > > > > _connection.close(); > > > > > } catch ( JMSException e ) { > > > > > LOG.error( "Could not stop JMS connection.", e ); > > > > > } > > > > > } > > > > > } > > > > > > > > > > } > > > > > > > > > > The message listeners look like this: > > > > > > > > > > public final class SomeMessageListener implements MessageListener= { > > > > > > > > > > private static final Log LOG =3D LogFactory.getLog( SomeMessa= geListener.class ); > > > > > > > > > > private final SomeAction _action; > > > > > > > > > > public SomeMessageListener(SomeAction action) { > > > > > _action =3D action; > > > > > } > > > > > > > > > > public void onMessage( Message message ) { > > > > > LOG.info( "Got message " + message ); > > > > > final SomeSerializable someSerializable; > > > > > try { > > > > > someSerializable =3D (SomeSerializable) ((ObjectMessa= ge)message).getObject(); > > > > > _action.performProductListAction( details ); > > > > > message.acknowledge(); > > > > > LOG.info( "Received message acknowledged." ); > > > > > } catch ( JMSException e ) { > > > > > LOG.fatal( "Could not acknowledge message.", e ); > > > > > } > > > > > } > > > > > } > > > > > > > > > > > > > > > Exactly these message are printed in the logs when the server is > > > > > restarted many messages, and not only for one message, but for 10= 00 or > > > > > 2000 for the last 6 days (the server was restarted 6 days before)= . > > > > > > > > > > The logs related to messaging when the server starts: > > > > > > > > > > [INFO ] main org.apache.activemq.broker.BrokerService.getBroker: > > > > > ActiveMQ 4.1.1 JMS Message Broker (localhost) is starting > > > > > > > > > > [INFO ] main org.apache.activemq.broker.BrokerService.getBroker: > > > > > For help or more information please see: http://incubator.apache.= org/activemq/ > > > > > > > > > > [INFO ] JMX connector org.apache.activemq.broker.jmx.ManagementCo= ntext.run: > > > > > > > > > > JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localho= st:1099/jmxrmi > > > > > > > > > > [INFO ] main org.apache.activemq.store.jdbc.JDBCPersistenceAdapte= r.createAdapter: > > > > > Database driver recognized: [apache_derby_embedded_jdbc_driver] > > > > > > > > > > [INFO ] main org.apache.activemq.store.jdbc.DefaultDatabaseLocker= .start: > > > > > Attempting to acquire the exclusive lock to become the Master bro= ker > > > > > > > > > > [INFO ] main org.apache.activemq.store.jdbc.DefaultDatabaseLocker= .start: > > > > > Becoming the master on dataSource: org.apache.derby.jdbc.Embedded= DataSource@2dda6548 > > > > > > > > > > [INFO ] main org.apache.activemq.store.journal.JournalPersistence= Adapter.recover: > > > > > Journal Recovery Started from: Active Journal: using 2 x 20.0 Meg= s at: /tmp/activemq/data/journal > > > > > > > > > > [INFO ] main org.apache.activemq.store.journal.JournalPersistence= Adapter.recover: > > > > > Journal Recovered: 1 message(s) in transactions recovered. > > > > > > > > > > [INFO ] main org.apache.activemq.broker.BrokerService.start: > > > > > ActiveMQ JMS Message Broker (localhost, ID:portal02.shopping25.ea= synet.de-55403-1197562278985-1:0) started > > > > > > > > > > [INFO ] main com.freiheit.shopping24.shop.message.business.impl.M= essageServiceImpl.: > > > > > Creating MessageService... > > > > > > > > > > [INFO ] main com.freiheit.shopping24.shop.message.business.impl.M= essageListenerContainer.: > > > > > Creating MessageListenerContainer, registering message listeners.= .. > > > > > > > > > > [INFO ] main org.apache.activemq.broker.TransportConnector.start: > > > > > Connector vm://localhost Started > > > > > > > > > > [INFO ] main org.apache.activemq.kaha.impl.KahaStore.delete: > > > > > Kaha Store deleted data directory /www/freiheit/data/activemq/dat= a/tmp_storage > > > > > > > > > > [INFO ] ActiveMQ Session Task foo.SomeMessageListener.onMessage: > > > > > Got message ActiveMQObjectMessage {commandId =3D 7, responseRequi= red =3D true, > > > > > messageId =3D ID:fqdn-42897-1196946608950-3:795:1:1:3, originalDe= stination =3D null, > > > > > originalTransactionId =3D null, producerId =3D ID:fqdn-42897-1196= 946608950-3:795:1:1, > > > > > destination =3D topic://TOPIC_1, transactionId =3D null, expirati= on =3D 0, timestamp =3D 1197048729937, > > > > > arrival =3D 0, correlationId =3D null, replyTo =3D null, persiste= nt =3D true, type =3D null, > > > > > priority =3D 4, groupID =3D null, groupSequence =3D 0, targetCons= umerId =3D null, compressed =3D false, > > > > > userID =3D null, content =3D org.apache.activemq.util.ByteSequenc= e@6d6564ae, > > > > > marshalledProperties =3D org.apache.activemq.util.ByteSequence@1b= b5139e, dataStr > > > > > ucture =3D null, redeliveryCounter =3D 0, size =3D 1208, properti= es =3D {EVENT_TYPE=3DTOPIC_1}, > > > > > readOnlyProperties =3D true, readOnlyBody =3D true, droppable =3D= false} > > > > > > > > > > [INFO ] ActiveMQ Session Task foo.SomeMessageListener.onMessage: > > > > > Received message acknowledged. > > > > > > > > > > And lots more log messages like the last two... > > > > > > > > > > Wow, you really have reached this point, thanx a lot! :) > > > > > So is there anything wrong? > > > > > > > > > > > > > > -- > > > > > > > > Martin Grotzke > > > > http://www.javakaffee.de/blog/ > > > > > > > > > > > > > > > -- > > Martin Grotzke > > http://www.javakaffee.de/blog/ > > >=20 >=20 >=20 --=20 Martin Grotzke http://www.javakaffee.de/blog/ --=-wQsXYsWfkQwrYrPrV08q Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBHZkpS7FvOl7Te+pYRAqBBAKDJexldb61IFBU+zz6gBpdL4iDVVQCffyna KIzwVtObA/Jn5/ckd7ICfiI= =CGa5 -----END PGP SIGNATURE----- --=-wQsXYsWfkQwrYrPrV08q--