Skip to content
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

Adding a function to wait for publisher confirms #841

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

manchicken
Copy link

  • Also added an example program to demo it
  • Also removed a deprecated uninit function call from the ssl example

manchicken and others added 5 commits July 24, 2024 16:12
- Also added an example program to demo it
- Also removed a deprecated uninit function call from the ssl example
Correcting unused lvalue error.
Fixing more unused params issues
Correcting format.
@manchicken
Copy link
Author

I'm working on adding publisher confirms to the Net::AMQP::RabbitMQ Perl module, and this seemed like a bit of functionality I could add back upstream. Let me know if I missed anything, or if there's anything you'd like me to update.

The example isn't the most imaginative, I know, but it shows how to use the new function.

@manchicken manchicken force-pushed the adding-confirm-select-example branch from bd822a8 to 5fbeae2 Compare July 25, 2024 03:23
@manchicken
Copy link
Author

Apologies for all of the confusion and CI runs, I don't have a Windows test environment. I think I got all CI passing now.

@alanxz
Copy link
Owner

alanxz commented Jul 25, 2024

Approach LGTM.

Will do a pass on the actual implementation shortly.

@manchicken
Copy link
Author

Thanks! My C is a bit rusty, so feel free to point out anything I could improve there as well.

librabbitmq/amqp_api.c Outdated Show resolved Hide resolved
*/
AMQP_EXPORT
amqp_rpc_reply_t AMQP_CALL amqp_publisher_confirm_wait(
amqp_connection_state_t state, amqp_envelope_t *envelope,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you describe the intended purpose of the envelope parameter?

Seems like this may not be required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's the only thing that'll tell you which channel the ACK came through. The code for the amqp_basic_ack_t is correct per spec, naturally, but it can be helpful to know which channel the ACK came on.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you have any more questions or requests for change on this?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all you need is the channel id, then use amqp_channel_t* as an output parameter.

Alternatively consider using an amqp_channel_t as an input parameter, then only wait for the confirm on this channel.

include/rabbitmq-c/amqp.h Outdated Show resolved Hide resolved
@@ -95,7 +95,6 @@ int main(int argc, char const *const *argv) {
die_on_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS),
"Closing connection");
die_on_error(amqp_destroy_connection(conn), "Ending connection");
die_on_error(amqp_uninitialize_ssl_library(), "Uninitializing SSL library");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecation notices complaining when building examples.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please send me a separate PR for this change.

manchicken and others added 2 commits July 31, 2024 19:26
- Removing extra empty line
- Changing order of params so `in`s come before `out`s.
@manchicken
Copy link
Author

@alanxz Let me know if there's anything else you'd like to see changed here. I'd really like to get this into my Perl module, users have been asking for it for a long time.

@manchicken
Copy link
Author

@alanxz any updates?

* \returns amqp_rpc_reply_t *
*/
AMQP_EXPORT
amqp_rpc_reply_t AMQP_CALL amqp_publisher_confirm_wait(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking through this API a bit more we need to consider a couple different scenarios:

  1. What does this API do if the connection isn't in publisher-confirm mode? From an API-use perspective, it'd be helpful to return some kind of error if the connection isn't correctly configured.
  2. In publisher confirm mode, when a message is published the broker will return one of basic.ack, basic.nack, basic.reject (with channel.close and connection.close as options, but already handled). (see: https://github.com/alanxz/SimpleAmqpClient/blob/500b070465f7759f0bf984ff56b724c06df930ef/src/Channel.cpp#L837-L877). From API-use perspective, it'd be helpful if this function handled all 3 cases, likely this means: this function should have as an out parameter an amqp_method_number_t, and a void*, which is a library allocated version of one of the previously referenced methods.

@alanxz
Copy link
Owner

alanxz commented Sep 3, 2024

@alanxz any updates?

Apologies for the delay, life has been a bit busy lately.

@manchicken
Copy link
Author

Apologies for the delay, life has been a bit busy lately.

Don't I know it, friend. Good luck and solidarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants