[prev in list] [next in list] [prev in thread] [next in thread] 

List:       activemq-users
Subject:    Re: PERL/STOMP: Subscribe to multiple destinations
From:       Roger Hoover <roger.hoover () gmail ! com>
Date:       2009-09-28 16:05:25
Message-ID: 44cb1ba30909280905h7b1c90c3s5cd77b87585034b5 () mail ! gmail ! com
[Download RAW message or body]


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 <nmittal@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.
>
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic