GithubHelp home page GithubHelp logo

easynetq / easynetq Goto Github PK

View Code? Open in Web Editor NEW
2.9K 2.9K 746.0 70.24 MB

An easy to use .NET API for RabbitMQ

Home Page: http://easynetq.com

License: MIT License

C# 100.00%
dotnet dotnet-core messaging rabbitmq

easynetq's Introduction

Build status

NuGet Status Nuget Status Nuget Status

Activity Activity Activity

EasyNetQ Logo

A Nice .NET API for RabbitMQ

Initial development was sponsored by travel industry experts 15below

Goals:

  1. To make working with RabbitMQ on .NET as easy as possible.

To connect to a RabbitMQ broker...

    var bus = RabbitHutch.CreateBus("host=localhost");

To publish a message...

    await bus.PubSub.PublishAsync(message);

To publish a message with 5s delay...

    await bus.Scheduler.FuturePublishAsync(message, TimeSpan.FromSeconds(5));

To subscribe to a message...

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

Remote procedure call...

    var request = new TestRequestMessage {Text = "Hello from the client! "};
    await bus.Rpc.RequestAsync<TestRequestMessage, TestResponseMessage>(request);

RPC server...

    await bus.Rpc.RespondAsync<TestRequestMessage, TestResponseMessage>(request =>
        new TestResponseMessage{ Text = request.Text + " all done!" }
    );

Getting started

Just open EasyNetQ.sln in VisualStudio or Rider and build. All the required dependencies for the solution file to build the software are included.

Contributors

Thanks to all the people who already contributed!

easynetq's People

Contributors

ar7z1 avatar bytenik avatar chinaboard avatar conniey avatar dependabot[bot] avatar dreisenberger avatar ericatwork avatar fhalim avatar fydon avatar jeffdoolittle avatar jhuntsman avatar micdenny avatar mikehadlow avatar mleenhardt avatar naveensrinivasan avatar philiphoy avatar pliner avatar pziezio avatar randomcodenz avatar redgoattea avatar robhruska avatar rotvig avatar samcook avatar stefansedich avatar sungam3r avatar tkirill avatar tynor88 avatar xpicio avatar yoplay70 avatar zidad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easynetq's Issues

Publishing with confirmation crashes

var report = new Report();
using (var bus = RabbitHutch.CreateBus("host=localhost;username=guest;password=guest", host))
{
using (var ch = bus.OpenPublishChannel(cc => cc.WithPublisherConfirms()))
{
while (true)
ch.Publish(report, cc => cc.OnSuccess(() => { }).OnFailure(() => { }));
}
}

after about 30-40k successfully published messages the following exception throws:

