Exemplo n.º 1
0
		public void TestPushJob()
		{
			ResqueClient q = ResqueClient.GetResque();

			//Create an Email Job
			ResqueObject email = new ResqueObject { Queue = "queue:email" };
			email.Job = new EmailJob { PK = 10 };
			email.JobType = email.Job.GetType();
			q.Push(email);

			//Create an Apple Push Notification
			ResqueObject apn = new ResqueObject { Queue = "queue:apn" };
			apn.Job = new APNJob { DeviceId = "sdfjkajsldfkjkl90823" };
			apn.JobType = apn.Job.GetType();

			q.Push(apn);

			////Create an Apple Push Notification
			//ResqueObject uaJob = new ResqueObject { Queue = "queue:apn" };
			//uaJob.Job = new UAPushJob { PleaseNo = "Does this work now?" };
			//uaJob.JobType = uaJob.Job.GetType();

			//q.Push(uaJob);



		}
Exemplo n.º 2
0
		public void TestExceptionJob()
		{
			ResqueClient q = ResqueClient.GetResque();

			//Create an Email Job
			ResqueObject exp = new ResqueObject { Queue = "queue:email" };
			exp.Job = new ExceptionThrowingJob { Desc = "Go boom boom" };
			exp.JobType = exp.Job.GetType();
			q.Push(exp);
		
		}
Exemplo n.º 3
0
		/// <summary>
		/// This allow you to override the queue field in the Resque Object
		/// Useful when a job fails and we need to put it in the error queue
		/// </summary>
		/// <param name="queueName"></param>
		/// <param name="item"></param>
		public void Push(string queueName, ResqueObject item)
		{
			using (RedisClient redisClient = Redis())
			{
				//Create a 'strongly-typed' API that makes all Redis Value operations to apply against Shippers
				WatchQueue(queueName);
				var jsv = TypeSerializer.SerializeToString(item);
				redisClient.PushItemToList(queueName, jsv);

			}

		}
Exemplo n.º 4
0
		public void TestDeserialization()
		{
			ResqueObject org = new ResqueObject { Queue = "testQueue"};

			org.Job = new EmailJob { PK=10 };
			org.JobType = org.Job.GetType();
			var jsv = TypeSerializer.SerializeToString(org);

			Console.WriteLine(jsv);
			

			var dynamicType = TypeSerializer.DeserializeFromString<ResqueObject>(jsv);

			var job = (IResqueJob)dynamicType.GetJob();

			Assert.AreEqual(typeof(EmailJob), job.GetType());

			job.Perform();


		
		}
Exemplo n.º 5
0
		private void WorkingOn(ResqueObject item)
		{ 
			//TODO: Add to redis, what this worker is working on. 
		}
Exemplo n.º 6
0
		public void PushToFailures(ResqueObject item)
		{
			Push("queue:failures", item);
		}
Exemplo n.º 7
0
		/// <summary>
		/// Pushes a job onto a queue. Queue name should be a string and the
		/// item should be any JSON-able POCO.
		/// </summary>
		/// <param name="queue"></param>
		/// <param name="?"></param>
		public void Push(ResqueObject item)
		{
			Push(item.Queue, item);
		}