Comments (5)
Hi @silencev!
This needs to be done with a source filter. This should do the trick:
source = Source("sb://test.servicebus.windows.net/queue")
source.set_filter(b"SessionID", name=b"com.microsoft:session-filter", descriptor=None)
client = ReceiveClient(source, auth=auth, ......)
Let me know how it goes :)
from azure-uamqp-python.
hi @annatisch ,
thanks for your reply, it works without showing NotAllowed error.
but it appears another error:
uamqp.errors.VendorLinkDetach:
com.microsoft:session-cannot-be-locked: The requested session 'SessionID' cannot be accepted. It may be locked by another receiver. TrackingId:8b02e492-2da1-44cf-a390-6cbcc6bea9e3_B41, SystemTracker:XXXXXX:queue:test-amqp~47, Timestamp:2019-01-03T17:39:56 TrackingId:aed3dc04867840349faa32a34ecb6660_G21, SystemTracker:gateway7, Timestamp:2019-01-03T17:39:56
here is the code snippet
uri = os.environ.get("AMQP_SERVICE_URI", 'amqps://xxxxxx.servicebus.windows.net/test-amqp')
key_name = os.environ.get("AMQP_SERVICE_KEY_NAME", 'RootManageSharedAccessKey')
access_key = os.environ.get("AMQP_SERVICE_ACCESS_KEY", 'YneZ0igTyRPXxxxxWXMpvAA=')
def uamqp_receive_simple():
parsed_uri = urlparse(uri)
plain_auth = authentication.SASLPlain(parsed_uri.hostname, key_name, access_key)
source = Source(uri)
source.set_filter(b"SessionID", name=b"com.microsoft:session-filter", descriptor=None)
messages = uamqp.receive_messages(source, auth=plain_auth, debug=True, max_batch_size=20, timeout=60000)
for message in messages: # type: UMessage
print("Received: {} {}".format(message, message.properties))
from azure-uamqp-python.
Hi @silencev,
Do you get the same error when using CBS auth?
cbs_auth = authentication.SASTokenAuth.from_shared_access_key(**auth_config)
from azure-uamqp-python.
hi @annatisch
thanks again!
after couple hours, I use CBS auth and enable logging.
I found it doesn't return any messages from service bus.
blocking in for 60 seconds (I give it a timeout value)
2019-01-04 09:44:17,696 [receiver] receiver.py:296 Message receiver b'receiver-link-a7affd27-1a12-43c3-9c50-e22bc33139cc' state changed from <MessageReceiverState.Opening: 1> to <MessageReceiverState.Open: 2> on connection: b'493d3773-8122-48b1-a634-abd83d0925dc'
2019-01-04 09:44:12,137 [common] common.py:213 Creating SASL Mechanism
2019-01-04 09:44:12,143 [amqp] amqp.py:26 Deallocating 'DictValue'
2019-01-04 09:44:12,143 [amqp] amqp.py:26 Destroying 'DictValue'
2019-01-04 09:44:12,143 [amqp] amqp.py:26 Deallocating 'SymbolValue'
2019-01-04 09:44:12,143 [amqp] amqp.py:26 Destroying 'SymbolValue'
2019-01-04 09:44:12,143 [amqp] amqp.py:26 Deallocating 'StringValue'
2019-01-04 09:44:12,143 [amqp] amqp.py:26 Destroying 'StringValue'
2019-01-04 09:44:12,144 [client] client.py:210 Opening client connection.
2019-01-04 09:44:12,144 [__init__] __init__.py:147 Initializing platform.
2019-01-04 09:44:12,151 [connection] connection.py:178 Connection b'493d3773-8122-48b1-a634-abd83d0925dc' state changed from <ConnectionState.START: 0> to <ConnectionState.START: 0>
2019-01-04 09:44:12,631 [connection] connection.py:178 Connection b'493d3773-8122-48b1-a634-abd83d0925dc' state changed from <ConnectionState.START: 0> to <ConnectionState.START: 0>
2019-01-04 09:44:14,667 [connection] connection.py:260 b'-> Header (AMQP 0.1.0.0)'
2019-01-04 09:44:14,667 [connection] connection.py:178 Connection b'493d3773-8122-48b1-a634-abd83d0925dc' state changed from <ConnectionState.START: 0> to <ConnectionState.HDR_SENT: 2>
2019-01-04 09:44:14,915 [connection] connection.py:260 b'<- Header (AMQP 0.1.0.0)'
2019-01-04 09:44:14,915 [connection] connection.py:178 Connection b'493d3773-8122-48b1-a634-abd83d0925dc' state changed from <ConnectionState.HDR_SENT: 2> to <ConnectionState.HDR_EXCH: 3>
2019-01-04 09:44:14,915 [connection] connection.py:260 b'-> [OPEN]* {493d3773-8122-48b1-a634-abd83d0925dc,my-service-bus.servicebus.windows.net,65536,65535}'
2019-01-04 09:44:14,915 [connection] connection.py:178 Connection b'493d3773-8122-48b1-a634-abd83d0925dc' state changed from <ConnectionState.HDR_EXCH: 3> to <ConnectionState.OPEN_SENT: 7>
2019-01-04 09:44:15,400 [connection] connection.py:260 b'<- [OPEN]* {51434d6c5b2c4c319b7e2aebbb04caa6_G33,NULL,65536,4999,240000,NULL,NULL,NULL,NULL,NULL}'
2019-01-04 09:44:15,400 [connection] connection.py:178 Connection b'493d3773-8122-48b1-a634-abd83d0925dc' state changed from <ConnectionState.OPEN_SENT: 7> to <ConnectionState.OPENED: 9>
2019-01-04 09:44:15,400 [connection] connection.py:260 b'-> [BEGIN]* {NULL,0,65536,65536,4294967295}'
2019-01-04 09:44:15,804 [connection] connection.py:260 b'<- [BEGIN]* {0,1,5000,65536,255,NULL,NULL,NULL}'
2019-01-04 09:44:15,805 [connection] connection.py:260 b'-> [ATTACH]* {$cbs-sender,0,false,0,0,* {$cbs},* {$cbs},NULL,NULL,0,0}'
2019-01-04 09:44:15,805 [connection] connection.py:260 b'-> [ATTACH]* {$cbs-receiver,1,true,0,0,* {$cbs},* {$cbs},NULL,NULL,NULL,0}'
2019-01-04 09:44:16,316 [connection] connection.py:260 b'<- [ATTACH]* {$cbs-sender,0,true,0,0,* {$cbs,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},* {$cbs,NULL,NULL,NULL,NULL,NULL,NULL},NULL,NULL,NULL,18446744073709551615,NULL,NULL,NULL}'
2019-01-04 09:44:16,316 [connection] connection.py:260 Destroying cSource
2019-01-04 09:44:16,316 [connection] connection.py:260 Destroying cTarget
2019-01-04 09:44:16,316 [connection] connection.py:260 Deallocating cSource
2019-01-04 09:44:16,316 [connection] connection.py:260 Destroying cSource
2019-01-04 09:44:16,316 [connection] connection.py:260 Deallocating cTarget
2019-01-04 09:44:16,316 [connection] connection.py:260 Destroying cTarget
2019-01-04 09:44:16,317 [connection] connection.py:260 b'<- [FLOW]* {0,5000,1,65536,0,0,100,0,NULL,false,NULL}'
2019-01-04 09:44:16,317 [connection] connection.py:260 b'-> [TRANSFER]* {0,0,<01 00 00 00>,0,false,false}'
2019-01-04 09:44:16,575 [connection] connection.py:260 b'<- [ATTACH]* {$cbs-receiver,1,false,0,0,* {$cbs,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},* {$cbs,NULL,NULL,NULL,NULL,NULL,NULL},NULL,NULL,0,18446744073709551615,NULL,NULL,NULL}'
2019-01-04 09:44:16,575 [connection] connection.py:260 Destroying cSource
2019-01-04 09:44:16,575 [connection] connection.py:260 Destroying cTarget
2019-01-04 09:44:16,575 [connection] connection.py:260 Deallocating cSource
2019-01-04 09:44:16,575 [connection] connection.py:260 Destroying cSource
2019-01-04 09:44:16,575 [connection] connection.py:260 Deallocating cTarget
2019-01-04 09:44:16,575 [connection] connection.py:260 Destroying cTarget
2019-01-04 09:44:16,575 [connection] connection.py:260 b'-> [FLOW]* {1,65536,1,65535,1,0,10000}'
2019-01-04 09:44:16,575 [connection] connection.py:260 CBS for connection b'493d3773-8122-48b1-a634-abd83d0925dc' completed opening with status: 0
2019-01-04 09:44:16,839 [connection] connection.py:260 b'<- [DISPOSITION]* {true,0,NULL,true,* {},NULL}'
2019-01-04 09:44:17,088 [connection] connection.py:260 b'<- [TRANSFER]* {1,0,<01 00 00 00>,0,NULL,false,NULL,NULL,NULL,NULL,false}'
2019-01-04 09:44:17,088 [connection] connection.py:260 Token put complete with result: 0, status: 202, description: b'Accepted', connection: b'493d3773-8122-48b1-a634-abd83d0925dc'
2019-01-04 09:44:17,088 [connection] connection.py:260 b'-> [DISPOSITION]* {true,0,0,true,* {}}'
2019-01-04 09:44:17,088 [receiver] receiver.py:92 Wrapping value type: <AMQPType.CompositeType: 22>
2019-01-04 09:44:17,089 [receiver] receiver.py:93 Wrapping value type: <AMQPType.CompositeType: 22>
2019-01-04 09:44:17,090 [receiver] receiver.py:296 Message receiver b'receiver-link-a7affd27-1a12-43c3-9c50-e22bc33139cc' state changed from <MessageReceiverState.Idle: 0> to <MessageReceiverState.Opening: 1> on connection: b'493d3773-8122-48b1-a634-abd83d0925dc'
2019-01-04 09:44:17,090 [receiver] receiver.py:275 b'-> [ATTACH]* {receiver-link-a7affd27-1a12-43c3-9c50-e22bc33139cc,2,true,0,1,* {amqps://my-service-bus.servicebus.windows.net/test-amqp,NULL,NULL,NULL,NULL,NULL,NULL,{[com.microsoft:session-filter:SessionId]}},* {493d3773-8122-48b1-a634-abd83d0925dc},NULL,NULL,NULL,262144}'
2019-01-04 09:44:17,695 [connection] connection.py:260 b'<- [ATTACH]* {receiver-link-a7affd27-1a12-43c3-9c50-e22bc33139cc,2,false,NULL,1,* {amqps://my-service-bus.servicebus.windows.net/test-amqp,NULL,NULL,NULL,NULL,NULL,NULL,{[com.microsoft:session-filter:SessionId]},NULL,NULL,NULL},* {493d3773-8122-48b1-a634-abd83d0925dc,NULL,NULL,NULL,NULL,NULL,NULL},NULL,NULL,0,262144,NULL,NULL,{[com.microsoft:locked-until-utc:636821630625849499]}}'
2019-01-04 09:44:17,695 [connection] connection.py:260 Wrapping value type: <AMQPType.DictValue: 19>
2019-01-04 09:44:17,695 [connection] connection.py:260 Destroying cSource
2019-01-04 09:44:17,695 [connection] connection.py:260 Destroying cTarget
2019-01-04 09:44:17,695 [connection] connection.py:260 Deallocating cSource
2019-01-04 09:44:17,695 [connection] connection.py:260 Destroying cSource
2019-01-04 09:44:17,695 [connection] connection.py:260 Deallocating cTarget
2019-01-04 09:44:17,695 [connection] connection.py:260 Destroying cTarget
2019-01-04 09:44:17,695 [connection] connection.py:260 Deallocating 'DictValue'
2019-01-04 09:44:17,695 [connection] connection.py:260 Destroying 'DictValue'
2019-01-04 09:44:17,695 [connection] connection.py:260 b'-> [FLOW]* {2,65535,1,65535,2,0,20}'
2019-01-04 09:44:17,696 [receiver] receiver.py:296 Message receiver b'receiver-link-a7affd27-1a12-43c3-9c50-e22bc33139cc' state changed from <MessageReceiverState.Opening: 1> to <MessageReceiverState.Open: 2> on connection: b'493d3773-8122-48b1-a634-abd83d0925dc'
2019-01-04 09:45:13,003 [receiver] receiver.py:264 Destroying cMessageReceiver
2019-01-04 09:45:13,003 [receiver] receiver.py:296 Message receiver b'receiver-link-a7affd27-1a12-43c3-9c50-e22bc33139cc' state changed from <MessageReceiverState.Open: 2> to <MessageReceiverState.Closing: 3> on connection: b'493d3773-8122-48b1-a634-abd83d0925dc'
2019-01-04 09:45:13,003 [receiver] receiver.py:264 b'-> [DETACH]* {2,true}'
2019-01-04 09:45:13,004 [receiver] receiver.py:265 Destroying cLink
2019-01-04 09:45:13,004 [client] client.py:263 Deallocating 'CompositeValue'
2019-01-04 09:45:13,004 [client] client.py:263 Destroying 'CompositeValue'
2019-01-04 09:45:13,004 [client] client.py:263 Deallocating 'CompositeValue'
2019-01-04 09:45:13,005 [client] client.py:263 Destroying 'CompositeValue'
2019-01-04 09:45:13,005 [client] client.py:263 Deallocating cLink
2019-01-04 09:45:13,005 [client] client.py:263 Deallocating cMessageReceiver
2019-01-04 09:45:13,005 [client] client.py:274 CBS session pending.
2019-01-04 09:45:13,005 [client] client.py:277 Closing exclusive connection.
2019-01-04 09:45:13,005 [connection] connection.py:217 Unlocked connection b'493d3773-8122-48b1-a634-abd83d0925dc' to close.
2019-01-04 09:45:13,005 [connection] connection.py:130 Shutting down connection b'493d3773-8122-48b1-a634-abd83d0925dc'.
2019-01-04 09:45:13,006 [cbs_auth] cbs_auth.py:82 Shutting down CBS session on connection: b'493d3773-8122-48b1-a634-abd83d0925dc'.
2019-01-04 09:45:13,006 [cbs_auth] cbs_auth.py:84 Unlocked CBS to close on connection: b'493d3773-8122-48b1-a634-abd83d0925dc'.
2019-01-04 09:45:13,006 [cbs_auth] cbs_auth.py:85 Destroying CBSTokenAuth for connection b'493d3773-8122-48b1-a634-abd83d0925dc'
2019-01-04 09:45:13,006 [cbs_auth] cbs_auth.py:85 b'-> [DETACH]* {0,true}'
2019-01-04 09:45:13,006 [cbs_auth] cbs_auth.py:85 b'-> [DETACH]* {1,true}'
2019-01-04 09:45:13,006 [cbs_auth] cbs_auth.py:86 Auth closed, destroying session on connection: b'493d3773-8122-48b1-a634-abd83d0925dc'.
2019-01-04 09:45:13,006 [session] session.py:135 Destroying cSession
2019-01-04 09:45:13,006 [session] session.py:135 b'-> [END]* {}'
2019-01-04 09:45:13,006 [cbs_auth] cbs_auth.py:89 Finished shutting down CBS session on connection: b'493d3773-8122-48b1-a634-abd83d0925dc'.
2019-01-04 09:45:13,006 [connection] connection.py:135 Destroying Connection
2019-01-04 09:45:13,007 [connection] connection.py:135 b'-> [CLOSE]* {}'
2019-01-04 09:45:13,007 [connection] connection.py:178 Connection b'493d3773-8122-48b1-a634-abd83d0925dc' state changed from <ConnectionState.OPENED: 9> to <ConnectionState.END: 13>
2019-01-04 09:45:13,010 [common] common.py:94 Destroying SASLMechanism
2019-01-04 09:45:13,010 [common] common.py:95 Destroying XIO
2019-01-04 09:45:13,010 [common] common.py:96 Destroying XIO
2019-01-04 09:45:13,010 [connection] connection.py:137 Connection shutdown complete b'493d3773-8122-48b1-a634-abd83d0925dc'.
2019-01-04 09:45:13,010 [__init__] __init__.py:160 Deinitializing platform.
2019-01-04 09:45:13,011 [amqp] amqp.py:51 Deallocating XIO
2019-01-04 09:45:13,011 [amqp] amqp.py:51 Destroying XIO
2019-01-04 09:45:13,011 [amqp] amqp.py:51 Deallocating SASLMechanism
2019-01-04 09:45:13,011 [amqp] amqp.py:51 Destroying SASLMechanism
2019-01-04 09:45:13,011 [amqp] amqp.py:51 Deallocating XIO
2019-01-04 09:45:13,011 [amqp] amqp.py:51 Destroying XIO
2019-01-04 09:45:13,011 [amqp] amqp.py:51 Deallocating cSource
2019-01-04 09:45:13,012 [amqp] amqp.py:51 Destroying cSource
2019-01-04 09:45:13,012 [amqp] amqp.py:51 Deallocating 'StringValue'
2019-01-04 09:45:13,012 [amqp] amqp.py:51 Destroying 'StringValue'
2019-01-04 09:45:13,020 [(unknown file)] (unknown file):0 Deallocating XIO
2019-01-04 09:45:13,020 [(unknown file)] (unknown file):0 Deallocating SASLMechanism
2019-01-04 09:45:13,020 [(unknown file)] (unknown file):0 Deallocating XIO
2019-01-04 09:45:13,020 [(unknown file)] (unknown file):0 Deallocating Connection
2019-01-04 09:45:13,020 [(unknown file)] (unknown file):0 Deallocating cSession
2019-01-04 09:45:13,020 [(unknown file)] (unknown file):0 Deallocating CBSTokenAuth
the portal shows it has 4 messages there:
from azure-uamqp-python.
my bad, I misunderstand the API
it now works after small modification:
set the None in first argument
source.set_filter(None, name=b"com.microsoft:session-filter", descriptor=None)
from azure-uamqp-python.
Related Issues (20)
- This repo is missing important files HOT 1
- Python 3.11 issues for uaqmp HOT 8
- 1.6.0 tag missing in git repository HOT 2
- Update Ubuntu VM to 20.04
- Disable pipeline in Github Actions
- six usage is redundant HOT 2
- Build arm64 wheels HOT 1
- LinkDetach Idle timeout after 10 minutes is printed as log warning HOT 1
- Amqp over websocket is not working and leeds to a connection error HOT 2
- Add PyPy support HOT 5
- uamqp 1.6.4 on PyPi, but not in a GitHub release HOT 2
- Version tags on Github are broken HOT 5
- Provide Python 3.12 wheels HOT 2
- Can't build on Mac OS error: command '/usr/bin/clang' failed with exit code 1 HOT 7
- Vulnerable to CVE-2024-21646? HOT 4
- Python Based AQMP Library & uAMQP Repo Status HOT 2
- Fails to build with Python 3.12
- Vulnerable to CVE-2024-25110? HOT 5
- [1.6.9] Failed building wheel for uamqp HOT 9
- Backport CVE-2024-29195 fix here as well?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-uamqp-python.