File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change 2626 my  $result  = $channel -> declare_queue(exclusive  =>  1);
2727 my  $callback_queue  = $result -> {method_frame }-> {queue };
2828
29-  sub  on_response  {
30-  my  $var  = shift ;
31-  my  $body  = $var -> {body }-> {payload };
32-  if  ($corr_id  eq  $var -> {header }-> {correlation_id }) {
33-  $cv -> send ($body );
34-  }
29+  sub  on_response_cb  {
30+  my  %a  = (
31+  condvar  =>  undef ,
32+  correlation_id  =>  undef ,
33+  @_ 
34+  );
35+  return  sub  {
36+  my  $var  = shift ;
37+  my  $body  = $var -> {body }-> {payload };
38+  if  ($a {correlation_id } eq  $var -> {header }-> {correlation_id }) {
39+  $a {condvar }-> send ($body );
40+  }
41+  };
3542 }
3643
3744 $channel -> consume(
3845 no_ack  =>  1,
39-  on_consume  =>  \&on_response,
46+  on_consume  =>  on_response_cb(
47+  condvar  =>  $cv ,
48+  correlation_id  =>  $corr_id ,
49+  ),
4050 );
4151
4252 $channel -> publish(
5565my  $response  = fibonacci_rpc(30);
5666print  "  [.] Got $response \n " 
5767
68+ print  "  [x] Requesting fib(32)\n " 
69+ $response  = fibonacci_rpc(32);
70+ print  "  [.] Got $response \n " 
                         You can’t perform that action at this time. 
           
                  
0 commit comments