Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queuing feature not working? #43

Closed
IonRobu opened this issue Sep 20, 2018 · 7 comments
Closed

Queuing feature not working? #43

IonRobu opened this issue Sep 20, 2018 · 7 comments

Comments

@IonRobu
Copy link

IonRobu commented Sep 20, 2018

I'm playing around queuing functionality a little bit, but no luck...
Steps:

  1. Cloned Coravel repository
  2. Add a Test console project, which reffers Coravel project
  3. The code from Test console:
class Program
	{
		static void Main(string[] args)
		{
			var serviceProvider = new ServiceCollection()
				.AddQueue()
				.BuildServiceProvider();
			var queue = serviceProvider.GetRequiredService<IQueue>();
			queue.QueueTask(() =>
			{
				Console.WriteLine("This was queued!");//not firing
			});

			queue.QueueAsyncTask(async () => {
				await Task.Delay(1000);
				Console.WriteLine("This was queued async!");//not firing
			});

			serviceProvider
				.ConfigureQueue()
				.OnError(e =>
				{
					Console.WriteLine(e.Message);//not firing
				});
			Console.ReadKey();
		}
	}

The queued tasks not firing. I put a breakpoint in QueuingHost:StartAsync method, where queuing timer seems to be started, but not firing. Did I miss something?

@jamesmh
Copy link
Owner

jamesmh commented Sep 20, 2018

I'll have a look and let you know :)

@IonRobu
Copy link
Author

IonRobu commented Sep 20, 2018

I also tried with scheduler:

serviceProvider.UseScheduler(scheduler =>
			{
				Action action = () =>
				{
					Console.WriteLine("Every minute during the week.");
				};
				scheduler.Schedule(action)
					.EveryMinute()
					.Weekday();
			});

and the same result: action not firing.

@jamesmh
Copy link
Owner

jamesmh commented Sep 20, 2018

I got it working - I'll have to put it up as a demo though

@IonRobu
Copy link
Author

IonRobu commented Sep 20, 2018

Great, so it was because of me :)
What is missing in my code sample?

@jamesmh
Copy link
Owner

jamesmh commented Sep 20, 2018

So you'll need to you the .NET Core Host Builder to get console apps to work. I created an example here.

If you're not familiar with the host builder you might want to start here.

You'll probably need to create a Hosted Service to do whatever you need. Or, using the web host builder you could make a really slim service that exposes a few endpoints to do whatever you need.

Let me know if things work out!

@jamesmh jamesmh closed this as completed Sep 20, 2018
@jamesmh
Copy link
Owner

jamesmh commented Sep 20, 2018

PS That's a quick and dirty example lol

@IonRobu
Copy link
Author

IonRobu commented Sep 20, 2018

I got it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants