RE: [EXTERNAL]: Re: Python Proton Binding on Receiver for Broker

2022-04-28 Thread ONeil, Jerome
Hey Steve,

Thanks for the reply.  I’m pretty sure I’ve extracted that code a few times, 
too.  

I’d really like to do this all in Proton, though, for a couple reasons.  Using 
a single library is on the list somewhere, and it will run in a pretty 
restricted environment.   And also right up until now I kind of like the Proton 
API.   It is really concise, and who doesn’t love callbacks?

Best regards,

-J

From: Steve Huston 
Sent: Thursday, April 28, 2022 2:19 PM
To: users@qpid.apache.org
Subject: [EXTERNAL]: Re: Python Proton Binding on Receiver for Broker

Hi Jerome, You can do that with the Python QMF API. I extracted the below from 
another script so it may need some adjustments but should get you there. -Steve 
import os import sys from qpid import * import qpid.messaging host="localhost" 
port=5672 ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
Please use caution responding to this email or opening any attachments.
ZjQcmQRYFpfptBannerEnd

Hi Jerome,



You can do that with the Python QMF API. I extracted the below from another 
script so it may need some adjustments but should get you there.

-Steve



import os

import sys



from qpid import *

import qpid.messaging



host="localhost"

port=5672

sock = util.connect(host, port)

qmf_con = connection.Connection(sock)

qmf_con.start()

session = qmf_con.session(str(qpid.messaging.uuid4()), timeout=30)



session.queue_declare(queue="MyTopic")

session.exchange_bind(queue="MyTopic", exchange="whatever", 
binding_key="jerome.#")

session.sync

session.close(timeout=10)





On 4/28/22, 4:48 PM, "ONeil, Jerome" 
mailto:jerome.on...@wabtec.com>> wrote:



Hello,



I am trying to set up a receiver for a topic on a qpid C++ broker and need 
to control the binding between the Source exchange and the receiver queue.  I 
can get a simple receiver set up just fine and pull messages from it.



>>> event.container.create_receiver("amqp://localhost/MyTopic")



[jerome@localhost ~]$ qpid-config -r queues

Queue 'debug-MyTopic'