System.IndexOutOfRangeException was unhandled
HResult=-2146233080
Message=Index was outside the bounds of the array.
Source=mscorlib
StackTrace:
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at EasyNetQ.PublisherConfirms.RegisterCallbacks(IModel channel, Action successCallback, Action failureCallback) at EasyNetQ.RabbitAdvancedPublishChannel.Publish(IExchange exchange, String routingKey, MessageProperties properties, Byte[] messageBody, Action1 configure)
at EasyNetQ.RabbitAdvancedPublishChannel.Publish[T](IExchange exchange, String routingKey, IMessage1 message, Action1 configure)
at EasyNetQ.RabbitPublishChannel.Publish[T](T message, Action`1 configure)
at EasyNetQPublisher2.Program.Main() in d:\Projects\RabbitMqTests\Publisher\EasyNetQPublisher2\Program.cs:line 25
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

The bug is always reproduced.

Management API - Only For EastNetQ Messages?

Hi,

Just hooked up the management api to a broker that uses masstransit & rabbit.
I also tried a simple message i published manually from the rabbit web ui.

I'm assuming it has to do with the message format not being in the easynetq format.

Got the following error when trying to list messages:

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[EasyNetQ.Management.Client.Model.Property]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.

Path '[0].properties.message_id', line 1, position 139.

Enable support for other kinds MQs

Just curious how much work it would be to add support for other kinds of MQs (not necessarily by yourself!). Have to do some work with SonicMQ and their API is horrible. How tightly is EasyNetQ coupled to RabbitMQ?

(And please don't hesitate to close with wont-fix if this would be an enormous task and outside of your interests :-)

Something internally appears to be hung

If I change the code for the EasyNetQ.Tests.Performance.Producer to be the following:

        /*
        Console.CancelKeyPress += (source, cancelKeyPressArgs) =>
        {
            Console.Out.WriteLine("Shutting down");

            cancelled = true;
            while(publishThread.IsAlive) Thread.Sleep(10);

            messageRateTimer.Dispose();
            bus.Dispose();
            Console.WriteLine("Shut down complete");
        };

        Thread.Sleep(Timeout.Infinite);
         */
        cancelled = true;
        while ( publishThread.IsAlive ) Thread.Sleep( 10 );
        messageRateTimer.Dispose();
        bus.Dispose();
        Console.WriteLine( "Shut down complete" );

The program will never exit. Any thoughts? I'm getting similar results just using the latest version of the Rabbit Client from NuGet, and the latest version of your library.

Thanks.

EasyNetQ Modules / message interceptors

provide a pipeline where messages can be intercepted and altered before passing onto the next state. This could provide functions like serialization, encryption, de-duplication etc.

Saga persistence

Hi Mike

Just wondering, are you persisting your saga data anywhere in your projects? If yes what do you use for this?

Thanks

EasyNetQ vs. Spring.Net AMQP Template?

Hi Mike,

This is not issue. I wanted to contact you so, thought to do from here!

I would like to hear your thoughts on EasyNetQ vs. Spring.Net AMQP Template.

We are a Spring shop and we are evaluating the choices either EasyNetQ or Spring.Net AMQP Template.

I was wondering it will be great if you can share your thoughts!

Looking forward to hear from you.

Thanks,
Rasheed
[email protected]

RabbitAdvancedPublishChannel.Dispose

Hi,

thanks for your great libary.
I have a Problem with the Class RabbitAdvancedPublishChannel.

I don't know where i came from, all other calls work perfect.

If i debug the code, the system hangs at Dispose()

public virtual void Dispose() { if (disposed) return; channel.Abort(); //Here hangs the app channel.Dispose(); disposed = true; }

the calling name is in a contructor with MEF Injection
using (var x = m_bus.OpenPublishChannel()) { x.Publish<TapiRefreshCommand>(new TapiRefreshCommand()); }

Create queue needs to catch exception

Hi Mike,

i've had an issue when changing queue parameters like args or
autodelete etc
If the queue already exists with other parameter upon using
"Queue.DeclareDurable" etc, no exception is thrown
when subscribing.
EasynetQ just pretends that it has successfully subscribed to that
queue.

IMO TopologyBuilder.CreateQueue(...) needs to handle exceptions to
make sure the queue is created properly.

Best regards,
Andreas

Active/Active Mirror - Try to reconnect when publishing

Currently when trying to publish a message you check to see if the connection is still valid (Inside RawPublish). If the node has gone down an exception is thrown upto the client. When we have an Active\Actice mirrored cluster all that is required is to reconnect again to a different Active node in the cluster. EasyNet should handle this seamlessly.

PublisherConfirms: fail open confirmations when connection drops

Hi,

Did a small test when publishing large amounts of messages using publisher confirms. When connections drop and are re-established we miss some messages in our receiving queue. I suspect that a number of these messages are not acknowledged, nor failed. It would be great if all these pending confirmations could be failed by EasyNetQ when the channel drops.

Fair work queueing

Hi Mike,

I am doing some work where pieces of work are long and vary greatly in size.

In EasyNetQ the prefetchCount is a constant (50).

In order to distribute the work fairly between subscribers I would love a way to set the prefetchCount to 1 as discussed in the fair dispatch section here: http://www.rabbitmq.com/tutorials/tutorial-two-python.html

I have created sample failing test that shows the problem: https://github.com/PicnicBasket/EasyNetQ/commit/225189d8ecf6dbc3cfedd6b99333e0db56799dbd
This test seems to fail most of the time.

If RabbitAdvancedBus.cs is changed to set the constant to 1:
private const int prefetchCount = 50;
then this test always passes.

  1. Would you be happy to see support for this added to EasyNetQ?
  2. Do you have any thoughts about how to expose this variable in the API?
    I had a couple of thoughts:
    a. Add an extra subscribe overload that requires it and accepts any value.
    b. Add a special subscribe method with an appropriate name (FairSubscribe?) that sets it to 1
    c. Maybe make this available through the AdvancedBus to avoid complicating the main API.

Happy to do all the work for this but wanted to check out your thoughts before putting together a pull request.

cheers
Andrew

Each publish causes a (sub?)-channel on rabbit server

Hello everybody,

I have the following situation: when publishing a message to rabbit server I can see that everytime a new channel will be created and never closed. I see the following when I look via the rabbit management plugin:
Channel:
192.168.20.10:4270:1
192.168.20.10:4270:2
192.168.20.10:4270:3
192.168.20.10:4270:4
192.168.20.10:4270:5
What's the meaning of the last number of each channel? The first is IP, then port and then ???
What is to do, to close these I call it 'sub'-channel?

Thanks in advance,
Micha

Loosely couple the versions of the dependencies

Hi Mike,

Thanks for the great abstraction on RabbitMQ! Testing and the implementation is really easy.

Newtonsoft.Json uses 4.02 at the moment.. would be cool if you could loose this dependency to >= 4.02. Same thing applies for Rabbitmq.Client. They are tightly coupled to use a specific version which is a problem when you use a other project which also depends on Newtonsoft.Json.

I've been playing around with Nuget abit to make a new .nuspec and nuget restore, but I am not sure if everything will work since it's not my project :)

I can you send a pull request of what I got at the moment if you want.

Allow SubscribeAsync from AutoSubscriber

Quick hacky implementation below - I need a little help with the reflection-foo in GetSubscribeAsyncMethodOfBus(), and I'm not sure how robust this is for real-world use.

public class AsyncAutoSubscriber : AutoSubscriber
{
    public AsyncAutoSubscriber(IBus bus, string subscriptionIdPrefix) : base(bus, subscriptionIdPrefix)
    {
    }       
    /// <summary>
    /// Registers all consumers in passed assembly. The actual Subscriber instances is
    /// created using <seealso cref="CreateConsumer"/>. The SubscriptionId per consumer
    /// method is determined by <seealso cref="GenerateSubscriptionId"/> or if the method
    /// is marked with <see cref="ConsumerAttribute"/> with a custom SubscriptionId.
    /// </summary>
    /// <param name="assemblies">The assembleis to scan for consumers.</param>
    public virtual void SubscribeAsync(params Assembly[] assemblies)
    {
        SubscribeAsync(typeof(IConsume<>), assemblies);
    }

    /// <summary>
    /// Registers all consumers in passed assembly. The actual Subscriber instances is
    /// created using <seealso cref="CreateConsumer"/>. The SubscriptionId per consumer
    /// method is determined by <seealso cref="GenerateSubscriptionId"/> or if the method
    /// is marked with <see cref="ConsumerAttribute"/> with a custom SubscriptionId.
    /// </summary>
    /// <param name="markerType">The interface type used for defining a subscriber. Needs to have a method named 'Consume'.</param>
    /// <param name="assemblies">The assembleis to scan for consumers.</param>
    public virtual void SubscribeAsync(Type markerType, params Assembly[] assemblies)
    {
        if (markerType == null)
            throw new ArgumentNullException("markerType");

        if (!IsValidMarkerType(markerType))
            throw new ArgumentException(string.Format("Type '{0}' must be an interface and contain a '{1}' method.", markerType.Name, ConsumeMethodName), "markerType");

        if (assemblies == null || !assemblies.Any())
            throw new ArgumentException("No assemblies specified.", "assemblies");

        var genericBusSubscribeMethod = GetSubscribeAsyncMethodOfBus();
        var subscriptionInfos = GetSubscriptionInfos(markerType, assemblies.SelectMany(a => a.GetTypes()));

        foreach (var kv in subscriptionInfos)
        {
            foreach (var subscriptionInfo in kv.Value)
            {
                var dispatchMethod = MessageDispatcher.GetType()
                    .GetMethod(DispatchMethodName, BindingFlags.Instance | BindingFlags.Public)
                    .MakeGenericMethod(subscriptionInfo.MessageType, subscriptionInfo.ConcreteType);

                var dispatchMethodType = typeof(Action<>).MakeGenericType(subscriptionInfo.MessageType);
                var dispatchDelegate = Delegate.CreateDelegate(dispatchMethodType, MessageDispatcher, dispatchMethod);
                var subscriptionAttribute = GetSubscriptionAttribute(subscriptionInfo);
                var subscriptionId = subscriptionAttribute != null
                                         ? subscriptionAttribute.SubscriptionId
                                         : GenerateSubscriptionId(subscriptionInfo);

                var busSubscribeMethod = genericBusSubscribeMethod.MakeGenericMethod(subscriptionInfo.MessageType);

                var onMessage = new Func<object, Task>(e => Task.Factory.StartNew(() => dispatchDelegate.DynamicInvoke(e)));
                busSubscribeMethod.Invoke(bus, new object[] { subscriptionId,onMessage});
            }
        }
    }

    protected virtual MethodInfo GetSubscribeAsyncMethodOfBus()
    {
        //HACK HACK HACK likely to blow up at some point
        return bus.GetType().GetMethods()
            .Where(m => m.Name == "SubscribeAsync")
            .Select(m => new { Method = m, Params = m.GetParameters() })
            .Single(m => m.Params.Length == 2
                && m.Params[0].ParameterType == typeof(string)
                //&& m.Params[1].ParameterType.GetGenericTypeDefinition() == typeof(Func<>) //<-- not sure how to pull this off?
                ).Method;
    }
}

Issue I found in EasyNetQ with topic-based subscription

Hi Mike

Sorry to bug you but I wanted to start using EasyNetQ and was working on putting together a simple example to test publish/subscribe with topic based queues. I am not sure if I am doing something wrong or if I uncovered an issue so I wanted to check with you before I proceeded any further. I have attached my solutions for my publisher and subscriber and the message they use. I noticed that even when I specify a WithTopic that doesn't match the published message's WithTopic it still pulls the message off the queue.

i.e
Publisher:
channel.Publish(message, x => x.WithTopic("X.A"));

Subscriber:
bus.Subscribe("my_id", (msg) =>
Task.Factory.StartNew(() =>
{
Console.WriteLine("Message ID: {0}", msg.Id);
Console.WriteLine("Message Text: {0}", msg.Text);
}), x => x.WithTopic("B.C"));

In spite of the topics being different the message is still dequeued. I thought the point of the topic based queues was to only dequeue messages where the topics matched the pattern.

The sample I attached has a basic example that demonstrates what I want to accomplish. I was also testing the advanced api but wanted to get the basic bus example working before I moved onto the advanced example.

I can't attach the sample app but I emailed it to you already.

Cheers
Aniket

Parser.cs throws a compile error on Mono

/home/michael/Projects/EasyNetQ/Source/EasyNetQ/Sprache/Parse.cs(430,58): error CS0266: Cannot implicitly convert type `Sprache.Parser<System.Collections.Generic.IEnumerable<T>>' to `Sprache.Parser<T>'. An explicit conversion exists (are you missing a cast?)
/home/michael/Projects/EasyNetQ/Source/EasyNetQ/Sprache/Parse.cs(430,58): error CS1662: Cannot convert `lambda expression' to delegate type `System.Func<System.Collections.Generic.IEnumerable<T>,Sprache.Parser<T>>' because some of the return types in the block are not implicitly convertible to the delegate return type

Probably not your top priority, but I might see if I can sort it out...

DefaultConsumerErrorStrategy should be open to extension

Our application relies on several queues for different purposes, and EasyNetQ has made the publishing/consuming job incredibly easier when compared with all the code we used to write when using the official RabbitMQ client. But, I think the default strategy for handling errors makes it harder to identify where an error came from when there are several queues in use, which is our case. I know I can write my own error handling strategy by implementing the IConsumerErrorStrategy interface and change that behavior, by it would be much easier just to subclass the DefaultConsumerErrorStrategy class and make use of the code that it's already implemented. But, that class isn't open to extension since most of its members are private. I'm not sure if that is by design. If it is, maybe the class should be marked as sealed, but if it isn't, it would be great if the class exposes more of its code.

Regards and congrats for developing such an amazing library.

Connection string is case sensitive.

I'm not certain this is an issue, but noticed that the parameters in the connection string are case sensitive. The first will connect to the correct virtual host. The second will result in a connection to '/'.

(1) host=myHost;virtualHost=myVirtualHost;username=guest;password=guest;
(2) host=myHost;virtualhost=myVirtualHost;username=guest;password=guest;

Is it wise to save the reuse the bus?

I am writing filesystemevents to RabbitMQ, sometimes I get 500 files dumped on the disk and I guess that creating a new bus all the time is a "slow" process.

Is a static lazy load pattern good or bad :-)

