You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by nmittal <nm...@rblt.com> on 2009/09/28 15:02:38 UTC

PERL/STOMP: Subscribe to multiple destinations

Hi All,
the following code snippet, leads me to believe that we can subscribe to
only one destination at a time...

my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port => '61613'
} );
$stomp->connect();
$stomp->subscribe(
      {   destination             => '/queue/testq',
          'ack'                   => 'client',
          'activemq.prefetchSize' => 1,
      }
  );

while (1) {
    my $frame = $stomp->receive_frame;
}

How can I subscribe to multiple destinations? do I have to do something like
this...

my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port => '61613'
} );
$stomp->connect();
$stomp->subscribe(
      {   destination             => '/queue/testq',
          'ack'                   => 'client',
          'activemq.prefetchSize' => 1,
      }
  );
my $stomp1 = Net::Stomp->new( { hostname => "192.168.42.30", port => '61613'
} );
$stomp1->connect();
$stomp1->subscribe(
      {   destination             => '/queue/testq2',
          'ack'                   => 'client',
          'activemq.prefetchSize' => 1,
      }
  );

while (1) {
    my $frame = $stomp->receive_frame || $stomp1->receive_frame;
}

or is there a more elegant way of doing this.

thanks for your help

-- 
View this message in context: http://www.nabble.com/PERL-STOMP%3A-Subscribe-to-multiple-destinations-tp25645168p25645168.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: PERL/STOMP: Subscribe to multiple destinations

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi,

you can use wildcards

http://activemq.apache.org/wildcards.html

Cheers
--
Dejan Bosanac

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Mon, Sep 28, 2009 at 3:02 PM, nmittal <nm...@rblt.com> wrote:

>
> Hi All,
> the following code snippet, leads me to believe that we can subscribe to
> only one destination at a time...
>
> my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port => '61613'
> } );
> $stomp->connect();
> $stomp->subscribe(
>      {   destination             => '/queue/testq',
>          'ack'                   => 'client',
>          'activemq.prefetchSize' => 1,
>      }
>  );
>
> while (1) {
>    my $frame = $stomp->receive_frame;
> }
>
> How can I subscribe to multiple destinations? do I have to do something
> like
> this...
>
> my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port => '61613'
> } );
> $stomp->connect();
> $stomp->subscribe(
>      {   destination             => '/queue/testq',
>          'ack'                   => 'client',
>          'activemq.prefetchSize' => 1,
>      }
>  );
> my $stomp1 = Net::Stomp->new( { hostname => "192.168.42.30", port =>
> '61613'
> } );
> $stomp1->connect();
> $stomp1->subscribe(
>      {   destination             => '/queue/testq2',
>          'ack'                   => 'client',
>          'activemq.prefetchSize' => 1,
>      }
>  );
>
> while (1) {
>    my $frame = $stomp->receive_frame || $stomp1->receive_frame;
> }
>
> or is there a more elegant way of doing this.
>
> thanks for your help
>
> --
> View this message in context:
> http://www.nabble.com/PERL-STOMP%3A-Subscribe-to-multiple-destinations-tp25645168p25645168.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>

Re: PERL/STOMP: Subscribe to multiple destinations

Posted by nmittal <nm...@rblt.com>.
Perfect this is what I was looking for. Thanks for your time.



