You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Louis Letourneau <ll...@gmail.com> on 2019/11/07 22:47:04 UTC
multiple senders in one container
I am using qpid proton 0.29 python talking to Active MQ using AMQP 1.0
I am trying to use one container and send messages to multiple queues
def on_start(self, event):
conn_url1 = Url(...)
self.sender1 = event.container.create_sender(conn_url1)
conn_url2 = Url(...)
self.sender2 = event.container.create_sender(conn_url2)
def on_new_data(self, event):
msg = Message(body=event.subject)
print('{}, {}'.format(self.sender1.credit, self.sender2.credit))
if(self.sender1.credit > 0):
self.sender1.send(msg)
else:
print("No credits: sender1")
if(self.sender2.credit > 0):
self.sender2.send(msg)
else:
print("No credits: sender2")
Problem is, sender2 always has 0 credits.
If I create X senders, only the first one created will have credits the
others will always be 0
I only found 2 ways to make this work.
1- Not use containers, but use a BlockingConnection per sender
2- Create one container per sender. Which means many loops, basically one
per connection
Is this normal? Why can't a container manage multiple connections/senders?
Thank you
Louis
Re: multiple senders in one container
Posted by Louis Letourneau <ll...@gmail.com>.
>
>
> try:
>
> event.container.container_id = None
>
> before opening any connection (in which case they should each get a
> different uuid), or else setting it to a different value of your
> choosing before opening
That was kind of it.
Session uses the id to name the link and the id comes from a uuid set the
first time.
Instead of setting it to None each time I just had to name (parameter to
create_sender) each of my senders /links
Thank you so much.
Louis
Re: multiple senders in one container
Posted by Gordon Sim <gs...@redhat.com>.
On 07/11/2019 10:47 pm, Louis Letourneau wrote:
> I am using qpid proton 0.29 python talking to Active MQ using AMQP 1.0
>
> I am trying to use one container and send messages to multiple queues
>
> def on_start(self, event):
> conn_url1 = Url(...)
> self.sender1 = event.container.create_sender(conn_url1)
> conn_url2 = Url(...)
> self.sender2 = event.container.create_sender(conn_url2)
>
> def on_new_data(self, event):
> msg = Message(body=event.subject)
> print('{}, {}'.format(self.sender1.credit, self.sender2.credit))
> if(self.sender1.credit > 0):
> self.sender1.send(msg)
> else:
> print("No credits: sender1")
> if(self.sender2.credit > 0):
> self.sender2.send(msg)
> else:
> print("No credits: sender2")
>
>
> Problem is, sender2 always has 0 credits.
> If I create X senders, only the first one created will have credits the
> others will always be 0
>
> I only found 2 ways to make this work.
> 1- Not use containers, but use a BlockingConnection per sender
> 2- Create one container per sender. Which means many loops, basically one
> per connection
>
> Is this normal? Why can't a container manage multiple connections/senders?
It may be that it is only accepting the first connection with the same
container id (treating it as the client id in JMS terms).
try:
event.container.container_id = None
before opening any connection (in which case they should each get a
different uuid), or else setting it to a different value of your
choosing before opening each connection.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org