I guess I'm not sure exactly what you're trying to do. I don't see a consumer in the code snippets. Is your consumer a C++ or Java client? Are you using an asynchronous consumer through the MessageListener interface, or are you calling receive() after a timed wait?
-----Original Message----- From: sgliu [mailto:[EMAIL PROTECTED] Sent: Monday, November 27, 2006 7:13 PM To: [email protected] Subject: Re: Message's live time Please help me. sgliu wrote: > > I change to follow code. > Sorry. > 10 second later,message doesn't disappear. > > #include <time.h> > double getcurt() > { > time_t ltime; > time(<ime); > double ddd; > ddd=ltime*1000; //second to millisecond > return ddd; > } > ... > double ttt=getcurt(); > message->setCMSTimeStamp(ttt); > message->setCMSExpiration(ttt + 10000); //10 second > ... > follow code do not yet. > ... > double ttt=getcurt(); > message->setCMSTimeStamp(ttt); > producer->setTimeToLive(ttt + 10000); //10 second > ... > I use visual c++ 2005 > > > > nmittler wrote: >> >> Just to clear that up, I believe if you set TimeToLive to Tnow + >> timeToLive in the MessageProducer before sending a message, you will >> have the expiration time you're looking for. >> >> So something like this ... >> >> long Tnow = ... // whatever is appropriate for your compiler/OS ... >> just get the current time in milliseconds >> long timeToLive = 5000L; // 5 milliseconds >> producer->setTimeToLive(Tnow + timeToLive ); >> ... >> producer->send(msg); >> >> >> Again, this is just a temporary work around. We should have this >> fixed in trunk soon. >> >> Regards, >> Nate >> >> On 11/26/06, Nathan Mittler <[EMAIL PROTECTED]> wrote: >>> >>> I just took a look at the code and it looks like the >>> ActiveMQProducer.sendmethod is overwriting the CMSExpiration in the >>> message with its timeToLive value. This is incorrect - it should >>> set the expiry to (expiry + timeToLive). I've captured this in a >>> JIRA issue: https://issues.apache.org/activemq/browse/AMQCPP-14 >>> >>> In the mean time, the CMS Expiration and TimeToLive serve basically >>> the same purpose. I'm not sure exactly what results you're looking >>> for, but you should be able to do essentially the same thing by >>> using the TimeToLive value in the ActiveMQProducer. >>> >>> Regards, >>> Nate >>> >>> On 11/26/06, sgliu <[EMAIL PROTECTED]> wrote: >>> > >>> > >>> > I konw the function Message::setCMSExpiration(long).I think it is >>> > live time of message. >>> > But follow code,10 second later,I receive message yet. >>> > ... >>> > session = connection->createSession( Session::AUTO_ACKNOWLEDGE ); >>> > destination = session->createTopic( "mytopic" ); >>> > ... >>> > producer->setDeliveryMode( DeliveryMode::PERSISTANT ); >>> > ... >>> > string text = "Hello world!" >>> > TextMessage* message = session->createTextMessage( text ); >>> > message->setCMSExpiration(10000); >>> > producer->send( message ); >>> > delete message; >>> > >>> > Why? >>> > -- >>> > View this message in context: >>> > http://www.nabble.com/Message%27s-live-time-tf2706004.html#a754489 >>> > 7 >>> > Sent from the ActiveMQ - User mailing list archive at Nabble.com. >>> > >>> > >>> >> >> > > -- View this message in context: http://www.nabble.com/Message%27s-live-time-tf2706004.html#a7570864 Sent from the ActiveMQ - User mailing list archive at Nabble.com.
