Giter Site home page Giter Site logo

cadyio / hangfire-ravendb Goto Github PK

View Code? Open in Web Editor NEW
18.0 11.0 34.0 7.28 MB

RavenDB job storage for Hangfire

Home Page: https://www.nuget.org/packages/Hangfire.Raven/

C# 100.00%
hangfire recurring-tasks c-sharp dotnet dotnet-core scheduled-jobs ravendb

hangfire-ravendb's Introduction

Hangfire RavenDB

Build Status

Platform Master
Windows Build status
Linux / OS X Travis CI Build Status

Overview

RavenDB job storage for Hangfire

Usage

This is how you connect to a ravendb server (local or remote)

GlobalConfiguration.Configuration.UseRavenStorage("connection_string", "database_name");

This is how you connect to an embedded ravendb instance

GlobalConfiguration.Configuration.UseEmbeddedRavenStorage();

To enqueue a background job you must have the following in the code somewhere at least once or the background job queue will not process

var client = new BackgroundJobServer();
\\then you can do this, which runs once
BackgroundJob.Enqueue(() => Console.WriteLine("Background Job: Hello, world!"));

Delayed tasks

Scheduled background jobs are being executed only after given amount of time.

BackgroundJob.Schedule(() => Console.WriteLine("Reliable!"), TimeSpan.FromDays(7));

Recurring tasks

Recurring jobs were never been simpler, just call the following method to perform any kind of recurring task using the CRON expressions.

RecurringJob.AddOrUpdate(() => Console.WriteLine("Transparent!"), Cron.Daily);

Continuations

Continuations allow you to define complex workflows by chaining multiple background jobs together.

var id = BackgroundJob.Enqueue(() => Console.WriteLine("Hello, "));
BackgroundJob.ContinueWith(id, () => Console.WriteLine("world!"));

License

Copyright ยฉ 2013-2014 Sergey Odinokov.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Known Bugs

Hangfire.Tests requires RavenDB.Client which requires .Net 4.5. Until RavenDB 4.0 is released, Hangfire.Tests cannot be included and run.

hangfire-ravendb's People

Contributors

andrewmarkley avatar austinwinstanley avatar derekdhaas avatar krivulcik avatar mjohnson0580 avatar patins1 avatar sigurbjorngudjonsson avatar

Stargazers

 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  avatar

hangfire-ravendb's Issues

Not working in ASP.Net applications

The latest version doesn't appear to be working in ASP.Net applications.

When making a call to BackgroundJob.Enqueue I am getting the following exception:

System.NullReferenceException
                      Message=Object reference not set to an instance of an object.
                      Source=Hangfire.Raven
                      StackTrace:
                           at Hangfire.Raven.RavenJsonMethodConverter.Read(Type type, Object value, JsonSerializer serializer)
                           at Hangfire.Raven.RavenJsonConverterBase`1.ReadJson(JsonReader reader, Type type, Object existingValue, JsonSerializer serializer)
                           at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 1771
                           at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 900
                           at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 2005

I believe this is due to Assembly.GetEntryAssembly() returning null on the following line:
https://github.com/cady-io/hangfire-ravendb/blob/c65b8b13143302424763c2d5d76eeed68a2e225c/src/Hangfire.Raven/RavenJsonConverters.cs#L90

The same error would also occur here:
https://github.com/cady-io/hangfire-ravendb/blob/c65b8b13143302424763c2d5d76eeed68a2e225c/src/Hangfire.Raven/RavenJsonConverters.cs#L107

Dashboard not working yet

using Hangfire;
using HangFire.Raven.Storage;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartupAttribute(typeof(HangfireServer.Startup))]
namespace HangfireServer
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
            GlobalConfiguration.Configuration.UseRavenStorage("http://localhost:8080", "hangfire");
            app.UseHangfireDashboard();
            app.UseHangfireServer();
        }
    }
}

image

Any ideas why? A database titled "hangfire" does exist and the ravendb server is running at http://localhost:8080.

RecurringJob.RemoveIfExists throws an object reference not set exception

Any attempt to use RecurringJob.RemoveIfExists with throw an object reference not set exception if the job id doesn't exist in the underlying RavenDb storage.

The exception originates in the Hangfire.Raven.RavenWriteOnlyTransaction.RemoveFromSet method.

This behaviour is not consistent with other Hangfire storage implementations, they will remove the job if it exists and won't throw an exception if it doesn't. See the documentation at the following link:

http://docs.hangfire.io/en/latest/background-methods/performing-recurrent-tasks.html

Requires rights to System database

When not using a connection string, the way the DocumentStore is constructed using the DefaultDatabase property requires read-access to the System database. In certain environments (like RavenHQ) that isn't granted โ€“ leading to an exception on start up.

I seems that constructing the URL for a specific database manually, f.ex. https://ravenserver/databases/foo and not setting DefaultDatabase avoids this problem.

Are there any drawbacks to this I'm not seeing atm.?

Embedded storage question

Why GlobalConfiguration.Configuration.UseEmbeddedRavenStorage() option is removed since 2.0 version? Is new way exist to configure it? In README this way is stayed. I am confused a little...

Up-to-date?

Good afternoon everyone,

I am currently developing a project in .NET Core 2.2 requiring to use Hangfire. As you already understood, we are also using a NoSQL database through RavenDB.

My question for this repository that seems pretty attracting is :

Is this up to date and ready to use with the current version of the following frameworks ?

  • Microsoft.AspNetCore v2.2.0 (.NET Core 2.2)
  • Hangfire v1.7.6
  • Hangfire.AspNetCore v1.7.6
  • RavenDB.Client v4.2.2

Cheers guys :D

Exception with fire and forget

Hello, I updated with the last version which seems to be supported in asp .net core

This is what I do:

GlobalConfiguration.Configuration.UseRavenStorage(ravenDBHost, "Hangfire");

var client = new BackgroundJobServer();
BackgroundJob.Enqueue(() => Console.WriteLine("Background Job: Hello, world!"));

I am getting an error such as this:

{Raven.Imports.Newtonsoft.Json.JsonSerializationException: Could not read value for property: Job ---> Raven.Imports.Newtonsoft.Json.JsonSerializationException: Could not read value for property:

at System.Reflection.TypeExtensions.GetMethod(Type type, String name)
at Hangfire.Raven.RavenJsonMethodConverter.Read(Type type, Object value, JsonSerializer serializer)
at Hangfire.Raven.RavenJsonConverterBase`1.ReadJson(JsonReader reader, Type type, Object existingValue, JsonSerializer serializer)
at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) in C:\Builds\RavenDB-3.5-RC\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 1769
at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) in C:\Builds\RavenDB-3.5-RC\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 900
at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) in C:\Builds\RavenDB-3.5-RC\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 2005

