You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by MattR <ma...@gmail.com> on 2019/10/11 14:47:53 UTC

Qpid Proton C++ open_sender vs open_receiver

Hi All,

I was hoping someone could explain the difference in what is going on behind
the scenes with Qpid Proton C++'s open_sender and open_receiver functions. I
am running into an issue with my class that is opening the sender and the
queue I am sending to not receiving messages. I have checked that when I
call the open_sender that a connection and channel (or "session" as I
understand it could be correlated with) are created, but no messages are
going through to the queue on send. When I qpid-stat I see that the queue
exists and it has consumers. However, if I add an open_receiver call
alongside my open_sender then the messages send just fine (qpid-stat
verifies this as well as on_tracker_accept is now getting called in my
code). Could someone explain what I might be missing or doing wrong so that
I do not require also calling open_receiver when I merely want to send
messages to my queue?

All responses are greatly appreciated.

- Matt R.



--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Qpid Proton C++ open_sender vs open_receiver

Posted by Robbie Gemmell <ro...@gmail.com>.
On Mon, 14 Oct 2019 at 19:58, MattR <ma...@gmail.com> wrote:
>
> Robbie Gemmell wrote
> > Calling open_sender will open a 'sender' link, and calling
> > open_receiver will create a 'receiver' link. The two are mostly
> > independent if you are simply sending to a queue, suggesting any
> > difference being seen from adding the latter would probably be some
> > interaction with the server configuration, other clients in use, etc.
>
> This was the basic jist I was getting from qpid.log, but wasn't sure there
> was something more worthwhile knowing about going on behind the scenes.
>
>
> Robbie Gemmell wrote
> > It seems likely your sender is either never being given any credit to
> > send
>
> I've verified I have credit on the sender before I try sending via
> on_sender_open.
>

Ok. FYI, you aren't guaranteed to have credit when on_sender_open is
called, as it arrives [if it does so at all] separately from the
sender attaching, which is why the examples use on_sendable to provoke
sending.

>
> Robbie Gemmell wrote
> > or actually the messages are being sent but just not accepted
> > (e.g instead released/modified/rejected) due to the particular setup.
>
> How could I verify this? I don't see anything in my qpid.log that shows the
> message is being received/rejected/released/modified.
>

Running your application with PN_TRACE_FRM=1 env variable would should
show you the protocol level trace. Youd see what is being generated to
send, and perhaps more importantly here what comes back the other way
etc.

>
> Robbie Gemmell wrote
> > Or it could just be an issue in your program, or the client. Its hard
> > to say much based on the limited info here.
>
> Totally fair. Here are the (subjectively) relevant code snippets where I'm
> actually trying to "do" something (just trying to do basic ssl setup and
> message send to get myself started).
>

A complete picture is far more useful in trying to ascertain where
issues may be, or even try running something like you are. E.g you
have a send method below, but no indication in the snippets exactly
when/how it is called, which could be the problem.
Isolated snippers aren't as helpful when the problem area isnt yet known.