private static IBus _bus;
public static IBus Bus
{
get { return _bus ?? (_bus = RabbitHutch.CreateBus(CnnStr)); }
}

Signing assemblies

Hi,

We want to sign our solution assemblies, but that is not possible because EasyNetQ is not signed.
Is it possible to deliver a signed version of EasyNetQ in the near future?

TIA

Topic-based routing

Hi Mike,

I saw an answer of yours on SO yesterday that might be just what I'm looking for.

Would topic-based routing work for this scenario:

We have a process that runs on numerous hosts. I'd like to use EasyNetQ to perform remote-control of those processes. If topic-based routing does what I think the name implies, then I could create a 'topic' for each host within our network, so that host would respond to only messages intended for that specific host. Is this a reasonably accurate assumption?

If that is correct, how can I help with adding this feature? Do you have any specs written/doodled/on-a-post-it?

Best,

David

PS - Is this the best forum for discussing EasyNetQ?

PSS - If no one has mentioned it to you recently, using EasyNetQ (after screwing around extensively with NServiceBus and MassTransit) is pure joy!

PSSS - I put an example for RespondAsync into the wiki. If it's pure crap, feel free to strike it. (However, it's probably not pure crap, as that code structure seems to be working fine in a low-volume production scenario for us)

Method Not Found - RabbitMQ.Client.IModel.QueueDeclare - Client v2.6.1.0

