Azure队列:查找项目是否在队列中

时间:2012-10-02 12:32:04

标签: azure azure-storage

是否可以查询azure队列以查找某个项目是否在指定队列中的某个位置(基于某些键属性)?

3 个答案:

答案 0 :(得分:8)

Azure队列用于异步消息传递,而不是搜索。如果需要索引支持,则应使用 Azure表 SQL Azure数据库

Azure队列只会让您peek the next message without dequeuing

答案 1 :(得分:0)

请检查Microsoft Azure Storage。这是管理内容的绝佳工具。上传,下载和管理Blob,文件,队列,表和Cosmos DB实体。

可以如下图所示管理队列消息: enter image description here

答案 2 :(得分:0)

当然,在消息队列中执行搜索操作是非常糟糕的方法,但是您可以尝试执行以下操作:

define stream outFile.  /* using a named stream rather than the default, unnamed, stream avoids unintended conflicts if someone else's code is lazily using the unnamed stream */

function mkTemp returns character ( input tmpid as character, input extension as character ):

  define variable fname as character no-undo.
  run adecomm/_tmpfile.p ( tmpid, extension, output fname ).

  /* create the temp file with no content
   */

  output stream outFile to value( fname ).
  output stream outFile close.

  return fname.

end.


procedure doStuff:

  define input parameter tmpfile as character no-undo.
  define input parameter custid  as integer   no-undo.

  output stream outFile to value( tmpFile ) append.  /* open the existing file in append mode */

  put stream outFile "customer:" custId skip.
  for each order no-lock where order.custNum = custId and orderStatus <> "shipped" and salesRep = "bbb":
    put stream outFile orderNum " " promised skip.
  end.

  output stream outFile close.

  return.

end.

define variable i       as integer no-undo.
define variable tmpName as character no-undo.

/* tmpName = mkTemp( "xyzzy", ".tmp" ). */  /* if you only need one temp file get the name here and comment it out below */

for each customer no-lock:

  tmpName = mkTemp( "xyzzy", ".tmp" ).  /* use this if every customer should get a distinct temp file */

  run doStuff ( tmpName, custNum ).

  /* if there is no good reason to be calling the doStuff() procedure then just remove it and do it inline like this: */

  /*
   *
  output stream outFile to value( tmpFile ) append.  /* open the existing file in append mode */

  put stream outFile "customer:" customer.custNum skip.
  for each order no-lock where order.custNum = customer.CustNum and orderStatus <> "shipped" and salesRep = "bbb":
    put stream outFile orderNum " " promised skip.
  end.

  output stream outFile close.

   */

  i = i + 1.
  if i >= 3 then leave.  /* just do 3 customers for the sample run... */

end.
相关问题