**Could not convert document RavenJobs/c80515fa-c78f-4f12-a39e-4e5e30ea1060 to entity of type Hangfire.Raven.Entities.RavenJob**

I see that there is new record in the RavenDB

Please assist.

Not accepting connection strings

I am unable to configure RavenStorage using a predefined connection string e.g. GlobalConfiguration.Configuration.UseRavenStorage("Hangfire"), where the connection string is defined like the following in the web.config:

<connectionStrings>
  <add name="Hangfire" connectionString="Url = http://localhost:8080;Database=Hangfire" />
</connectionStrings>

It appears that DefaultDatabase is being overwritten with null on the following line:
https://github.com/cady-io/hangfire-ravendb/blob/master/src/Hangfire.Raven/Repository.cs#L61

I don't believe the DefaultDatabase (or ApiKey) need to set explicitly here as these values are already defined in the connection string itself.

RavenDB dependency issue on full framework

I am trying to use hangfire.ravendb in a .net 4.6 project that also uses RavenDB. This is not possible due to a version conflict with RavenDB client. I am using the net45 version, while this library is using the netstandard1.3 version.

The netstandard1.3 dependency doesn't resolve due to difference in public key token (netstandard1.3's key is null). I've tried to get around this by manually loading the full version assembly using AppDomain.CurrentDomain.AssemblyResolve event but that didn't work either due to implementation differences between the assembly versions.

Could you provide a full framework version or workaround?

Doesn't work on full .NET Framework anymore (targets netcoreapp2.0)

Is there a specific reason for targetting netcoreapp2.0 instead of netstandard2.0 which, as I understand it, is recommended for libraries?

If not, it would be nice to switch to targetting netstandard2.0 since that is "implemented" in the full .NET Framework from version 4.6.1, enabling the same assembly to be used from both .NET Core and the full framework.

Production API Key configuration

How do I configure the connection string for production use with an API Key, the raven instance is located on another server so I'm using the secure API Key.

GlobalConfiguration.Configuration.UseRavenStorage("connection_string", "database_name");

The connection string contains Url at the start which causing the http/https exception. Of course I dropped the URL part but it comes with the api key and database name already.

Options from Raven are:

Connection String: "Url = http://localhost:8080; ApiKey = esting/cheeolfngotns; Database = Testing"
Direct Link: "http://localhost:8080/studio/index.html#api-key=testing/cheeolfngotns"

I've tried all sorts of variations to get it working but it errors with:

System.ObjectDisposedException: The document store has already been disposed and cannot be used
Object name: 'DocumentStore'.

This works fine localhost without the API key

Missing dlls in nuget 3.2.0 package

While invoking
services.AddHangfire(c => c.UseRavenStorage(ravenConfig.Url, ravenConfig.Database));
it complains of missing dlls like:

  • Raven.Abstractions (3.5.4)
  • Raven.Lightweight (3.5.4)

They are missing under package folder.
I'm using Raven.Client v4.1.4, seems like missing dlls are not included anymore neither of these packages.

Latest NuGet Package

Hello,

When you get a chance could you please publish the latest NuGet package.

Many thanks

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.