Qpid Proton client using an API not sending a message to the server

I am trying to write an AMQP 1.0 client using Qpid Proton in C. I do not want to use the messenger. I want to use proton-c engine. I have a little problem when we figure out how to do this. My main anchor point is setting the endpoint for the connection. The only C client example using the proton-c engine that I can find is here.

https://github.com/apache/qpid-proton/blob/master/examples/engine/c/psend.c

However, it uses structures that are not part of the Qpid Proton C API 0.12.0. In particular, I do not see pn_driver_t or pn_connector_t as part of API 0.12.0.

I am trying to perform the general workflow defined in the AMQP 1.0 specification 1) create a connection, 2) create a session, 3) create a sender link. I'm not very experienced with C, and this is my first time I used the non-Czech part of the Qpid Proton library, so forgive me if I missed something obvious. Here is my current code. I tried different options and looked for days.

#include <stdio.h> #include <unistd.h> #include <string.h> #include "proton/message.h" #include "proton/messenger.h" #include "proton/connection.h" #include "proton/session.h" #include "proton/link.h" #include "proton/delivery.h" #include "proton/event.h" #include "proton/engine.h" //State integer values are defined in Connection macros //https://qpid.apache.org/releases/qpid-proton-0.12.0/proton/c/api/group__connection.html void print_state(char * name, pn_state_t state) { printf("[%s] local: %i, remote: %i\n", name, PN_LOCAL_MASK & state, PN_REMOTE_MASK & state); } //Reference https://github.com/apache/qpid-proton/blob/master/examples/engine/c/psend.c void send_engine() { struct pn_connection_t * connection; connection = pn_connection(); //STACKOVERFLOW - I have a feeling this is not right, but cannot find an alternative to set protocol (amqp or ws) the hostname and port. I see a way to set the hostname only pn_connection_set_container(connection, "amqp://amqpserver:port"); print_state("Connection Initialized", pn_connection_state(connection)); pn_transport_t * transport; transport = pn_transport(); int r = pn_transport_bind(transport, connection); if (r != 0) { printf("transport bind error: %i\n", r); } pn_connection_open(connection); print_state("Connection Opened", pn_connection_state(connection)); pn_session_t * sess; sess = pn_session(connection); print_state("Session Initialized", pn_session_state(sess)); pn_session_open(sess); print_state("Session Opened", pn_session_state(sess)); pn_link_t * sender; sender = pn_sender(sess, "c-client"); //the queue name in "toserver" pn_terminus_set_address(pn_link_target(sender), "toserver"); print_state("Sender Link Initialized", pn_link_state(sender)); pn_link_open(sender); print_state("Sender Link Opened", pn_link_state(sender)); pn_delivery_t *delivery; char *tagID = "uid"; delivery = pn_delivery(sender, pn_dtag(tagID, strlen(tagID))); char *msg = "abc"; printf("%zd\n", pn_link_send(sender, msg, strlen(msg))); pn_delivery_settle(delivery); printf("Delivery stettled %d\n", pn_delivery_settled(delivery)); print_state("Connection End", pn_connection_state(connection)); print_state("Session End", pn_session_state(sess)); print_state("Sender Link End", pn_link_state(sender)); //TODO free everything } int main (int argc, char *argv[]) { send_engine(); printf("done\n"); return 0; } 

On my AMQP server, I have frame level tracking and can’t see the connection with the client. This is not a server problem. It works with many other clients, including the C client using the Messenger API. What am I missing in this example? Thanks!

Note. I tried to solve this exhaustively and provided as much context as possible.

+5
source share
1 answer

The driver API was removed in Apache Qpid Proton in version 0.9 in March 2015.

commit 4b53bfca06432e440c95d60648b5e7be54ae4296 Author: Rafael Schloming Date: Fri 13 Feb 08:27:23 2015 -0500

 removed driver API and bindings 

Proton C code examples are based on Messenger.

Many recent works have switched to the C ++ real platform, which is not based on Messenger. For more information see the release of documentation 0.12.1 .

+1
source

Source: https://habr.com/ru/post/1243717/


All Articles