Send Message with IRequestReplyClient throwing Producer not started exception #512
-
Hi everyone, Here is an excerpt from startup: Could someone please point me in the right direction? Many Thanks for any help. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @juanmacrod, You don’t need to register additional producers to use the RequestReplyClient. The AddRequestReplyClient method is sufficient. To start the producer (and the consumer) used by the RequestReplyClient, you need to resolve the IActiveMqClient from your service provider and call StartAsync. Similarly, ensure you call StopAsync for a graceful shutdown. This is handled automatically if you’re using AddActiveMqHostedService. If the issue persists, consider providing a minimal reproducible example or a unit test so I can help investigate further. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hi,
Please take a look at this example:
https://havret.github.io/dotnet-activemq-artemis-client/docs/request-reply.
The key issue seems to be that you're not sending a response back to the
`ReplyTo` address. You need to acknowledge the incoming message and then
send the response to the specified `ReplyTo` address.
Everything you need is in the documentation, but if you need further
clarification, feel free to ask.
I hope this helps!
Havret
…On Sun, Nov 24, 2024 at 12:14 PM juanmacrod ***@***.***> wrote:
Hi @Havret <https://github.com/Havret>,
Thanks for the quick reply. The exception was caused because I think the
consumer was not running - at least, I don't see it anymore.
Unfortunately, when sending the message the process just hangs and doesn't
seem to call the consumer on the other service.
Here is my consumer startup:
``
services.AddActiveMq("artemis", endpoints)
.AddConsumer("OT_REQUEST", ActiveMQ.Artemis.Client.RoutingType.Anycast,
async (message, consumer, serviceProvider, CancelllationToken) =>
{
var request = JsonSerializer.Deserialize(message.GetBody());
Console.WriteLine("Request received: " + request);
var responseMessage = new ActiveMQ.Artemis.Client.Message(JsonSerializer.Serialize("Response to: " + request))
{
CorrelationId = message.CorrelationId
};
await consumer.AcceptAsync(responseMessage, null);
Console.WriteLine("Response sent: " + responseMessage.GetBody<string>());
});
services.AddActiveMqHostedService();
``
They should both be sending/receiving on the queue OT-REQUEST but
somethings seems not quite right with my queues:
image.png (view on web)
<https://github.com/user-attachments/assets/425b7b91-caa2-4478-a8ab-f8decad44a87>
The message in the OT-REQUEST queue has a reply-to of the temp queue
......63e which has a consumer bound.
Am I doing something fundamentally wrong?
—
Reply to this email directly, view it on GitHub
<#512 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACFOT5MDZ34GCEINCPBRX5L2CGYI7AVCNFSM6AAAAABSLAIIKOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMZWGI2TENA>
.
You are receiving this because you were mentioned.Message ID:
<Havret/dotnet-activemq-artemis-client/repo-discussions/512/comments/11362524
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
Hi,
my mistake!!!
I was calling consumer.ReceiveAsync without needing it because the message handler already had a reference to the incoming message.
With that call removed, It's working fine now.
Many Thanks for such a great project.