I am using message broker example module ,in my case i am able to send the message , but no sure how it is being consumer or consumer is attached to it. When i run the message broker example module with out editing it gives me fatal error " Cannot use object of type Closure as array"
To make it work i replaced the code in hook_message_broker_consumers() with code in the documentation , though error are there but no consumer is created!
To directly call the hook_message_broker_consumers() i created a menu for it , it calls the function hook_message_broker_consumers() but nothing happens! also it won't even recognize the $self_name variable!
With the code mentioned in the documentation i having follow issues
'callback' => 'mymodule_handle_user_updates' doesn't call the function! and if i force call it using call_user_func() it gives me error function name must be a string for $ack()
function mymodule_message_broker_consumers($self_name) {
$consumers = array();
$consumers['user-synchronisation'] = array(
'queue' => 'user-updates',
'callback' => 'mymodule_handle_user_updates');
return $consumers;
}
function mymodule_handle_user_updates($message_body, $ack) {
$messageData = json_decode($message_body);
// Process message ...
// and ack it
$ack();
}
so i wonder how to create consumer and consume message
Comments
Comment #1
adityaj commentedComment #2
georgwaechter commentedHi,
your changes within the message_broker.api.php wont work because the file isnt event included for php processing. It is there only for documentation purposes as in most drupal modules.
Do you have enabled the message_broker_dummy module or the message_broker_amqp module?
You attach consumers by registering them via hook_message_broker_consumers and specifying a queue and callback. Via the json configuration you connect/bind your queues to exchanges. Please consult the documentation for rabbitmq if this is not clear.