-
Notifications
You must be signed in to change notification settings - Fork 8
Rename Consumer Feature to Consumer SettleStrategy #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| // RabbitMQ AMQP 1.0 Go Client: https://github.com/rabbitmq/rabbitmq-amqp-go-client | ||
| // RabbitMQ AMQP 1.0 documentation: https://www.rabbitmq.com/docs/amqp | ||
| // The example is demonstrating how to implement a simple RPC echo server and client using RabbitMQ AMQP 1.0 Go Client. | ||
| // It uses DirectReplyTo for the client to receive responses without needing to declare a reply queue. | ||
| // DirectReplyTo is the recommended way to receive replies for RPC clients. | ||
| // The server listens for messages on a request queue and responds with the same message (echo). | ||
| // The client sends messages to the request queue and waits for the echoed response. | ||
| // The example also includes graceful shutdown handling when the user presses Ctrl+C. | ||
| // Example path:https://github.com/rabbitmq/rabbitmq-amqp-go-client/tree/main/docs/examples/rpc_echo_server/main.go | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
|
|
@@ -66,9 +76,11 @@ func main() { | |
|
|
||
| requester, err := clientConn.NewRequester(context.TODO(), &rabbitmqamqp.RequesterOptions{ | ||
| RequestQueueName: requestQueue, | ||
| // Enable Direct Reply To feature | ||
| // see: https://www.rabbitmq.com/direct-reply-to.html | ||
| DirectReplyTo: true, | ||
| // Use DirectReplyTo so replies are received via RabbitMQ direct-reply-to (no reply queue declared). | ||
| // See: https://www.rabbitmq.com/docs/direct-reply-to#overview | ||
| // That's the recommended way to receive replies for RPC clients, | ||
| // as it avoids the overhead of declaring and consuming from a reply queue. | ||
| SettleStrategy: rabbitmqamqp.DirectReplyTo, | ||
|
Comment on lines
+79
to
+83
|
||
| }) | ||
| if err != nil { | ||
| panic(err) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -276,7 +276,7 @@ func (a *AmqpConnection) NewRequester(ctx context.Context, options *RequesterOpt | |||||||||||||||||
|
|
||||||||||||||||||
| replyQueueName := options.ReplyToQueueName | ||||||||||||||||||
| queueName := "" | ||||||||||||||||||
| if !options.DirectReplyTo { | ||||||||||||||||||
| if options.SettleStrategy != DirectReplyTo { | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+279
to
280
|
||||||||||||||||||
| if options.SettleStrategy != DirectReplyTo { | |
| switch options.SettleStrategy { | |
| case DirectReplyTo: | |
| // No reply queue is declared when using DirectReplyTo. | |
| case PreSettled: | |
| // PreSettled is not a valid strategy for a requester that expects replies. | |
| return nil, fmt.Errorf("unsupported settle strategy for requester: %v", options.SettleStrategy) | |
| default: |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -123,9 +123,11 @@ type RequesterOptions struct { | |||||||||||||||||||
| // Optional. If not set, a default timeout of 30 seconds will be used. | ||||||||||||||||||||
| RequestTimeout time.Duration | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // If true, the requester will set the 'Direct-Reply-To' feature for RabbitMQ. | ||||||||||||||||||||
| // see: https://www.rabbitmq.com/direct-reply-to.html | ||||||||||||||||||||
| DirectReplyTo bool | ||||||||||||||||||||
| // SettleStrategy configures how the reply consumer receives messages. | ||||||||||||||||||||
| // Use ExplicitSettle for a dedicated reply queue (default). | ||||||||||||||||||||
| // Use DirectReplyTo to enable RabbitMQ direct-reply-to (no reply queue declared). | ||||||||||||||||||||
|
Comment on lines
+127
to
+128
|
||||||||||||||||||||
| // Use ExplicitSettle for a dedicated reply queue (default). | |
| // Use DirectReplyTo to enable RabbitMQ direct-reply-to (no reply queue declared). | |
| // | |
| // Supported values for requesters: | |
| // - ExplicitSettle (default): use a dedicated reply queue and explicitly settle replies | |
| // via Accept()/Requeue(). | |
| // - DirectReplyTo: enable RabbitMQ direct-reply-to (no reply queue declared). | |
| // | |
| // Note: PreSettled is not supported for requesters; replies are always explicitly settled. |
Uh oh!
There was an error while loading. Please reload this page.