You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by sgliu <sh...@sina.com> on 2006/11/10 08:18:16 UTC

Topic In Visual C++,Who can help me?

I want some code(can compile in visual C++), Can complete "topic", like
example shows CMS in action(http://www.activemq.org/site/cms.html).
I want create topic, not create queue,In Visual C++ 2005.
who can give me some code?
Help me...
-- 
View this message in context: http://www.nabble.com/Topic-In-Visual-C%2B%2B%2CWho-can-help-me--tf2606196.html#a7272366
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Topic In Visual C++,Who can help me?

Posted by sgliu <sh...@sina.com>.
Example in http://www.activemq.org/site/cms.html 
I only change
destination = session->createQueue( "TEST.FOO" );
into
destination = session->createTopic( "mytopic" );
In producer and consumer,I both change it.

I also changed 
HelloWorldProducer producer( 1000 );
into 
HelloWorldProducer producer( 1);

Programe run no error.But I see nothing in consumer,see nothing prompt
message in producer also.
J2SE 5.0 Monitoring & management Consol prompt:
In ActiveMQ.Advisory.Consumer.Topic.mytopic
ConsumerCount=0,DequeueCount=0,QueueSize=0

these code , queue sucess,but topic ?
How can I do?
----------------------------------------------------------------------------------------------------------------------------------



James.Strachan wrote:
> 
> On 11/10/06, sgliu <sh...@sina.com> wrote:
>>
>> but how create topic?
>> Only change createQueue() to createTopic()?
> 
> Yes
> 
>> I try it,but not succeed.
> 
> What happens?
> 
>> (can send ,but can not receive)
> 
> Try looking in the JConsole or Web Console or the Visualisation Plugin
> to see who's producing and consuming from what destinations.
> 
> http://activemq.org/site/how-can-i-monitor-activemq.html
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context: http://www.nabble.com/Topic-In-Visual-C%2B%2B%2CWho-can-help-me--tf2606196.html#a7288600
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Topic In Visual C++,Who can help me?

Posted by sgliu <sh...@sina.com>.
http://www.activemq.com/site/activemq-c-clients.html
Above sample,I want finish durable subscription.I don't konw how about
modification.
I change createQueue() to createTopic(),but only archieve non-durable
subscription.
If I change main function to follow three function,I will receive nothing.
  void Produce() 
 { 
     HelloWorldProducer producer( 5 ); 
     Thread producerThread( &producer ); 
     producerThread.start(); 
     producerThread.join(); 
 } 
 void Consumer() 
 { 
      HelloWorldConsumer consumer( 3000 ); 
      Thread consumerThread( &consumer ); 
      consumerThread.start(); 
      consumerThread.join(); 
 } 
 int main(int argc, char* argv[]) 
 { 
      Produce(); 
      Consumer(); 
 }
How can I do?

-- 
View this message in context: http://www.nabble.com/Topic-In-Visual-C%2B%2B%2CWho-can-help-me--tf2606196.html#a7311736
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Topic In Visual C++,Who can help me?

Posted by sgliu <sh...@sina.com>.
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 <sh...@sina.com> 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.


Re: Topic In Visual C++,Who can help me?

Posted by Nathan Mittler <na...@gmail.com>.
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 <sh...@sina.com> 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.
>
>

RE: Topic In Visual C++,Who can help me?

Posted by sgliu <sh...@sina.com>.
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.


RE: Topic In Visual C++,Who can help me?

Posted by Timothy Bish <ta...@twcny.rr.com>.
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.

> -----Original Message-----
> From: sgliu [mailto:shengguo@sina.com]
> Sent: Saturday, November 11, 2006 3:20 AM
> To: activemq-users@geronimo.apache.org
> Subject: Re: Topic In Visual C++,Who can help me?
> Importance: High
> 
> 
> From JDK's console,I saw the number of EnqueueCout would add one,if I ran
> my
> program once.But DequeueCount and QueueSize always is zero.
> and my program received nothing.
> ???
> How should  I receive Message ? What function?
> 
> 
> 
> James.Strachan wrote:
> >
> > On 11/10/06, sgliu <sh...@sina.com> wrote:
> >>
> >> but how create topic?
> >> Only change createQueue() to createTopic()?
> >
> > Yes
> >
> >> I try it,but not succeed.
> >
> > What happens?
> >
> >> (can send ,but can not receive)
> >
> > Try looking in the JConsole or Web Console or the Visualisation Plugin
> > to see who's producing and consuming from what destinations.
> >
> > http://activemq.org/site/how-can-i-monitor-activemq.html
> > --
> >
> > James
> > -------
> > http://radio.weblogs.com/0112098/
> >
> >
> 
> --
> View this message in context: http://www.nabble.com/Topic-In-Visual-
> C%2B%2B%2CWho-can-help-me--tf2606196.html#a7290521
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Topic In Visual C++,Who can help me?

Posted by sgliu <sh...@sina.com>.
>From JDK's console,I saw the number of EnqueueCout would add one,if I ran my
program once.But DequeueCount and QueueSize always is zero.
and my program received nothing.
???
How should  I receive Message ? What function?



James.Strachan wrote:
> 
> On 11/10/06, sgliu <sh...@sina.com> wrote:
>>
>> but how create topic?
>> Only change createQueue() to createTopic()?
> 
> Yes
> 
>> I try it,but not succeed.
> 
> What happens?
> 
>> (can send ,but can not receive)
> 
> Try looking in the JConsole or Web Console or the Visualisation Plugin
> to see who's producing and consuming from what destinations.
> 
> http://activemq.org/site/how-can-i-monitor-activemq.html
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context: http://www.nabble.com/Topic-In-Visual-C%2B%2B%2CWho-can-help-me--tf2606196.html#a7290521
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Topic In Visual C++,Who can help me?

Posted by James Strachan <ja...@gmail.com>.
On 11/10/06, sgliu <sh...@sina.com> wrote:
>
> but how create topic?
> Only change createQueue() to createTopic()?

Yes

> I try it,but not succeed.

What happens?

> (can send ,but can not receive)

Try looking in the JConsole or Web Console or the Visualisation Plugin
to see who's producing and consuming from what destinations.

http://activemq.org/site/how-can-i-monitor-activemq.html
-- 

James
-------
http://radio.weblogs.com/0112098/

Re: Topic In Visual C++,Who can help me?

Posted by sgliu <sh...@sina.com>.
but how create topic?
Only change createQueue() to createTopic()?
I try it,but not succeed.(can send ,but can not receive)
How can I do?
--------------------------------------------------------------------------------------------------



James.Strachan wrote:
> 
> Just use the createTopic() method rather than createQueue()?
> 
> Browsing the CMS API might help
> http://incubator.apache.org/activemq/cms/html/
> 
> On 11/10/06, sgliu <sh...@sina.com> wrote:
>>
>> I want some code(can compile in visual C++), Can complete "topic", like
>> example shows CMS in action(http://www.activemq.org/site/cms.html).
>> I want create topic, not create queue,In Visual C++ 2005.
>> who can give me some code?
>> Help me...
>> --
>> View this message in context:
>> http://www.nabble.com/Topic-In-Visual-C%2B%2B%2CWho-can-help-me--tf2606196.html#a7272366
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context: http://www.nabble.com/Topic-In-Visual-C%2B%2B%2CWho-can-help-me--tf2606196.html#a7273821
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Topic In Visual C++,Who can help me?

Posted by James Strachan <ja...@gmail.com>.
Just use the createTopic() method rather than createQueue()?

Browsing the CMS API might help
http://incubator.apache.org/activemq/cms/html/

On 11/10/06, sgliu <sh...@sina.com> wrote:
>
> I want some code(can compile in visual C++), Can complete "topic", like
> example shows CMS in action(http://www.activemq.org/site/cms.html).
> I want create topic, not create queue,In Visual C++ 2005.
> who can give me some code?
> Help me...
> --
> View this message in context: http://www.nabble.com/Topic-In-Visual-C%2B%2B%2CWho-can-help-me--tf2606196.html#a7272366
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/