activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Davies <rajdav...@gmail.com>
Subject Re: messages are received after expiry time
Date Wed, 18 Jul 2007 05:09:30 GMT
Can I suggest you use the 4.1.1 release ?  http://activemq.apache.org/ 
activemq-411-release.html

cheers,

Rob

On Jul 18, 2007, at 3:10 AM, Suchitha Koneru ((sukoneru)) wrote:

> Hello Active MQ users ,
>                                The active mq version which we use is
> 4.0.2. Our application uses durable subscriber and topic  
> publishers. The
> time to live on the topic publishers is set as 5 minutes which 300,000
> seconds.
> Two  durable subscribers a and b  are created and started  10 minutes
> after the messages are published. Both the subscribers receive all the
> messages. The messages should expire after 5 minutes , how come  
> they are
> still getting delivered ??  Please let me know, if Iam missing  
> anything
> in teh configuration. The broker is started at command line from  
> active
> me's bin directory.
>
> thanks,
> suchitha.
>
> The code for publisher  is as follows
> InitialContext envContext = new InitialContext(prop);
>
> connectionFactory = new
> ActiveMQConnectionFactory("tcp://171.69.155.137:61616");
>
> connection = (TopicConnection )connectionFactory.createConnection();
>
> session = ( TopicSession) connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
> topic = (Topic) envContext.lookup("MyTopic") ;
>
> producer = (TopicPublisher)session.createPublisher(topic);
>
> if(producer != null){
>
> producer.setTimeToLive(300000); // time to live 5 minutes
>
> producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>
> connection.start();
>
> }
>
> int i=0 ;
>
> while(i<10){
>
> System.out.println("sending message");
>
> ObjectMessage objMsg = session.createObjectMessage(i+"");
>
> System.out.println("publishing the message");
>
> i++;
>
> producer.publish(objMsg);
>
> }
>
>
> code for receiver
>
> InitialContext envContext = new InitialContext(prop);
>
> connectionFactory = new
> ActiveMQConnectionFactory("tcp://171.69.155.137:61616");
>
> connection = (TopicConnection )connectionFactory.createConnection();
>
> connection.setClientID(clientID);
>
> session = ( TopicSession) connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
> topic = (Topic) envContext.lookup("MyTopic") ;
>
> durableSubscriber = session.createDurableSubscriber(topic,
> durableSubscriptionName);
>
> durableSubscriber.setMessageListener(this);
>
> if(durableSubscriber != null){
>
> connection.start();
>
> System.out.println("receiver started");
>
> }
>
> public void onMessage(Message message){
>
>
>
> if(message instanceof ObjectMessage) {
>
> ObjectMessage objMessage = (ObjectMessage) message;
>
> System.out.println(this.durableSubscriptionName+"
> "+objMessage.getObject().toString() );
>
> }
>
> }
>
>


Mime
View raw message