Azure WebJob进程存储队列消息系列性

时间:2016-03-09 22:21:24

标签: azure azure-webjobs azure-webjobssdk

我们需要一次一个地连续处理来自Azure存储队列的消息。

默认情况下,import SpriteKit class BackgroundNode: SKNode { override init() { super.init() // create containers for all the Textures and Nodes var backgroundTextures = [SKTexture]() var backgroundSpriteNodes = [SKSpriteNode]() // load the TextureAtlas for the Background let backgroundAtlas : SKTextureAtlas = SKTextureAtlas(named: "BackgroundImages") let imagesCount:Int = backgroundAtlas.textureNames.count // fetch all of the image resources and store them as both textures and spriteNodes for var i = 1; i <= imagesCount; i++ { let imageTextureName = "background_\(i)" let imageTexture = backgroundAtlas.textureNamed(imageTextureName) let spriteNode = SKSpriteNode(texture: imageTexture) spriteNode.anchorPoint = CGPointMake(0, 0) backgroundTextures.append(imageTexture) backgroundSpriteNodes.append(spriteNode) } // for each image figure out what the x value of the location should be for var i = 0; i < imagesCount; i++ { var addtionalWidth:CGFloat = 0 // add the x value of all the images before this image to come up with the latest x for var j = 0; j < i; j++ { addtionalWidth += backgroundTextures[j].size().width } // assign each SKNode a position backgroundSpriteNodes[i].position = CGPointMake(0 + addtionalWidth, 0) // add the Node to the scene self.addChild(backgroundSpriteNodes[i]) } // keep track of where you are to reset scrolls images lastNode = backgroundSpriteNodes[imagesCount - 1] } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } var speedOfBackground : CGFloat = 300.0 var previousTime : CFTimeInterval = -1 var lastNode : SKSpriteNode! func update(currentTime: CFTimeInterval) { if previousTime != -1 { var outOfBoundsSprite : SKSpriteNode? = nil let deltaX = speedOfBackground * CGFloat(currentTime - previousTime) for sknode in self.children { if let sprite = sknode as? SKSpriteNode { sprite.position = CGPointMake(sprite.position.x - deltaX, sprite.position.y) if (sprite.position.x < -sprite.size.width) { outOfBoundsSprite = sprite } } } if (outOfBoundsSprite != nil) { outOfBoundsSprite?.position.x = lastNode.position.x + lastNode.size.width lastNode = outOfBoundsSprite! } } previousTime = currentTime } } 设置为16

https://github.com/Azure/azure-webjobs-sdk/blob/0581fb1610d56a597523fcea67733944efba9541/src/Microsoft.Azure.WebJobs.Host/JobHostQueuesConfiguration.cs#L15

WebJob从队列中取出的16条消息将被并行处理。相反,我们需要WebJob一次一个地连续处理消息。

如何实现这一目标?

我们目前被迫将<div ng-init="foo()"> 设置为1,这是不理想的,因为它会在消息队列中读取时引入大量的旋转/停机时间。

澄清:我们不需要先执行先出或保证订单处理,只需一次处理一个。

1 个答案:

答案 0 :(得分:2)

JobHostConfiguration config = new JobHostConfiguration();
config.Queues.BatchSize = 1;
config.Queues.MaxDequeueCount = 1;
config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(5);

将BatchSize和MaxDequeueCount设置为1, 将MaxPollingInterval设置为5秒。