> void on_container_start(proton::container &c) override {
>     if (!connected()) {
>         try {
>             cout << "inside on_container_start" << endl;
>             stringstream qpidURLBuilder;
>             qpidURLBuilder << "amqps://";
>             qpidURLBuilder << this->brokerURI;
>             qpidURLBuilder << ":";
>             qpidURLBuilder << this->portNumber;
>             string qpidURL = qpidURLBuilder.str();
>             connection_options connectionOptions;
>             cout << "setting ssl connectionOptions..." << endl;
>             string envCertPassword = "password";
>             string certName = "/home/mrich/guest.crt";
>             string certKey = "/home/mrich/guest.key";
>             string server_ca = "/home/mrich/root.crt";
>             ssl_certificate client_cert = ssl_certificate(certName,
>                    certKey, envCertPassword);
>             ssl_client_options ssl_cli(client_cert, server_ca,
> proton::ssl::VERIFY_PEER);
>             connectionOptions.sasl_allowed_mechs("EXTERNAL");
>             connectionOptions.ssl_client_options(ssl_cli);
>             cout << "preparing to connect to qpid..." << endl;
>             this->conn = c.connect(qpidURL, connectionOptions);
>         } catch (const std::exception& error) {
>             cerr << error.what() << endl;
>             cleanup();
>         }
>     }
> }
>
> void on_connection_open(proton::connection &c) override {
>     c.open_sender("external.dropbox");
>     //c.open_receiver("external.dropbox");
>     cout << "connection has been opened..." << endl;
>     this->isConnected = true;
> }
>
> int send() {
>     int messagesProcessed = 0;
>     if (!connected()) {
>         return -1;
>     }
>     string loc;
>     string header;
>     try {
>         while (this->sent < this->maxMessagesPerSend) {
>             message msg;
>             msg.durable(true);
>             msg.id(this->sent);
>             header="gobble-dee-goo" + to_string(this->sent);
>             msg.subject(header);
>             loc="blah-blah-blah";
>             msg.body(loc);
>             this->sndr.send(msg);
>             cout << "attempting to send message: " << fileHeader << endl;
>             messagesProcessed++;
>             this->sent++;
>             sleep(1);
>         }
>     } catch (const std::exception& error) {
>         cerr << error.what() << endl;
>         cleanup();
>     }
>     return messagesProcessed;
> }
>
> To reiterate my previous comment, when I use c.open_receiver in
> on_connection_open, the messages successfully go through. Without it,
> though, I don't see any sign the message is successfully sending.
>

I can see that your send method does a sleep. If you are calling the
method in the container thread as expected thats just going to block
the container thread and delay the underlying sends actually
happening, when the IO is processed seperately by it later. If you are
calling the method from another thread, thats likely to be the
problem.

My guess at the moment would be that adding the superfluous receiver
creation sparks extra network activity and processing (e.g its opening
attach arriving after the senders, and perhaps entirely seperately,
and possibly further activity by granting credit and causing a write,
and possibly even more through message transfers), masking an actual
issue in your program or the client.

> Also, I'm not sure if it adds anything regarding qpid configuration, but we
> are also using Qpid JMS and Proton Python. I've successfully got those
> working (connecting/sending/receiving/etc.), but Proton C++ is providing the
> most difficult to properly set up and consistently get working. This merely
> lends to the thought that my issue seems code related and not necessarily
> qpid configuration related. I could very well be off base, though.
>
> Thanks again,
>
> Matt R.
>
>
>
> --
> Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Qpid Proton C++ open_sender vs open_receiver

Posted by MattR <ma...@gmail.com>.
Robbie Gemmell wrote
> Calling open_sender will open a 'sender' link, and calling
> open_receiver will create a 'receiver' link. The two are mostly
> independent if you are simply sending to a queue, suggesting any
> difference being seen from adding the latter would probably be some
> interaction with the server configuration, other clients in use, etc.

This was the basic jist I was getting from qpid.log, but wasn't sure there
was something more worthwhile knowing about going on behind the scenes.


Robbie Gemmell wrote
> It seems likely your sender is either never being given any credit to
> send

I've verified I have credit on the sender before I try sending via
on_sender_open.


Robbie Gemmell wrote
> or actually the messages are being sent but just not accepted
> (e.g instead released/modified/rejected) due to the particular setup.

How could I verify this? I don't see anything in my qpid.log that shows the
message is being received/rejected/released/modified.


Robbie Gemmell wrote
> Or it could just be an issue in your program, or the client. Its hard
> to say much based on the limited info here.

Totally fair. Here are the (subjectively) relevant code snippets where I'm
actually trying to "do" something (just trying to do basic ssl setup and
message send to get myself started).

