Now that our microservice is reclaiming our memory as we intended, we need to stop and make sure that we have a basic understanding of how our communication mechanism between microservices is going to work. In order to connect and publish our message, we needed to dynamically ensure that both our exchange and queue have been created. We do this in our Subscribe method, as shown in the following code snippet:
public static void Subscribe()
{
Bus = RabbitHutch.CreateBus("host=localhost",
x => x.Register<IConventions, AttributeBasedConventions>());
Declare the exchange:
IExchange exchange = Bus.Advanced.ExchangeDeclare("EvolvedAI", ExchangeType.Topic);
Declare the queue:
IQueue queue = Bus.Advanced.QueueDeclare("Memory");
Bind the queue to the exchange for message delivery using the Bind function:
Bus.Advanced.Bind...