Created
February 1, 2017 15:26
-
-
Save icambridge/bd7334304dabc1fac3c6a1441a96a561 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
conn, err := amqp.DialConfig("XXXX", | |
amqp.Config{ | |
Heartbeat: time.Second, | |
Properties: amqp.Table{ | |
"connection.blocked" : false, | |
}, | |
}) | |
blockings := conn.NotifyBlocked(make(chan amqp.Blocking)) | |
go func() { | |
for b := range blockings { | |
if b.Active { | |
log.Infof("TCP blocked: %q", b.Reason) | |
} else { | |
log.Infof("TCP unblocked") | |
} | |
} | |
}() | |
if err != nil { | |
return nil, err | |
} | |
ch, err := conn.Channel() | |
if err != nil { | |
return nil, err | |
} | |
ch.Qos( | |
30, // prefetch count | |
0, // prefetch size | |
false, // global | |
) | |
msgs, err := ch.Consume( | |
"repositories", // queue | |
"", // consumer | |
false, // auto-ack | |
false, // exclusive | |
false, // no-local | |
false, // no-wait | |
nil, // args | |
) | |
// messages can be processed | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$connection = new \PhpAmqpLib\Connection\AMQPStreamConnection('xxxx', 5672, 'guest', 'guest'); | |
$channel = $connection->channel(); | |
$callback = function($msg) { | |
echo " [x] Received ", $msg->body, "\n"; | |
sleep(10); | |
}; | |
$channel->basic_qos(0, 1, false); | |
$channel->basic_consume('repositories', '', false, false, false, false, $callback); | |
while(count($channel->callbacks)) { | |
$channel->wait(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment