From: Jason Tang Date: Thu, 23 Jul 2009 16:36:02 +0000 (+0100) Subject: + added bit more code so when you add additional header key/value pairs for X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Engine-STOMP.git;a=commitdiff_plain;h=d2057f6f0deab048111153a15213848b8b4e0bad + added bit more code so when you add additional header key/value pairs for subscribing ie transformation jms-object-json --- diff --git a/lib/Catalyst/Engine/Stomp.pm b/lib/Catalyst/Engine/Stomp.pm index 218702e..f2b588f 100644 --- a/lib/Catalyst/Engine/Stomp.pm +++ b/lib/Catalyst/Engine/Stomp.pm @@ -77,6 +77,10 @@ sub run { # connect up my %template = %{$app->config->{'Engine::Stomp'}}; + my $add_header = delete $template{subscribe_header}; + if (ref($add_header) ne 'HASH') { + $add_header = undef; + } $self->connection(Net::Stomp->new(\%template)); $self->connection->connect(); $self->conn_desc($template{hostname}.':'.$template{port}); @@ -84,10 +88,20 @@ sub run { # subscribe, with client ack. foreach my $queue (@queues) { my $queue_name = "/queue/$queue"; - $self->connection->subscribe({ - destination => $queue_name, - ack => 'client' - }); + my $header_hash = { + destination => $queue_name, + ack => 'client', + }; + + # add the additional headers - yes I know it overwrites but + # thats the dev's problem? + if (keys %{$add_header}) { + foreach my $key (keys %{$add_header}) { + $header_hash->{$key} = $add_header->{$key}; + } + } + + $self->connection->subscribe($header_hash); } # enter loop...