The AppDynamics .NET Agent automatically detects RabbitMQ backends based upon calls from instrumented tiers. RabbitMQ exit points are methods that publish or push messages to a queue. RabbitMQ entry points are methods that listen or poll for new messages in the queue.

.NET extends support for BasicPublish and BasicConsume in the RabbitMQ client >= 6.0.0.


If you are using NServiceBus over the RabbitMQ transport, see NServiceBus Backends for .NET.

Exit Points and Backend Naming

The agent discovers a RabbitMQ backend exit point when your application sends a message to the queue using the BasicPublish() method.

By default, the agent names the RabbitMQ backend for the exchange parameter of the BasicPublish() method.

For example:

model.BasicPublish("MyExchange", "", false, false,
    basicProperties, Encoding.UTF8.GetBytes(message));
CODE

In this case the agent names the queue MyExchange.
RabbitMQ Backend Name

You can refine the backend name to include some or all segments of the routing key. To configure RabbitMQ naming you must be familiar with your implementation RabbitMQ exchanges and routing keys. See RabbitMQ Exchanges and Exchange Types.

Refine backend naming

Register the rmqsegments node property. For instructions on how to set a node property, see App Agent Node Properties.

Name: rmqsegments
Description: "Configure RabbitMQ naming to include routing key segments."
Type: Integer
Value: <integer>
The routing key is a string. The agent treats dot-separated (".") substrings of the routing key as segments. Set the value to an integer that represents the number of routing key segments to include in the name.

In the following example the routing key is "abc.def.ghi". Set the rmqsegments value to "2" to name the queue "MyExchange.abc.def".

model.BasicPublish("MyExchange", "abc.def.ghi", false, false,
    basicProperties, Encoding.UTF8.GetBytes(message));
CODE

After you save the node property, the Controller sends the configuration to the agent. After some time the RabbitMQ backend shows up with the new name.
RabbitMQ Backend Name

Entry Points

The agent discovers RabbitMQ backend entry point when your application polls the queue. AppDynamics auto-detects RabbitMQ based upon the following patterns:

BasicGet Method

The agent detects the pattern below where the application periodically polls the message queue using the BasicGet() method. The call timing is limited to the time spent inside the while loop. The timer only starts when the BasicGet result returns a value at line 4. The timer ends when the next BasicGet executes. In this example, the application polls every five seconds, so the execution time equals the time in the if loop plus five seconds.

RabbitMQ Client before version 6.x: 

while (true)
{
       var result = channel.BasicGet("MyExchange", true);
       if (result != null)
       {
                 var body = result.Body;
                 var message = Encoding.UTF8.GetString(body);
                 Console.WriteLine("Received: {0}.", message);
       }

       Thread.Sleep(5000);
}
CODE

RabbitMQ Client version 6.x: 

while (true)
{
       var result = channel.BasicGet("MyExchange", true);
       if (result != null)
       {
                 var body = result.Body.ToArray()
                 var message = Encoding.UTF8.GetString(body);
                 Console.WriteLine("Received: {0}.", message);
       }

       Thread.Sleep(5000);
}
CODE

HandleBasicDeliver Method

The agent detects the HandleBasicDeliver() method for custom implementations of the IBasicConsumer interface. In this case, the call timing reflects the execution time for the HandleBasicDeliver method.