Wednesday, 15 May 2013

c# - Azure Service Bus messages not being received -



c# - Azure Service Bus messages not being received -

i sending message web role worker role. before these messages received , instantly out of messages not beingness received, though content of messages same. if send 1 message now, not received after if send latest 1 received. 1 not received earlier, gets received after few seconds or goes dead letter messages time live has expired.

i not able figure out problem can be, ideas? or behaviour normal service bus?

this how receiving message in worker role

edit:

public override void run() { while (!isstopped) { seek { if (broadcastreceived) { broadcastreceived = false; // receive message web role upload broadcast queue broadcastclient.beginreceive(onwebrolemessagereceived, null); } if (signalrmessagereceived) { signalrmessagereceived = false; // receive message signalr broadcasthub signalrclient.beginreceive(onsignalrmessagereceived, null); } if (signalrfirsttimemessagereceived) { signalrfirsttimemessagereceived = false; // receive message signalr broadcasthub signalrfirsttimeclient.beginreceive(onsignalrfirsttimemessagereceived, null); } } } public void onwebrolemessagereceived(iasyncresult iar) { brokeredmessage receivedbroadcastmessage = null; receivedbroadcastmessage = broadcastclient.endreceive(iar); if (receivedbroadcastmessage != null) { // process message receivedbroadcastmessage.complete(); } broadcastreceived = true; }

update :

broadcastclient = cloudstoragehelper.getservicebusqueueclient(queuenames.apitoworkerrole); public static queueclient getservicebusqueueclient(string queuename) { string connectionstring = cloudconfigurationmanager.getsetting("microsoft.servicebus.connectionstring"); var namespacemanager = namespacemanager.createfromconnectionstring(connectionstring); if (!namespacemanager.queueexists(queuename)) { namespacemanager.createqueue(queuename); } queueclient client = queueclient.createfromconnectionstring(connectionstring, queuename); homecoming client; }

web role:

var queueclient = cloudstoragehelper.getservicebusqueueclient(queuenames.apitoworkerrole); //for testing purposes record.username = "owner"; record.channel = "world"; record.title = "sample"; record.duration = 10; brokeredmessage message = new brokeredmessage(record); queueclient.send(message);

in worker role above, executing code in run once. indicates single message process every time worker role run? typical code process messages in loop looks follows:

public override void run() { while (!isstopped) { seek { // receive message brokeredmessage receivedmessage = null; receivedmessage = client.receive(); if (receivedmessage != null) { // process message receivedmessage.complete(); // unless message goes in queue } } grab (messagingexception e) { if (!e.istransient) { trace.writeline(e.message); throw; } thread.sleep(10000); // optional if want add together delay } } }

c# asp.net azure servicebus azure-servicebus-queues

No comments:

Post a Comment