Roger Hoover wrote:
> 
> You can do something like this....
> 
> my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port =>
> '61613'
> } );
> $stomp->connect();
> $stomp->subscribe(
>      {   destination             => '/queue/testq',
>          'ack'                   => 'client',
>          'activemq.prefetchSize' => 1,
>      }
>  );
> $stomp->subscribe(
>      {   destination             => '/queue/testq2',
>          'ack'                   => 'client',
>          'activemq.prefetchSize' => 1,
>      }
>  );
> 
> while (1) {
>    my $frame = $stomp->receive_frame;
>    # if $frame->headers->{'destination'} eq '/queue/testq'
>    #    handle testq message
>    # if $frame->headers->{'destination') eq '/queue/testq2'
>    #    handle testq2 message
> }
> 
> 
> On Mon, Sep 28, 2009 at 6:02 AM, nmittal <nm...@rblt.com> wrote:
> 
>>
>> Hi All,
>> the following code snippet, leads me to believe that we can subscribe to
>> only one destination at a time...
>>
>> my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port =>
>> '61613'
>> } );
>> $stomp->connect();
>> $stomp->subscribe(
>>      {   destination             => '/queue/testq',
>>          'ack'                   => 'client',
>>          'activemq.prefetchSize' => 1,
>>      }
>>  );
>>
>> while (1) {
>>    my $frame = $stomp->receive_frame;
>> }
>>
>> How can I subscribe to multiple destinations? do I have to do something
>> like
>> this...
>>
>> my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port =>
>> '61613'
>> } );
>> $stomp->connect();
>> $stomp->subscribe(
>>      {   destination             => '/queue/testq',
>>          'ack'                   => 'client',
>>          'activemq.prefetchSize' => 1,
>>      }
>>  );
>> my $stomp1 = Net::Stomp->new( { hostname => "192.168.42.30", port =>
>> '61613'
>> } );
>> $stomp1->connect();
>> $stomp1->subscribe(
>>      {   destination             => '/queue/testq2',
>>          'ack'                   => 'client',
>>          'activemq.prefetchSize' => 1,
>>      }
>>  );
>>
>> while (1) {
>>    my $frame = $stomp->receive_frame || $stomp1->receive_frame;
>> }
>>
>> or is there a more elegant way of doing this.
>>
>> thanks for your help
>>
>> --
>> View this message in context:
>> http://www.nabble.com/PERL-STOMP%3A-Subscribe-to-multiple-destinations-tp25645168p25645168.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/PERL-STOMP%3A-Subscribe-to-multiple-destinations-tp25645168p25704079.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: PERL/STOMP: Subscribe to multiple destinations

Posted by Roger Hoover <ro...@gmail.com>.
You can do something like this....

my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port => '61613'
} );
$stomp->connect();
$stomp->subscribe(
     {   destination             => '/queue/testq',
         'ack'                   => 'client',
         'activemq.prefetchSize' => 1,
     }
 );
$stomp->subscribe(
     {   destination             => '/queue/testq2',
         'ack'                   => 'client',
         'activemq.prefetchSize' => 1,
     }
 );

while (1) {
   my $frame = $stomp->receive_frame;
   # if $frame->headers->{'destination'} eq '/queue/testq'
   #    handle testq message
   # if $frame->headers->{'destination') eq '/queue/testq2'
   #    handle testq2 message
}


On Mon, Sep 28, 2009 at 6:02 AM, nmittal <nm...@rblt.com> wrote:

>
> Hi All,
> the following code snippet, leads me to believe that we can subscribe to
> only one destination at a time...
>
> my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port => '61613'
> } );
> $stomp->connect();
> $stomp->subscribe(
>      {   destination             => '/queue/testq',
>          'ack'                   => 'client',
>          'activemq.prefetchSize' => 1,
>      }
>  );
>
> while (1) {
>    my $frame = $stomp->receive_frame;
> }
>
> How can I subscribe to multiple destinations? do I have to do something
> like
> this...
>
> my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port => '61613'
> } );
> $stomp->connect();
> $stomp->subscribe(
>      {   destination             => '/queue/testq',
>          'ack'                   => 'client',
>          'activemq.prefetchSize' => 1,
>      }
>  );
> my $stomp1 = Net::Stomp->new( { hostname => "192.168.42.30", port =>
> '61613'
> } );
> $stomp1->connect();
> $stomp1->subscribe(
>      {   destination             => '/queue/testq2',
>          'ack'                   => 'client',
>          'activemq.prefetchSize' => 1,
>      }
>  );
>
> while (1) {
>    my $frame = $stomp->receive_frame || $stomp1->receive_frame;
> }
>
> or is there a more elegant way of doing this.
>
> thanks for your help
>
> --
> View this message in context:
> http://www.nabble.com/PERL-STOMP%3A-Subscribe-to-multiple-destinations-tp25645168p25645168.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>