activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Suchitha Koneru \(sukoneru\)" <sukon...@cisco.com>
Subject messages are received after expiry time
Date Wed, 18 Jul 2007 02:10:39 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message