Closed karimflaction closed 6 years ago
Hello @karimflaction,
All topology features needed to perform an operation (such as publish or subscribe) will be created when performing the operation. So, for your example, the exchange test_exchange
and test_queue
will be declared when a message of type BasicMessage
is subscribed to.
It looks like you are using version 1.10.x of the client, so you could look at the sample projects here: https://github.com/pardahlman/RawRabbit/tree/stable/sample. There is also documentation available here http://rawrabbit.readthedocs.io/en/master/Getting-started.html#messaging-pattern
Hope this helps!
Hello @pardahlman
Tank you for you answer ;) I had already read the documentation. I followed your example and I did this :
I have my configuration in the file .json but as you can see I have a problem, the method .SetBasePath and .AddJsonFile doesn't work.
Do you have an idea ?
Thank you
Oh I found this problem myself :)
But I have an another problem, when I start the application stop when I call the json file. I have this error :
_System.AggregateException occurred
HResult=0x80131500
Message=One or more errors occurred. (One or more errors occurred. (The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'test_queue_testrabbitmq_receiver' in vhost 'vhost': received 'false' but current is 'true'", classId=50, methodId=10, cause=))
Source=1 exceptions) at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken) at RawRabbit.Operations.Subscriber
1.SubscribeAsync[T](Func3 subscribeMethod, SubscriptionConfiguration config) at RawRabbit.Common.BaseBusClient
1.SubscribeAsync[T](Func3 subscribeMethod, Action
1 configuration)
at TestRabbitMq.Receiver.ConsoleAppRunner.
Inner Exception 1: AggregateException: One or more errors occurred. (The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'test_queue_testrabbitmq_receiver' in vhost 'vhost': received 'false' but current is 'true'", classId=50, methodId=10, cause=)
Inner Exception 2: OperationInterruptedException: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'test_queue_testrabbitmqreceiver' in vhost 'vhost': received 'false' but current is 'true'", classId=50, methodId=10, cause=
Can you help me ?
If you must have something to understand my problem i can give you all :)
Hello again,
Reading the exception closely it says: _"PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'test_queue_testrabbitmqreceiver' in vhost 'vhost': received 'false' but current is 'true'". This means that the queue test_queue_testrabbitmq_receiver
is already declared in the broker. If you are new to RabbitMQ I suggest that you take a look at the C# tutorial that explains some basic concepts.
Thank you for your help :)
I have a last question. I create my queue and I receive it, but it create a lot of connections and I don't understand why.
This is my code to receive :
But it create a lot of connections and channel like this :
How can I do to have one channel for a queue ? Thank you :)
It is difficult to answer that question based on your code snippet, is RabbitHelper
a wrapper class? I'm guessing that you are creating multiple instances of IBusClient
, which should be registered as a singleton if resolved from the factory.
Yes,
That is my class :
I change this :
I add the var test but it changed nothing
My BasiscMessage class
And my configuration in .json
What you are actually doing is setting up multiple subscriptions within your while-loop. If you want to perform multiple operations at the same time, have a look at these tests: https://github.com/pardahlman/RawRabbit/blob/2.0/test/RawRabbit.IntegrationTests/PublishAndSubscribe/MultipleOperationsTests.cs#L11
Note that the setup only does SubscribeAsync
once.
I test it like that:
But nothing :(
Yeah, so what I'm saying is: check how it is done in the tests I pointed to. If you have SubscribeAsync
within an infinite while loop, you are going to get multiple consumers.
Hello,
I'm doing a project and I don't know how create a queue... I know how receive a queue.
I tested this :
return BusClientFactory.CreateDefault( ioc => ioc.AddSingleton<IConfigurationEvaluator, AttributeConfigEvaluator>());
But I cannot specify my configuration if I do this
My configuration :
_config = new RawRabbitConfiguration { Username = "guest", Password = "guest", Port = 32780, VirtualHost = "vhost", Hostnames = { "rabbit-mq" } };
I have too a class with my queue :
[Queue(Name = "test_queue", Durable = false)] [Exchange(Name = "test_exchange", Type = RawRabbit.Configuration.Exchange.ExchangeType.Topic)] [Routing(RoutingKey = "test_key", NoAck = true)] public class BasicMessage { public string Message { get; set; } }
How can I create a queue and set a configuration ?
Somebody can help me ?
Thank you,