Retrieve message properties from Azure Service bus topics withn Python -
using python 2.7 need properties of message. know message contains 3 properties: cdid, active , alarm:
in c# have client sends message;
string connectionstring = cloudconfigurationmanager.getsetting("microsoft.servicebus.connectionstring"); topicclient newclient = topicclient.createfromconnectionstring(connectionstring, "cdmessages"); var servicemsg = new brokeredmessage("alarm deactive"); servicemsg.properties["cdid"] = message.properties["cdid"]; servicemsg.properties["active"] = false; servicemsg.properties["alarm"] = false; newclient.send(servicemsg);
i have made subscription , able receive messages using python have no clue how properties of message.
key_name = '******' key_value ='******' service_namespace1 = '******' sbs = servicebusservice(service_namespace=service_namespace1, shared_access_key_name=key_name, shared_access_key_value=key_value) active = "active" deactive = "deactivate" sbs.create_subscription('cdmessages', 'allmessages') while true: msg = sbs.receive_subscription_message('cdmessages', 'allmessages', peek_lock=false) print(msg.body) messagestring = str(msg.body) if messagestring.find(active) == true newstate = "activated" return(newstate)
i can "activated" part working because send "alarm deactive" or "alarm active" message text hack made @ to the lowest degree working partially. need able read properties. have tried msg.properties returns error properties attribute doesn't exists.
python azure azureservicebus
No comments:
Post a Comment