void on_container_start(proton::container &c) override {
    if (!connected()) {
        try {
            cout << "inside on_container_start" << endl;
            stringstream qpidURLBuilder;
            qpidURLBuilder << "amqps://";
            qpidURLBuilder << this->brokerURI;
            qpidURLBuilder << ":";
            qpidURLBuilder << this->portNumber;
            string qpidURL = qpidURLBuilder.str();
            connection_options connectionOptions;
            cout << "setting ssl connectionOptions..." << endl;
            string envCertPassword = "password";
            string certName = "/home/mrich/guest.crt";
            string certKey = "/home/mrich/guest.key";
            string server_ca = "/home/mrich/root.crt";
            ssl_certificate client_cert = ssl_certificate(certName,
                   certKey, envCertPassword);
            ssl_client_options ssl_cli(client_cert, server_ca,
proton::ssl::VERIFY_PEER);
            connectionOptions.sasl_allowed_mechs("EXTERNAL");
            connectionOptions.ssl_client_options(ssl_cli);
            cout << "preparing to connect to qpid..." << endl;
            this->conn = c.connect(qpidURL, connectionOptions);
        } catch (const std::exception& error) {
            cerr << error.what() << endl;
            cleanup();
        }
    }
}

void on_connection_open(proton::connection &c) override {
    c.open_sender("external.dropbox");
    //c.open_receiver("external.dropbox");
    cout << "connection has been opened..." << endl;
    this->isConnected = true;
}

int send() {
    int messagesProcessed = 0;
    if (!connected()) {
        return -1;
    }
    string loc;
    string header;
    try {
        while (this->sent < this->maxMessagesPerSend) {
            message msg;
            msg.durable(true);
            msg.id(this->sent);
            header="gobble-dee-goo" + to_string(this->sent);
            msg.subject(header);
            loc="blah-blah-blah";
            msg.body(loc);
            this->sndr.send(msg);
            cout << "attempting to send message: " << fileHeader << endl;
            messagesProcessed++;
            this->sent++;
            sleep(1);
        }
    } catch (const std::exception& error) {
        cerr << error.what() << endl;
        cleanup();
    }
    return messagesProcessed;
}

To reiterate my previous comment, when I use c.open_receiver in
on_connection_open, the messages successfully go through. Without it,
though, I don't see any sign the message is successfully sending.

Also, I'm not sure if it adds anything regarding qpid configuration, but we
are also using Qpid JMS and Proton Python. I've successfully got those
working (connecting/sending/receiving/etc.), but Proton C++ is providing the
most difficult to properly set up and consistently get working. This merely
lends to the thought that my issue seems code related and not necessarily
qpid configuration related. I could very well be off base, though.

Thanks again,

Matt R.



--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Qpid Proton C++ open_sender vs open_receiver

Posted by Robbie Gemmell <ro...@gmail.com>.
Calling open_sender will open a 'sender' link, and calling
open_receiver will create a 'receiver' link. The two are mostly
independent if you are simply sending to a queue, suggesting any
difference being seen from adding the latter would probably be some
interaction with the server configuration, other clients in use, etc.
It seems likely your sender is either never being given any credit to
send, or actually the messages are being sent but just not accepted
(e.g instead released/modified/rejected) due to the particular setup.
Or it could just be an issue in your program, or the client. Its hard
to say much based on the limited info here.

On Fri, 11 Oct 2019 at 15:47, MattR <ma...@gmail.com> wrote:
>
> Hi All,
>
> I was hoping someone could explain the difference in what is going on behind
> the scenes with Qpid Proton C++'s open_sender and open_receiver functions. I
> am running into an issue with my class that is opening the sender and the
> queue I am sending to not receiving messages. I have checked that when I
> call the open_sender that a connection and channel (or "session" as I
> understand it could be correlated with) are created, but no messages are
> going through to the queue on send. When I qpid-stat I see that the queue
> exists and it has consumers. However, if I add an open_receiver call
> alongside my open_sender then the messages send just fine (qpid-stat
> verifies this as well as on_tracker_accept is now getting called in my
> code). Could someone explain what I might be missing or doing wrong so that
> I do not require also calling open_receiver when I merely want to send
> messages to my queue?
>
> All responses are greatly appreciated.
>
> - Matt R.
>
>
>
> --
> Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org