A fairly simple implementation (so I thought) based on the examples in the current master.

            _hutch = RabbitHutch.CreateBus("host=localhost", new QueueLogger());
            _hutch.RespondAsync<SMSMessage, SMSMessageResponse>(HandleSMSRequest);

i've also tried (not that I think it would make much of a difference

            _hutch.Subscribe<SMSMessage>("consumer", message => HandleSMSRequest(message));

The classes SMSMessage and SMSMessageResponse are both in a separate assembly from where the bus is being created.

Upon execution i get

System.MissingMethodException
Method not found: 'System.String RabbitMQ.Client.IModel.QueueDeclare(System.String, Boolean, Boolean, Boolean, System.Collections.IDictionary)'.
at EasyNetQ.RabbitBus.DeclareRequestResponseStructure(IModel channel, String requestTypeName)
at EasyNetQ.RabbitBus.<>c__DisplayClass132.<RespondAsync>b__10() in c:\Projects\EasyNetQ\EasyNetQ\RabbitBus.cs:line 352 at EasyNetQ.PersistentConnection.AddSubscriptionAction(Action subscriptionAction) in c:\Projects\EasyNetQ\EasyNetQ\PersistentConnection.c s:line 58 at EasyNetQ.RabbitBus.RespondAsync[TRequest,TResponse](Func2 responder) in c:\Projects\EasyNetQ\EasyNetQ\RabbitBus.cs:line 402

