How to call a controller of custom module when a node is published?
The purpose of controllers is just providing output for a route, not implementing hooks. If you need to write code that is invoked when a node is published, you need to implement one of the following hooks:


hook_ENTITY_TYPE_presave(), invoked right before the entity is saved
hook_ENTITY_TYPE_update() (invoked after an entity is updated and saved in the database) and hook_ENTITY_TYPE_insert() (invoked after an entity is created and saved in the database)


hook_node_presave(), hook_node_update(), and hook_node_insert() get a Node object as parameter, so obtaining the body value is pretty easy.

use Drupal\node\Entity\Node;

function mymodule_node_presave(Node $node) {
  $body = $node-&gt;get('body')-&gt;value;
  $summary = $node-&gt;get('body')-&gt;summary;
}


Getting the taxonomy term from a reference field of a node can be achieved with code similar to the following one.

use Drupal\node\Entity\Node;
use Drupal\taxonomy\Entity\Term;

function mymodule_node_presave(Node $node) {
  $term = Term::load($node-&gt;get('field_tags')-&gt;target_id);
}


To that, you need to add the code to verify the node has been published.

use Drupal\node\Entity\Node;
use Drupal\taxonomy\Entity\Term;

function mymodule_node_presave(Node $node) {
  if ($node-&gt;status()) {
    // The node has been published.
    $body = $node-&gt;get('body')-&gt;value;
    $summary = $node-&gt;get('body')-&gt;summary;
    $term = Term::load($node-&gt;get('field_tags')-&gt;target_id);
    $term_name = $term-&gt;getName();
  }
}


If the taxonomy reference field is not field_tags, replace field_tags with the right machine name of the field.