question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Implement an Auto Responder?

See original GitHub issue

Let me start by saying that I love the Auto Subscriber.

From what I can see in the wiki, the ā€œrespondā€ side of the request/response pattern appears very similar to the ā€œsubscribeā€ side of the publish/subscribe pattern (albeit, a little different; for example, thereā€™s no subscription ID).

publish/subscribe

bus.Subscribe<MyMessage>("my_subscription_id", msg => Console.WriteLine(msg.Text));

request/response

bus.Respond<MyRequest, MyResponse>(request => new MyResponse { Text = ā€œResponding to ā€œ + request.Text});

That said, I still donā€™t want to manually manage and wire up all of the ā€œrespondā€ handlers in my application. I figure we could provide an AutoResponder just like the AutoSubscriber.

Allow me to make some initial suggestions as to whatā€™s required. Iā€™m only just brushing up on the async and signature changes in the 4.0 release, so Iā€™ll spec only the async methods, but I might get them a bit wrong as I browse the latest changes!

AutoRespond.cs

namespace EasyNetQ.AutoRespond
{
    public class AutoResponder
    {
        protected readonly IBus bus;

        public AutoResponder(IBus bus);

        public IAutoResponderMessageDispatcher AutoResponderMessageDispatcher { get; set; }

        public virtual async Task<IDisposable> RespondAsync(Type[] responderTypes, CancellationToken cancellationToken = default)
    }
}

IAutoResponderMessageDispatcher.cs

namespace EasyNetQ.AutoRespond
{
    public interface IAutoResponderMessageDispatcher
    {
        TResponse Dispatch<TRequest, TResponse, TResponder>(TRequest request, CancellationToken cancellationToken = default)
            where TRequest : class
            where TResponse : class
            where TResponder : class, IRespond<TRequest, TResponse>;

        Task<TResponse> DispatchAsync<TRequest, TResponse, TResponder>(TRequest request, CancellationToken cancellationToken = default)
            where TRequest : class
            where TResponse : class
            where TResponder : class, IRespondAsync<TRequest, TResponse>;
    }
}

IRespond.cs

namespace EasyNetQ.AutoRespond
{
    public interface IRespond<TRequest, TResponse>
        where TRequest : class
        where TResponse : class
    {
        TResponse Respond(TRequest request, CancellationToken cancellationToken = default);
    }
}

IRespondAsync.cs

namespace EasyNetQ.AutoRespond
{
    public interface IRespondAsync<TRequest, TResponse>
        where TRequest : class
        where TResponse : class
    {
        Task<TResponse> RespondAsync(TRequest request, CancellationToken cancellationToken = default);
    }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
AnthonyMastreancommented, May 15, 2019

Obviously, let me know if this is something you even want. I canā€™t think of why you wouldnā€™t but, hey, itā€™s not my project šŸ¤—

Iā€™m getting the same feelings working through the send/receive patternā€¦

bus.Receive<MyMessage>("my.queue", message => Console.WriteLine("MyMessage: {0}", message.Text));

https://github.com/EasyNetQ/EasyNetQ/wiki/Send-Receive

Iā€™m actually implementing the ā€œautoā€ classes now in a private project. If they work out and youā€™re interested, after all, Iā€™ll send up a PR. To go a step further, if you want auto subscribe, respond, and receive and the impl. ends up looking goodā€¦ would you consider an even more generic ā€œauto wire allā€?

2reactions
AnthonyMastreancommented, Jun 14, 2019

OK! Iā€™m willing to tackle thisā€¦ I can start something under my own account, link it here, and see how it turns out? What do you think about the term ā€œAutoRegistrationā€ as an umbrella to cover all of the relevant messaging patterns?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Setup Email Autoresponders Tutorial
Click on Create to create the autoresponder. Autoresponder Example. Deleting Email Auto Responders. To delete an autoresponder, click on Delete next to itĀ ......
Read more >
Create an auto responder campaign
Create an auto responder campaign. Click Campaigns on the left menu, then click "Create a Campaign." On the next screen:.
Read more >
How To Write an Auto-Reply Email: 6 Examples
Auto -reply emails can acknowledge your customer and provide great follow-up information without adding additional burden to staff.
Read more >
How to Create an Auto Reply in Gmail + Examples for 2023
Before you can implement the auto response feature, you need to set up a message to act as your automatic response. Step 1....
Read more >
Set-up auto-reply (out of office)
Select File > Automatic Replies. Note: If you don't see the Automatic Replies button, follow the steps to use rules to send an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found