Reputation: 4174
I am new to Service Fabric.
We have a queue on Azure Service Bus. I want to continuously pull from the queue in my Service Fabric, process the message (execute some business logic) and save some data in the DB, then remove the message from the queue.
The Microservice should check the queue every couple of seconds to monitor for a new message.
My question is, What is the intended Microservice(s) that would pull data, process some business logic, then save to the DB. Is it A Stateless Service or a Reliable Actor
Upvotes: 2
Views: 2228
Reputation: 7285
Your problem space seems to fit the stateful or stateless model. Either one is fine depending on whether you need to maintain state or not.
As general guidance, consider the actor pattern to model your problem or scenario if:
Reference: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-actors-introduction
Upvotes: 1
Reputation: 11470
(Edit: interpreted question wrong earlier)
I'd say it's a matter of personal preference which model you choose.
You can have a stateless service running on all nodes, receiving messages and processing them on worker threads.
Actors are less able to singlehandedly process lots of messages because of the Single Entry model (limiting multi-threading options). But Actors can come in numbers. You can have many Actors listening for messages. You'd need to ensure those Actors become & stay alive though.
original answer:
This nuget package does this: https://www.nuget.org/packages/ServiceFabric.ServiceBus.Services It supports queues, topics, batching and sessions.
Upvotes: 3
Reputation: 21
You may use any. Stateless or Statefull. Is should not really matter. In my view, you can do below:
Once you have this, inside your service code, you may use StatefulService's "CreateServiceReplicaListeners" override or StatelessService's "CreateServiceInstanceListeners".
protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
{
return new[] { new ServiceReplicaListener(context => new ServiceBusCommunicationListener(context)) };
}
Upvotes: 0