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

adityaj’s picture

Assigned: adityaj » Unassigned
georgwaechter’s picture

Status: Active » Fixed

Hi,

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.

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.

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.