I am putting this down to an incompatibility with version 2.6.1.0 of RabbitMQ.Client. Do you have plans to support it?

Let me know if you need more information about my specific setup.

DC

Error messages cannot be published using the BinarySerializer

Steps to reproduce:

  1. Send to a queue a json serialized message.
  2. Consume this message with the BinarySerializer.
  3. It fails (as expected).
  4. The bug: EasyNetQ is not able to publish an error message into its default error queue using the BinarySerializer:

ERROR: EasyNetQ Consumer Error Handler: Failed to publish error message
Exception is:
System.Runtime.Serialization.SerializationException: Type 'EasyNetQ.SystemMessag
es.Error' in Assembly 'EasyNetQ, Version=0.9.1.60, Culture=neutral, PublicKeyTok
en=null' is not marked as serializable.
at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMemb
ers(RuntimeType type)
at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type
type, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberI
nfo()
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSeriali
ze(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, S
erObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter
objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(O
bject obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerOb
jectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter obje
ctWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Obje
ct graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(S
tream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(S
tream serializationStream, Object graph)
at EasyNetQ.BinarySerializer.MessageToBytes[T](T message)
at EasyNetQ.DefaultConsumerErrorStrategy.CreateErrorMessage(BasicDeliverEvent
Args devliverArgs, Exception exception)
at EasyNetQ.DefaultConsumerErrorStrategy.HandleConsumerError(BasicDeliverEven
tArgs devliverArgs, Exception exception)

Can't set input arguments when creating queue

I'm trying to set some arguments when calling CreateQueue on the management API. The QueueInfo provides a InputArguments properties for this (I guess?), but I can't really set any arguments on it, being a list of the InputArgument type which don't contain any properties or methods.

Is this part missing from the API or am I doing something wrong here?

Re-creating subscribers fails after server restart with OperationInterruptedException exception

Hi, I am unsure if this is a bug, or if I am doing it wrong, but I cannot get re-create subscribers to work after a server restart. I am using the latest source, and a very simple test project containing 1 subscriber using AutoSubscribe. I posted this on the Google group yesterday, but my post was deleted. Why would that be?

DEBUG: Trying to connect
DEBUG: OnConnected event fired
DEBUG: Re-creating subscribers

ERROR: Re-creating subscribers failed: reason: 'The AMQP operation was interrupted: AMQP close-reason, initiated by Application, code=200, text="Goodbye", classId=0, methodId=0, cause='
RabbitMQ.Client.Exceptions.OperationInterruptedException: The AMQP operation was interrupted: AMQP close-reason, initiated by Application, code=200, text="Goodbye", classId=0, methodId=0, cause=
at RabbitMQ.Client.Impl.SimpleBlockingRpcContinuation.GetReply()
at RabbitMQ.Client.Impl.ModelBase.QueueDeclare(String queue, Boolean passive, Boolean durable, Boolean exclusive, Boolean autoDelete, IDictionary arguments)
at RabbitMQ.Client.Impl.ModelBase.QueueDeclare(String queue, Boolean durable, Boolean exclusive,
Boolean autoDelete, IDictionary arguments)
at EasyNetQ.Topology.TopologyBuilder.CreateQueue(String queueName, Boolean durable, Boolean exclu
sive, Boolean autoDelete, IDictionary`2 arguments) in c:\vs\MY_PROJECT\src\EasyNetQ\Source\EasyNetQ\Topology\TopologyBuilder.cs:line 31
at EasyNetQ.Topology.Queue.Visit(ITopologyVisitor visitor) in c:\vs\MY_PROJECT\src\EasyNetQ\Source\EasyNetQ\Topology\Queue.cs:line 111
at EasyNetQ.RabbitAdvancedBus.<>c__DisplayClass7.b__4() in c:\vs\MY_PROJECT\src\EasyNetQ\Source\EasyNetQ\RabbitAdvancedBus.cs:line 137
at EasyNetQ.RabbitAdvancedBus.OnConnected() in c:\vs\MY_PROJECT\src\EasyNetQ\Source\EasyNetQ\RabbitAdvancedBus.cs:line 214

INFO: Connected to RabbitMQ. Broker: 'localhost', Port: 5672, VHost: '/'

Time Critical Request Repsonse

Hi,

I'm try your library. Its very great. I like your style of Messaging.
I tried a little bit with Request Response and found a time critical point.

This is my code

        using (var bus = RabbitHutch.CreateBus("host=localhost", new EasyNetQ.Loggers.ConsoleLogger()))
        {
            var myRequest = new Messages.Telefon.CallRequest{ };
            using (var publishChannel = bus.OpenPublishChannel())
            {
                publishChannel.Request<CallRequest, CallResponse>(myRequest, response =>
                    DisplayData(myRequest, response));
            }
        }

the function DisplayData is only called if I put an break-point at the request line and stop in visual studio with F10 forward.

"EasyNetQ" prevents "RabbitMQ.Client" Nuget minor updates

The Nuget package references "RabbitMQ.Client" dependency with particular version (= 3.0.2.0).

The current version of "RabbitMQ.Client" is 3.0.4. The version number difference suggests it should be safe to update, but the NuGet package doesn't let me.

I wonder whether can be changed. For example, the dependency on "Newtonsoft.Json" is version (โ‰ฅ 4.5). So maybe the dependency can be the same for "RabbitMQ.Client". Maybe also add something like (< 3.1.0.0) if there is a worry about the possibility of a breaking change.

Request/Response: EasyNetQ does not ACK on cancelled task or when returning null

Testing the RPC of EasyNetQ, if you simple pass to the RespondAsync<MyRequest, MyResponse>(ConsumeAsync) this method:

    public async Task<MyResponse> ConsumeAsync(MyRequest request)
    {
        throw new TaskCanceledException();
    }

you will end-up with the message that is not ACK, and testing more deeper I found that is not only because there's no exception thrown, but because the Task.Result is null, in fact you can have the same behavior simply doing this:

bus.Respond<MyRequest, MyResponse>(request => (MyResponse)null);

I've also better understood the behavior of the async functionality, in practice the async it seems to simply catch the TaskCanceledException and OperationCanceledException and set the returning task status to canceled. If you remove the async keywork, the exception is normally re-thrown and the RespondAsync will intercept and move the message to the error queue.

So these exceptions will be caught by the async framework and the EasyNetQ doesn't send the message to the error queue and also doesn't ACK it, it simply do nothing:

    public async Task<CreateLiveMatchFromBetradarResponse> ConsumeAsync(CreateLiveMatchFromBetradarRequest request)
    {
        throw new TaskCanceledException();
    }

    public async Task<CreateLiveMatchFromBetradarResponse> ConsumeAsync(CreateLiveMatchFromBetradarRequest request)
    {
        throw new OperationCanceledException();
    }

Instead if you throw an ApplicationException, is normally propagated and the EasyNetQ catch it, ACK the message and send it to the error queue:

    public async Task<CreateLiveMatchFromBetradarResponse> ConsumeAsync(CreateLiveMatchFromBetradarRequest request)
    {
        throw new ApplicationException();
    }

In any case if you remove the async keywork, the exception is propagated to EasyNetQ and then even if the operation is simple cancelled (for example by a timeout), the message is ACK and moved to the error queue, and if think this is the right approach.

In conclusion I think that the message should always be ACK after the task as completed, but then it should be moved to the errors queue if the task.Exception != null or task.IsCanceled, because a canceled task is a non-finished task and should be considered an error (think about timeouts)

Took from group discussion: https://groups.google.com/forum/#!topic/easynetq/DZSUD_H7IKo

Unable to specify a virtualHost other than "/"

Hello.

EasyNetQ is working for me with connection string like ""host=localhost;virtualHost=/" but I try to set the virtualhost to anything else I get an error when I try to open a publish channel telling me the broker is not connected.

Do I need to configure something in rabbitmq first? Are there any other steps?

Correlation Id set by client should not be overridden by EasyNetQ

public void Publish(IExchange exchange, string routingKey,
IMessage message)

sets message.Properties.CorrelationId =
advancedBus.GetCorrelationId();

and does not consider if CorrelationId was set manually.
IMO it should look something like that:

if (message.Properties.CorrelationId == "")
message.Properties.CorrelationId = advancedBus.GetCorrelationId();

bus.Publish<T> throws exception when setting immediate to true

Using similar code to this if I set immediate to true it throws an exception saying "Immediate is not implemented". Setting it to false seems to work.

public class EmailMessageQueue : IEmailMessageQueue
{
    private readonly IAdvancedBus bus;
    private readonly IExchange exchange;

    public EmailMessageQueue(IAdvancedBus bus)
    {
        this.bus = bus;

        var queue = bus.QueueDeclare("emailsubscriptionAdvanced");

        exchange = bus.ExchangeDeclare("myAdvancedExchange", ExchangeType.Direct);

        this.bus.Bind(exchange, queue, "#");
    }

    public void Send(Referee referee)
    {
        var message =
            new Message<MyMessage>(new MyMessage()
                {
                    EMailAddress = referee.EMailAddress,
                    FirstName = referee.FirstName,
                    LastName = referee.LastName
                });

        bus.Publish<MyMessage>(exchange, "#", true, true, message);
    }
}

What is the proper way to shot-down RabbitMQ?

What is the best way to stop/dispose a publisher or subscriber in a windows service or any other form of program.

I am using a asynchronous subscriber.

And congratulation on the new advanced API

Provide a way to register OnConnected events which allows avoiding race conditions cause by connection being established before a handler can be assigned.

Currently, a simple code like the following:

var bus = RabbitHutch.CreateBus(...);
bus.Connected += HandleBusConnected;

Will miss the first 'connected' event fired, because due to race condition, as soon as CreateBus returns, a new connection is made before a handler can be assigned to 'Connected' event.

It will be great if a 'connected' event handler could be specified to CreateBus(..) on a similar way as we can currently register other components like loggers, etc.

Alternative Ports

I know the RabbitMq .NET client supports alternative ports. Can EasyNetQ support alternative ports as well?

Does EasyNetQ support fanout

To put it short, can on exchange be bound to to queues? with EasyNetQ

I need to publish a fileevent to an exchange and then bind to queues to this exchange.

When consume message failed, could re-delivery the message automatically by easynetq?

Hi, our scenario is when received a message in subscribe, we want to save the message info to db, but some exeption happens during the saving progress, the easynetq's way to solve it is use hosepipe to re-submit the error message, but we want to re-publish the message automatically by easynetq just when the exeption happens, could we?

Or, is there any way that when consumer process the message successfully, return a successful tag to the broker then the broker delete the message from queue, but if the message are proccessed failed, return a failed tag to the broker and then the broker re-delivery the message to the consumer again until the message is sucessfully processed. Could we do like this by using easynetq?

Binding DestinationType is always null

Since "Merge branch 'camel_case_management_properties'" the DestinationType property of the Binding class does not work.

I think it is because the property name changed from "destination_type" to "DestinationType" and the underlying api still uses "destination_type" in the json.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.