From: Tomas Doran Date: Thu, 30 Jul 2009 02:49:11 +0000 (+0100) Subject: Clean up X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Engine-STOMP.git;a=commitdiff_plain;h=6f80183adc19e35b6ceadfe7113114ac31c1deb9 Clean up --- diff --git a/lib/Catalyst/Engine/Stomp.pm b/lib/Catalyst/Engine/Stomp.pm index f2b588f..985cd3e 100644 --- a/lib/Catalyst/Engine/Stomp.pm +++ b/lib/Catalyst/Engine/Stomp.pm @@ -77,10 +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; - } + my $subscrine_headers = $template{subscribe_headers} || {}; + die("subscribe_headers config for Engine::Stomp must be a hashref!\n") + if (ref($subscribe_headers) ne 'HASH'); + $self->connection(Net::Stomp->new(\%template)); $self->connection->connect(); $self->conn_desc($template{hostname}.':'.$template{port}); @@ -88,20 +88,11 @@ sub run { # subscribe, with client ack. foreach my $queue (@queues) { my $queue_name = "/queue/$queue"; - my $header_hash = { + $self->connection->subscribe({ + %$subscribe_headers, 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...