bind [#] => MyTopic





So that's grand.  I need to control the binding with more detail, though, 
and for the life of me I can't figure out how to do it.  I've tried controlling 
on the URL.  I've tried Filters and Selectors.  I have tried a variety of 
different link and receiver properties (x-bindings, etc..) and other methods 
scrapped up from the internet, and all I ever get for that binding is '#'.



Can someone provide a simple example?  Lets say I wanted that binding to 
actually be



bind [jerome.#] => MyTopic



What would that look like?  I am all out of clues and hope someone has one 
to spare.



Best regards,



-Jerome

This email and any attachments are only for use by the intended 
recipient(s) and may contain legally privileged, confidential, proprietary or 
otherwise private information. Any unauthorized use, reproduction, 
dissemination, distribution or other disclosure of the contents of this e-mail 
or its attachments is strictly prohibited. If you have received this email in 
error, please notify the sender immediately and delete the original. Neither 
this information block, the typed name of the sender, nor anything else in this 
message is intended to constitute an electronic signature unless a specific 
statement to the contrary is included in this message.



This email and any attachments are only for use by the intended recipient(s) 
and may contain legally privileged, confidential, proprietary or otherwise 
private information. Any unauthorized use, reproduction, dissemination, 
distribution or other disclosure of the contents of this e-mail or its 
attachments is strictly prohibited. If you have received this email in error, 
please notify the sender immediately and delete the original. Neither this 
information block, the typed name of the sender, nor anything else in this 
message is intended to constitute an electronic signature unless a specific 
statement to the contrary is included in this message.


Re: Python Proton Binding on Receiver for Broker

2022-04-28 Thread Steve Huston
Hi Jerome,

You can do that with the Python QMF API. I extracted the below from another 
script so it may need some adjustments but should get you there.
-Steve

import os
import sys

from qpid import * 
import qpid.messaging

host="localhost"
port=5672
sock = util.connect(host, port)
qmf_con = connection.Connection(sock)
qmf_con.start()
session = qmf_con.session(str(qpid.messaging.uuid4()), timeout=30)

session.queue_declare(queue="MyTopic")
session.exchange_bind(queue="MyTopic", exchange="whatever", 
binding_key="jerome.#")
session.sync
session.close(timeout=10)


On 4/28/22, 4:48 PM, "ONeil, Jerome"  wrote:

Hello,

I am trying to set up a receiver for a topic on a qpid C++ broker and need 
to control the binding between the Source exchange and the receiver queue.  I 
can get a simple receiver set up just fine and pull messages from it.

>>> event.container.create_receiver("amqp://localhost/MyTopic")

[jerome@localhost ~]$ qpid-config -r queues
Queue 'debug-MyTopic'
bind [#] => MyTopic


So that's grand.  I need to control the binding with more detail, though, 
and for the life of me I can't figure out how to do it.  I've tried controlling 
on the URL.  I've tried Filters and Selectors.  I have tried a variety of 
different link and receiver properties (x-bindings, etc..) and other methods 
scrapped up from the internet, and all I ever get for that binding is '#'.

Can someone provide a simple example?  Lets say I wanted that binding to 
actually be

bind [jerome.#] => MyTopic

What would that look like?  I am all out of clues and hope someone has one 
to spare.

Best regards,

-Jerome
This email and any attachments are only for use by the intended 
recipient(s) and may contain legally privileged, confidential, proprietary or 
otherwise private information. Any unauthorized use, reproduction, 
dissemination, distribution or other disclosure of the contents of this e-mail 
or its attachments is strictly prohibited. If you have received this email in 
error, please notify the sender immediately and delete the original. Neither 
this information block, the typed name of the sender, nor anything else in this 
message is intended to constitute an electronic signature unless a specific 
statement to the contrary is included in this message.



Python Proton Binding on Receiver for Broker

2022-04-28 Thread ONeil, Jerome
Hello,

I am trying to set up a receiver for a topic on a qpid C++ broker and need to 
control the binding between the Source exchange and the receiver queue.  I can 
get a simple receiver set up just fine and pull messages from it.

>>> event.container.create_receiver("amqp://localhost/MyTopic")

[jerome@localhost ~]$ qpid-config -r queues
Queue 'debug-MyTopic'
bind [#] => MyTopic


So that's grand.  I need to control the binding with more detail, though, and 
for the life of me I can't figure out how to do it.  I've tried controlling on 
the URL.  I've tried Filters and Selectors.  I have tried a variety of 
different link and receiver properties (x-bindings, etc..) and other methods 
scrapped up from the internet, and all I ever get for that binding is '#'.

Can someone provide a simple example?  Lets say I wanted that binding to 
actually be

bind [jerome.#] => MyTopic

What would that look like?  I am all out of clues and hope someone has one to 
spare.

Best regards,

-Jerome
This email and any attachments are only for use by the intended recipient(s) 
and may contain legally privileged, confidential, proprietary or otherwise 
private information. Any unauthorized use, reproduction, dissemination, 
distribution or other disclosure of the contents of this e-mail or its 
attachments is strictly prohibited. If you have received this email in error, 
please notify the sender immediately and delete the original. Neither this 
information block, the typed name of the sender, nor anything else in this 
message is intended to constitute an electronic signature unless a specific 
statement to the contrary is included in this message.


RE: Poor performance with Session in qpid-cpp

2022-04-28 Thread Millieret, Xavier
Hi Robbie,

Just my feedback.
Effectively, when I use the latest libqpid-proton-cpp release (i.e. 0.37.0), 
it's better, and works fine.

Moreover, on each methods (receive, send, unreceive) I used with my connection 
object the following code (and more especially work_queue().add .)
So to summary, my issue has been solved by:


  *   Using the latest library
  *   Using each time work_queue().add with my shared connection object.

send(const proton::message& msg) {
..
m_connection.work_queue().add([=]() {
m_connection.default_session().open_sender("queue://myAdress");
});

}

receive(const std::string& address) {
..
m_connection.work_queue().add([=]() {
   m_connection.default_session().open_receiver(address, 
proton::receiver_options().auto_accept(true));
});

}

unreceive() {
..
m_connection.work_queue().add([=]() {
m_receiver.close();
});

}

Regards

From: Millieret, Xavier
Sent: mercredi 27 avril 2022 16:37
To: 'users@qpid.apache.org' 
Subject: RE: Poor performance with Session in qpid-cpp

Hi Robbie,

Thx a lot for your explanation, I will try with the latest library (0.37.0), 
and I send you my feedback.

From: Millieret, Xavier
Sent: mercredi 27 avril 2022 10:24
To: users@qpid.apache.org
Subject: Poor performance with Session in qpid-cpp

Hi all,

I am using on linux the qpid-proton cpp 0.34 library, coupled to activemq 5.16 
on Debian 11

I don't understand why the code who using session object (or default_session) 
to send or a receive message, when I try to close it (for example, the 
receiver), it's 2 times more important than using a connection and each time 
open a receiver od sender and close it?

Here the code who take 2 times more for a close

m_connection.work_queue().add([=]() {
 m_connection.default_session().open_receiver("queue://myAdress", 
proton::receiver_options().auto_accept(true));
});



// The close session
m_receiver.session().close()

// 2 seconds later
on_session_close(proton::session&)
{
  cout << "inside on_session_close << endl ;
}

// This code is 2 times more faster

m_connection.work_queue().add([=]() {



m_connection.open_receiver(address, 
proton::receiver_options().auto_accept(true));


});


m_receiver.close();

// Arounds milli seconds after
on_receiver_close(proton::receiver&)
{
  cout << "inside on_receiver_close << endl ;
}

In the broker 's literature and theirs clients, the best way is obtain a 
connection, use it to open session, and use the session to send or receive 
message, don't open/close  a connection every time who want to send/receive a 
message.

So it's my question about this performance issue.

Xavier Millieret
Software Engineer
Engineering Software & Connectivity
Power Quality and Electronics Division (PQED)
Immeuble Viseo - Bâtiment A
110, rue Blaise Pascal
38330 Montbonnot St Martin
FRANCE
tel: +33 (0) 4 76 00 66 02
xaviermillie...@eaton.com
www.eaton.com





Eaton Industries (France) S.A.S ~ Siège social: 110 Rue Blaise Pascal, Immeuble 
Le Viséo - Bâtiment A Innovallée, 38330, Montbonnot-St.-Martin, France ~ Lieu 
d'enregistrement au registre du commerce: Grenoble ~ Numéro d'enregistrement: 
509 653 176 ~ Capital social souscrit et liberé:EUR 16215441 ~ Numéro de TVA: 
FR47509653176