File tree 1 file changed +20
-7
lines changed
1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change 26
26
my $result = $channel -> declare_queue(exclusive => 1);
27
27
my $callback_queue = $result -> {method_frame }-> {queue };
28
28
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
+ };
35
42
}
36
43
37
44
$channel -> consume(
38
45
no_ack => 1,
39
- on_consume => \&on_response,
46
+ on_consume => on_response_cb(
47
+ condvar => $cv ,
48
+ correlation_id => $corr_id ,
49
+ ),
40
50
);
41
51
42
52
$channel -> publish(
55
65
my $response = fibonacci_rpc(30);
56
66
print " [.] Got $response \n " ;
57
67
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