activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roger Hoover <roger.hoo...@gmail.com>
Subject Re: PERL/STOMP: How to Request Response
Date Tue, 08 Sep 2009 18:07:38 GMT
Oh I see.  I didn't look at your example carefully enough.  Thanks!

On Tue, Sep 8, 2009 at 11:04 AM, nmittal <nmittal@rblt.com> wrote:

>
> Roger, single connection is needed only in one script. So the requester
> would
> have one connection and the responder would have another. I was using 2
> connections in the requester and that was breaking it. I think, temporary
> queues are tied to a single instance of the connection.
>
> thanks
> Nishant
>
>
> Roger Hoover wrote:
> >
> > Hi Dejan,
> >
> > I'm not seeing how this feature is useful if you have to have a single
> > connection.  Usually, the whole point of request/response, is to have the
> > request processed elsewhere by some other process (perhaps on another
> > machine) with it's own connection.  If it only works on the same
> > connection,
> > I don't see the point of using a queue to distribute the work.
> >
> > Please let me know if I'm missing something.  Thanks,
> >
> > Roger
> >
> > On Tue, Sep 8, 2009 at 6:54 AM, Dejan Bosanac <dejan@nighttale.net>
> wrote:
> >
> >> Hi Nishant,
> >>
> >> just committed a test case that shows that stomp works nice with temp
> >> destinations
> >>
> >> here it is
> >>
> >>    public void testTempDestination() throws Exception {
> >>
> >>        String frame = "CONNECT\n" + "login: system\n" + "passcode:
> >> manager\n\n" + Stomp.NULL;
> >>        stompConnection.sendFrame(frame);
> >>
> >>        frame = stompConnection.receiveFrame();
> >>        assertTrue(frame.startsWith("CONNECTED"));
> >>
> >>        frame = "SUBSCRIBE\n" + "destination:/temp-queue/" +
> >> getQueueName()
> >> + "\n" + "ack:auto\n\n" + Stomp.NULL;
> >>        stompConnection.sendFrame(frame);
> >>
> >>        frame = "SEND\n" + "destination:/temp-queue/" + getQueueName() +
> >> "\n\n" + "Hello World" + Stomp.NULL;
> >>        stompConnection.sendFrame(frame);
> >>
> >>        StompFrame message = stompConnection.receive(1000);
> >>        assertEquals("Hello World", message.getBody());
> >>    }
> >>
> >> Can you try using one connection in your client code for starters and
> see
> >> if
> >> it works.
> >>
> >> If you cannot make your stomp implementation to work with temp
> >> destinations,
> >> you can use regular queues and selectors as described in this thread
> >>
> >>
> http://www.nabble.com/Implement-request-response-with-JMS-over-Stomp-td24914033.html
> >>
> >> Cheers
> >> --
> >> Dejan Bosanac
> >>
> >> Open Source Integration - http://fusesource.com/
> >> ActiveMQ in Action - http://www.manning.com/snyder/
> >> Blog - http://www.nighttale.net
> >>
> >>
> >> On Tue, Sep 8, 2009 at 5:22 AM, nmittal <nmittal@rblt.com> wrote:
> >>
> >> >
> >> > Dejan, Thanks for your reply. I have been trying that... I am trying
> >> with
> >> 2
> >> > stomp connections, one that subscribes to '/temp-queue/tq' and one
> that
> >> > sends a message to /queue/Queue.Data with reply to as the above
> >> temp-queue.
> >> > my client code is below..
> >> >
> >> > my $stomp = Net::Stomp->new( { hostname => "192.168.42.30", port
=>
> >> '61613'
> >> > } );
> >> > $stomp->connect();
> >> >
> >> > my $stomp1 = Net::Stomp->new( { hostname => "192.168.42.30", port
=>
> >> > '61613'
> >> > } );
> >> > $stomp1->connect();
> >> > $stomp1->subscribe(
> >> >      {   destination             => '/temp-queue/tq',
> >> >          'ack'                   => 'auto',
> >> >          'activemq.prefetchSize' => 1,
> >> >      }
> >> >  );
> >> >
> >> > my %head;
> >> > $head{destination} = '/queue/Queue.Data';
> >> > $head{"reply-to"} = '/temp-queue/tq';
> >> >
> >> > my $frame = Net::Stomp::Frame->new(
> >> >       { command => "SEND", headers => \%head, body =>
> >> to_json(\%request)
> >> }
> >> > );
> >> >
> >> > $stomp->send_frame($frame);
> >> >
> >> > while (1) {
> >> >    my $frame1 = $stomp1->receive_frame;
> >> >    my $json1 = $frame1->body;
> >> >
> >> >    print "$json1\n";
> >> > }
> >> >
> >> > --------
> >> >
> >> > on the server, I subscribe to /queue/Queue.Data and send the reply
> back
> >> on
> >> > the destination that is in the reply-to header. please see server code
> >> > below...
> >> >
> >> > my $stomp = Net::Stomp->new( { hostname => $broker, port => '61613'
}
> >> );
> >> > $stomp->connect();
> >> > $stomp->subscribe(
> >> >      {   destination             => '/queue/Queue.Data',
> >> >          'ack'                   => 'client',
> >> >          'activemq.prefetchSize' => 1,
> >> >      }
> >> >  );
> >> >
> >> >
> >> > while (1) {
> >> >    my $frame = $stomp->receive_frame;
> >> >
> >> >    if (defined($frame->headers->{"reply-to"})) {
> >> >                my %head;
> >> >                $head{destination} = $frame->headers->{"reply-to"};
> >> >
> >> >                my $frame1= Net::Stomp::Frame->new(
> >> >               { command => "SEND", headers => \%head, body =>
"This is
> >> the
> >> > response from server" } );
> >> >
> >> >                $stomp->send_frame($frame1);
> >> >    }
> >> >
> >> >    $stomp->ack( { frame => $frame } );
> >> > }
> >> > $stomp->disconnect;
> >> >
> >> > --
> >> >
> >> > I see that the request is being sent and received but the reply never
> >> makes
> >> > it to the client. What am I doing wrong?
> >> >
> >> > thanks
> >> > Nishant
> >> >
> >> >
> >> >
> >> >
> >> > Dejan Bosanac wrote:
> >> > >
> >> > > Hi,
> >> > >
> >> > > use /temp-topic/ or /temp-queue/ prefixes (instead of /topic/ and
> >> > /queue/)
> >> > > for destination names and ActiveMQ will create temporary
> >> destinations.
> >> > >
> >> > > 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 7, 2009 at 3:45 AM, nmittal <nmittal@rblt.com> wrote:
> >> > >
> >> > >>
> >> > >> Hi, I am trying to implement request response with a Perl Client
> >> using
> >> > >> stomp.
> >> > >> the documentation on the ActiveMQ website has sample code in JAVA
> >> that
> >> > >> created a temporary destination and then sets the replyto header
to
> >> this
> >> > >> temp destination.
> >> > >> How can I create a temporary destination in Perl STOMP client.
I am
> >> > using
> >> > >> Net::Stomp.
> >> > >>
> >> > >> thanks for the help.
> >> > >>
> >> > >> Nishant
> >> > >> --
> >> > >> View this message in context:
> >> > >>
> >> >
> >>
> http://www.nabble.com/PERL-STOMP%3A-How-to-Request-Response-tp25323954p25323954.html
> >> > >> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >> > >>
> >> > >>
> >> > >
> >> > >
> >> > > -----
> >> > > Dejan Bosanac
> >> > >
> >> > > Open Source Integration - http://fusesource.com/
> >> > > ActiveMQ in Action - http://www.manning.com/snyder/
> >> > > Blog - http://www.nighttale.net
> >> > >
> >> >
> >> > --
> >> > View this message in context:
> >> >
> >>
> http://www.nabble.com/PERL-STOMP%3A-How-to-Request-Response-tp25323954p25339442.html
> >> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >> >
> >> >
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/PERL-STOMP%3A-How-to-Request-Response-tp25323954p25351243.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message