-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#35) Return 'ISubscription' for Subscribe and Respond
- Loading branch information
par.dahlman
committed
Mar 19, 2016
1 parent
6c73ed5
commit 495dd70
Showing
8 changed files
with
91 additions
and
13 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
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,37 @@ | ||
using System; | ||
using RabbitMQ.Client; | ||
using RawRabbit.Consumer.Abstraction; | ||
|
||
namespace RawRabbit.Common | ||
{ | ||
public interface ISubscription : IDisposable | ||
{ | ||
string QueueName { get; } | ||
string ConsumerTag { get; } | ||
} | ||
|
||
public class Subscription : ISubscription | ||
{ | ||
public string QueueName { get; } | ||
public string ConsumerTag { get; } | ||
|
||
private readonly IRawConsumer _consumer; | ||
|
||
public Subscription(IRawConsumer consumer, string queueName) | ||
{ | ||
_consumer = consumer; | ||
var basicConsumer = consumer as DefaultBasicConsumer; | ||
if (basicConsumer == null) | ||
{ | ||
return; | ||
} | ||
QueueName = queueName; | ||
ConsumerTag = basicConsumer.ConsumerTag; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_consumer.Disconnect(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using RawRabbit.Common; | ||
using RawRabbit.Configuration.Respond; | ||
using RawRabbit.Context; | ||
|
||
namespace RawRabbit.Operations.Abstraction | ||
{ | ||
public interface IResponder<out TMessageContext> where TMessageContext : IMessageContext | ||
{ | ||
void RespondAsync<TRequest, TResponse>(Func<TRequest, TMessageContext, Task<TResponse>> onMessage, ResponderConfiguration cfg); | ||
ISubscription RespondAsync<TRequest, TResponse>(Func<TRequest, TMessageContext, Task<TResponse>> onMessage, ResponderConfiguration cfg); | ||
} | ||
} |
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,12 +1,13 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using RawRabbit.Common; | ||
using RawRabbit.Configuration.Subscribe; | ||
using RawRabbit.Context; | ||
|
||
namespace RawRabbit.Operations.Abstraction | ||
{ | ||
public interface ISubscriber<out TMessageContext> where TMessageContext : IMessageContext | ||
{ | ||
void SubscribeAsync<T>(Func<T, TMessageContext, Task> subscribeMethod, SubscriptionConfiguration config); | ||
ISubscription SubscribeAsync<T>(Func<T, TMessageContext, Task> subscribeMethod, SubscriptionConfiguration config); | ||
} | ||
} |
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