Coder Social home page Coder Social logo

ziyasal / disque.net Goto Github PK

View Code? Open in Web Editor NEW
56.0 10.0 18.0 563 KB

.Net library for the Disque distributed, in-memory message broker (i.e Redis as a job queue)

License: MIT License

C# 94.18% Shell 4.43% Dockerfile 1.39%
disque redis c-sharp job-queue

disque.net's Introduction

Disque.Net

A simple .Net client for the Disque in-memory distributed queue https://github.com/antirez/disque

Disque is ongoing experiment to build a distributed, in memory, message broker. Its goal is to capture the essence of the "Redis as a jobs queue" use case, which is usually implemented using blocking list operations, and move it into an ad-hoc, self-contained, scalable, and fault tolerant design, with simple to understand properties and guarantees, but still resembling Redis in terms of simplicity, performances, and implementation as a C non-blocking networked server.

Installation
NuGet - Disque.Net

Install-Package Disque.Net

List of supported methods

Ping

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string pong = q.Ping();

Info

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string info = q.Info();

Info by Section

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string info = q.Info("server");

AddJob

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string jobId = q.AddJob("myqueue", "message", 10);

AddJob with Parameters

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
JobParams jobParams = new JobParams
            {
                Replicate = 1,
                Retry = 10,
                Ttl = 20,
                Maxlen = 10,
                Delay = 10,
                Async = true
            };
string jobId = q.AddJob("myqueue", "message", 10, jobParams);

GetJob

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
List<Job> jobs = q.GetJob("myqueue");

GetJob with Parameters

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
List<Job> jobs = q.GetJob(100, 2, "myqueue");

AckJob

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string jobId = q.AddJob("myqueue", "message", 10);
long count = q.Ackjob(jobId);

Qlen

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
long qlen = q.Qlen("myqueue");

Qpeek

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
List<Job> jobs = q.Qpeek("myqueue", 2);

DelJob

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string jobId = q.AddJob("myqueue", "testJob", 10);
long count = q.DelJob(jobId);

Dequeue

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string jobId = q.AddJob("myqueue", "testJob", 10);
long count = q.Dequeue(jobId);

Enqueue

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string jobId = q.AddJob("myqueue", "testJob", 10);
long count = q.Enqueue(jobId);

Fastack

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string jobId = q.AddJob("fastack", "message", 10);
long count = q.Fastack(jobId);

Show

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
string jobId = q.AddJob("myqueue", "testJob", 10);
JobInfo info = q.Show(jobId);

Working

var q = new DisqueClient(new Uri("disque://192.168.59.103:7711"));
String jobId = q.AddJob("myqueue", "testJob", 10);
long secs = q.Working(jobId);

Bugs

If you encounter a bug, performance issue, or malfunction, please add an Issue with steps on how to reproduce the problem.

TODO

  • Async methods

License

Code and documentation are available according to the MIT License (see LICENSE)

disque.net's People

Contributors

aclemmensen avatar bugthesystem avatar darrenfang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

disque.net's Issues

GetJob with multiple queues does not work

q.GetJob(10, 10, "test_noexist", "test");

The test_noexist queue does not exist and therefore the expected output would be the next job from the test queue, but instead it just returns an empty list.

using telnet the following returns 10 jobs immediately
GETJOB TIMEOUT 10 COUNT 10 FROM unanalyzed_priority unanalyzed

Cannot access a closed Stream

how to fix this problem?

System.ObjectDisposedException: Cannot access a closed Stream.
at System.IO.__Error.StreamIsClosed()
at System.IO.BufferedStream.Write(Byte[] array, Int32 offset, Int32 count)
at CSRedis.Internal.RedisWriter.Write(RedisCommand command, Stream stream)
at CSRedis.Internal.RedisConnector.Call[T](RedisCommand1 command) at CSRedis.RedisClient.Write[T](RedisCommand1 command)
at Disque.Net.DisqueClient.AddJob(String queueName, String job, Int32 mstimeout)
at SGT.HOTW.DataInfo.AppLibs.DisqueUtility.AddJobToFds(Object data, String MemberFDS_Server)

using Common.Logging;
using Disque.Net;
using Newtonsoft.Json;
using StackExchange.Redis;
using System;

namespace TEST
{
	public class DisqueUnity
	{
		private DisqueClient _disqueClient = new DisqueClient(new Uri($"disque://127.0.0.1:7711"));


		public static DisqueUtility Instance { get; } = new DisqueUtility();

		
		public void AddJobToFds(dynamic data, string Member)
		{
			try
			{
				var jsondata = JsonConvert.SerializeObject(data);
				this._disqueClient.AddJob($"Group1", jsondata, 30000);  //issue point
			}
			catch (Exception ex)
			{
				this.log.Error($"Exception:{ex}");
			}
			
		}
	}
}

Crashes when acknowledging/dequeuing more than 1 job

Was trying to empty my queue as I was just testing some stuff.

var jobs = disque.GetJob(10, 1000, "test");
while (jobs.Count > 0)
{
	disque.Ackjob(jobs.Select(x => x.Id).ToArray());
	jobs = disque.GetJob(10, 1000, "test");
}

Throws:

An unhandled exception of type 'CSRedis.RedisException' occurred in csredis.dll
Additional information: BADID Invalid Job ID format.

Also crashes when I substituted 1000 for 2.

Support for .NET 4

I was downloaded the source code. It works fine with .NET 4. Could you please provide the package for .NET 4?

Thank you.

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.