forked from MassTransit/MassTransit
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
257 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2007-2016 Chris Patterson, Dru Sellers, Travis Smith, et. al. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace MassTransit | ||
{ | ||
using System; | ||
|
||
|
||
[Serializable] | ||
public class JobNotFoundException : | ||
MassTransitException | ||
{ | ||
public JobNotFoundException() | ||
{ | ||
} | ||
|
||
public JobNotFoundException(string message) | ||
: base(message) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2007-2016 Chris Patterson, Dru Sellers, Travis Smith, et. al. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace MassTransit.Turnout | ||
{ | ||
using System.Threading.Tasks; | ||
using Contracts; | ||
|
||
|
||
/// <summary> | ||
/// The consumer that handles the control messages for the job | ||
/// </summary> | ||
public class CancelJobConsumer : | ||
IConsumer<CancelJob> | ||
|
||
{ | ||
readonly IJobRoster _roster; | ||
|
||
public CancelJobConsumer(IJobRoster roster) | ||
{ | ||
_roster = roster; | ||
} | ||
|
||
public async Task Consume(ConsumeContext<CancelJob> context) | ||
{ | ||
JobHandle jobHandle; | ||
if (!_roster.TryGetJob(context.Message.JobId, out jobHandle)) | ||
throw new JobNotFoundException($"The JobId {context.Message.JobId} was not found."); | ||
|
||
await jobHandle.Cancel().ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2007-2016 Chris Patterson, Dru Sellers, Travis Smith, et. al. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace MassTransit.Turnout.Contracts | ||
{ | ||
using System; | ||
|
||
|
||
public interface CancelJob | ||
{ | ||
/// <summary> | ||
/// The job identifier | ||
/// </summary> | ||
Guid JobId { get; } | ||
|
||
/// <summary> | ||
/// The time the job was started | ||
/// </summary> | ||
DateTime Timestamp { get; } | ||
|
||
/// <summary> | ||
/// The reason for cancelling the job | ||
/// </summary> | ||
string Reason { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2007-2016 Chris Patterson, Dru Sellers, Travis Smith, et. al. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace MassTransit.Turnout.Contracts | ||
{ | ||
using System; | ||
|
||
|
||
/// <summary> | ||
/// Published when a job faults | ||
/// </summary> | ||
/// <typeparam name="TInput"></typeparam> | ||
public interface JobCanceled<out TInput> : | ||
JobCanceled | ||
{ | ||
/// <summary> | ||
/// The job input | ||
/// </summary> | ||
TInput Input { get; } | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Published when a job faults | ||
/// </summary> | ||
public interface JobCanceled | ||
{ | ||
/// <summary> | ||
/// The job identifier | ||
/// </summary> | ||
Guid JobId { get; } | ||
|
||
/// <summary> | ||
/// The time the job was cancelled | ||
/// </summary> | ||
DateTime Timestamp { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2007-2016 Chris Patterson, Dru Sellers, Travis Smith, et. al. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace MassTransit.Turnout.Events | ||
{ | ||
using System; | ||
using Contracts; | ||
|
||
|
||
class Canceled<TInput> : | ||
JobCanceled<TInput> | ||
{ | ||
public Canceled(Guid jobId, TInput input) | ||
{ | ||
JobId = jobId; | ||
Input = input; | ||
Timestamp = DateTime.UtcNow; | ||
} | ||
|
||
public Guid JobId { get; } | ||
public DateTime Timestamp { get; } | ||
public TInput Input { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
// Copyright 2007-2016 Chris Patterson, Dru Sellers, Travis Smith, et. al. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace MassTransit.Turnout.Events | ||
{ | ||
using System; | ||
using Contracts; | ||
using MassTransit.Events; | ||
|
||
|
||
class Faulted : | ||
JobFaulted | ||
class Faulted<TInput> : | ||
JobFaulted<TInput> | ||
{ | ||
public Faulted(Guid jobId, Exception exception) | ||
public Faulted(Guid jobId, TInput input, Exception exception) | ||
{ | ||
JobId = jobId; | ||
Input = input; | ||
Timestamp = DateTime.UtcNow; | ||
Exceptions = new FaultExceptionInfo(exception); | ||
} | ||
|
||
public Guid JobId { get; } | ||
public DateTime Timestamp { get; } | ||
public ExceptionInfo Exceptions { get; } | ||
public TInput Input { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.