Code Monkey home page Code Monkey logo

nuages-taskqueue's Introduction

Nuages.TaskQueue

Nuages.TaskQueue Nuages.TaskQueue Nuages.TaskQueue

example workflow

Nuages.TaskQueue bring Nuages.TaskRunner and Nuages.Queue together to offer a hosted task running service based on message from a queue.

It is available in two packages :

  • Nuages.TaskQueue.SQS for AWS Simple Queue Service (nuget | source)
  • Nuages.TaskQueue.ASQ for Azure Storage Queue (nuget | source)

How to use with SQS

Configuration

//Default SQS configuration
//You can provide your own implementation of IQueueClientProvider if you want to provide the instance using another way.
services.AddDefaultAWSOptions(configuration.GetAWSOptions())
        .AddAWSService<IAmazonSQS>();
        
services.AddSQSTaskQueueWorker(configuration);

appsettings.json

{
  "Queues":
  {
    "AutoCreateQueue" : true
  },
  "TaskQueueWorker" :
  {
    "QueueName" : "here-you-enter-your-queuename",
    "Enabled" : true,
    "MaxMessagesCount" : 1,
    "WaitDelayInMillisecondsWhenNoMessages": 2000
  },
  "AWS": {
    "Profile": null,
    "Region": null
  }
}

Alternatively, you may want to provide the value using the Configure method.

services.AddSQSTaskQueueWorker(configuration)
        .Configure<QueueOptions>(options =>
        {
            //set options here  
        }).Configure<QueueWorkerOptions>(options =>
        {
          //set options here  
        });
        

Push message to the queue

You can push message on the queue the way you want. The important thing here is that the queue message body can be deserialize as a RunnableTaskDefinition.

This is what it should look like.

{
  "AssemblyQualifiedName": "Nuages.TaskRunner.Tasks.OutputToConsoleTask, Nuages.TaskRunner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
  "Payload": { "Message" : "Started !!!!" }
}

A service is provided to help you push such a message from your code. You need to use ISQSQueueService for that.

var data = new OutputToConsoleTaskData { Message = message };
var taskData = RunnableTaskDefinitionCreator<OutputToConsoleTask>.Create(data);

//ISQSQueueService _isqsQueueService injected using DI
await _isqsQueueService.EnqueueTaskAsync("queue-name-goes-here", taskData);
        

Samples

nuages-taskqueue's People

Contributors

martin-masse avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.