0
votes

The documentation about Consumers says this MassTransit embraces The Hollywood Principle, which states, "Don't call us, we'll call you." But with Amazons SQS at least, that is not at all true. MassTransit does poll the Amazon SQS, but just hides that from a consumer app. I found this by looking at the SQS queue I had created => monitoring tab and checking at "Number Of Empty Receives". I found I had quickly racked up thousands of calls, far from ideal as they can be chargeable.

The AWS solution is to adjust the polling frequency of the queue with a property "Receive Message Wait Time", which means you have something called Long Polling. While I can manually set that up in AWS, I'd rather do that when I configure my consumer instead. The AWS SDK suggests an attribute called "ReceiveMessageWaitTimeSeconds" but I can't seem to set that. How can I set the polling frequency in MassTransit? I can see WaitTimeSeconds in a few places in the configuration but none of this documented at all.

After a bit of playing, this code seems to do what I want but I'm not sure it is correct. Is there a better way?

 var busControl = Bus.Factory.CreateUsingAmazonSqs(cfg =>
 {
  cfg.Host("eu-west-2", h =>
  {
    h.AccessKey("************");
    h.SecretKey("***SECRET***");
  });

  //Specify a SQS message queue name
  cfg.ReceiveEndpoint("my-queue", e =>
  {
     // create a consumer to read message from q
     e.Consumer<EventConsumer>();
     e.WaitTimeSeconds = 18;
     //etc
1

1 Answers

1
votes

You can set WaitTimeSeconds to a longer value to decrease the polling frequency. There is no push from SQS, it always consists of an API call.

As for the Hollywood principle, that's referring to MassTransit, not the transport interactions required by the broker.