activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Casey <jamesc....@gmail.com>
Subject Re: PERL/STOMP: How to Request Response
Date Wed, 14 Oct 2009 07:48:39 GMT
Hi Dejan,

I've been looking in this area and think I see the problem.

When I create a consumer on a temp queue using STOMP, e.g.
/temp-queue/my-queue the broker creates an internal queue called, e.g.
/remote-temp-queue/ID:vtb-generic-51.cern.ch-58055-1255502987724-4:1:1

If I go and look via JMX I can find out what this temp queue is.

If I have a producer (separate process) that tries to send to
/temp-queue/my-queue nothing happens (I guess it creates another internal
queue in the broker) while if I send a message from the producer to
/remote-temp-queue/ID:vtb-generic-51.cern.ch-58055-1255502987724-4:1:1 the
message arrives fine at the consumer.

The problem is that my consumer doesn't know what the name of the actual
underlying queue is so it can't send it as a reply-to header.  How could
this be worked around in the STOMP protocol ?

James.

2009/9/8 Dejan Bosanac <dejan@nighttale.net>

> Hi Roger,
>
> I agree with you. I'm not sure if that's the problem, it was just my first
> guess looking at the code. Will take a look at it more closely and see if
> there's a problem on a broker side.
>
> 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 6:40 PM, Roger Hoover <roger.hoover@gmail.com>
> 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.
> > > >
> > > >
> > >
> >
>

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