Can permanence of message solve this problem? I join follow code,but no effect. producer->setTimeToLive(1000000000); If I send message to activemq server in one program,and I receive message in other program.I set permanence of messge.over this time,message will disappear. I hope producer in one program(or function),and consumer in other program(or function). How shall I do? Thanks a lot.
nmittler wrote: > > It looks like you stop producing before you start consuming. The join on > the thread waits for that thread to stop. If you join on the producing > thread before you start your consumer, the main thread will block until > the > producer is done and there will be no messages available for the consumer > when it starts. > > If you look at our example, we start the consumer thread, then we start > the > producer thread, and finally join and wait for both threads to terminate. > > Hope this helps, > Nate > > On 11/11/06, sgliu <[EMAIL PROTECTED]> wrote: >> >> >> At first,I thank you for helping. >> This sample work fine.But If I change createQueue to createTopic in >> producer >> and consumer, and change follow code >> int main(int argc, char* argv[]) { >> >> HelloWorldProducer producer( 5 ); >> HelloWorldConsumer consumer( 5000 ); >> >> // Start the consumer thread. >> Thread consumerThread( &consumer ); >> consumerThread.start(); >> >> // Start the producer thread. >> Thread producerThread( &producer ); >> producerThread.start(); >> >> // Wait for the threads to complete. >> producerThread.join(); >> consumerThread.join(); >> } >> into >> void Produce() >> { >> HelloWorldProducer producer( 5 ); >> Thread producerThread( &producer ); >> producerThread.start(); >> producerThread.join(); >> } >> void Consumer() >> { >> HelloWorldConsumer consumer( 5000 ); >> Thread consumerThread( &consumer ); >> consumerThread.start(); >> consumerThread.join(); >> } >> int main(int argc, char* argv[]) >> { >> Produce(); >> Consumer(); >> } >> >> after running,I received nothing. >> If I write some code for produce,and write some code for consumer. How >> shall >> I do ? >> >> >> >> >> I've updated the example code shown here: >> http://www.activemq.com/site/activemq-c-clients.html >> >> The update show the use of topic or queue by passing a boolean into the >> ctor >> of the producer and consumer objects on construction. >> >> It may take some time for the webpage to update, so grab to code from >> trunk >> if you don't see the changed code here. >> >> Regards >> Tim. >> >> -- >> View this message in context: >> http://www.nabble.com/Topic-In-Visual-C%2B%2B%2CWho-can-help-me--tf2606196.html#a7298852 >> Sent from the ActiveMQ - User mailing list archive at Nabble.com. >> >> > > -- View this message in context: http://www.nabble.com/Topic-In-Visual-C%2B%2B%2CWho-can-help-me--tf2606196.html#a7299106 Sent from the ActiveMQ - User mailing list archive at Nabble.com.