user2481240
user2481240

Reputation: 11

Can't call method "headers" on an undefined value at C:/Perl/site/lib/Net/Stomp. pm line 122

I am trying to send EMS message from Perl to queue running in the EMS server. I'm using STOMP module to connect to EMS queue for sending message. Here is my code -

JMSQUEUE.pl:

use Net::Stomp;
use Net::Stomp::Frame;
my $stomp = Net::Stomp->new( { hostname => 'localhost', port => '7222' } );
$stomp->connect( { login => 'admin', passcode => '' } );
$stomp->send( { destination => '/queue/pradeepexp', body => 'test message' } );
$stomp->disconnect;

and in my module - STOMP.PM:

sub connect {
    my ( $self, $conf ) = @_;

    my $frame =
      Net::Stomp::Frame->new( { command => 'CONNECT', headers => $conf } );
    $self->send_frame($frame);
    $frame = $self->receive_frame;

    # Setting initial values for session id, as given from
    # the stomp server
    $self->session_id( $frame->headers->{session} );
    $self->_connect_headers($conf);

    return $frame;
}

Any settings I need to do before calling connect?

Upvotes: 1

Views: 556

Answers (2)

Fabian
Fabian

Reputation: 31

I had the same problem with sending messages from Perl to ApacheMQ. (Perl + Net-Stomp-0.45 + apache-activemq-5.8)

It was just a little mistake. It is important to set the correct transportConnectors in this file harddisk\apache-activemq-5.8\conf\activemq.xml.

<transportConnectors>
   <transportConnector name="stomp" uri="stomp://localhost:61616"/>
</transportConnectors>

After that it works fine :D For more information: http://activemq.apache.org/stomp.html

Maybe there are similar files in EMS.

Upvotes: 3

mzedeler
mzedeler

Reputation: 4369

This happens because the Stomp library receives an invalid (or no) response from the message broker.

Try to telnet to the message broker and see if it speaks Stomp at all.

Upvotes: 0

Related Questions