简体   繁体   English

Azure 服务总线错误:使用 Databricks 创建队列时确保 RequiresSession 设置为 true

[英]Azure Service Bus Error: Ensure RequiresSession is set to true when creating a Queue, with Databricks

When attempting to retrieve Queue messages from Azure Service via Databricks I get the following error:尝试通过 Databricks 从 Azure 服务检索队列消息时,出现以下错误:

Ensure RequiresSession is set to true when creating a Queue or Subscription to enable sessionful behavior确保在创建队列或订阅时将 RequiresSession 设置为 true 以启用会话行为

I have set the Message Queue using Azure's Service Bus Explorer, see below我已经使用 Azure 的服务总线资源管理器设置了消息队列,见下文

在此处输入图像描述

As you can see I have set the sessionId to carlsession6如您所见,我已将 sessionId 设置为 carlsession6

Therefore, I'm not sure why I'm getting the error message因此,我不确定为什么会收到错误消息

The code in databricks is as follows: databricks中的代码如下:

session_id = "carlsession6"

connstr = "Endpoint=sb://carlsbus.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=myaccesskey"
queue_name = "carlsqueue"

prevTable = None
table = None
rows = []
msgs = []
run = True

batchMsgs = 0

totalMsgs = 0

with ServiceBusClient.from_connection_string(connstr) as client:
    # max_wait_time specifies how long the receiver should wait with no incoming messages before stopping receipt.
    # Default is None; to receive forever.
    
    while run:
      
      with client.get_queue_receiver(queue_name, session_id=session_id, max_wait_time=5) as receiver:
           
          logDebug(D_LEVEL[1], 'GOT QUEUE RECEIVER')
          rows = []
          msgs = []
    
          i = 0
          for msg in receiver: 
          
            receiver.session.renew_lock()
          
            logDebug(D_LEVEL[1], 'READ MESSAGE')
            msgs.append(msg)
          
            msgJSON = json.loads(str(msg))
          
            if 'table' in msgJSON['control']:
              table = msgJSON['control']['table']
          
            if prevTable is None:
              prevTable = table
                     
            if prevTable != table or batchMsgs >= MAX_BATCH_SIZE:
              writeData(prevTable, schema, rows, msgs)
              rows = []
              msgs = []
              batchMsgs = 0
            
            prevTable = table
          
            i += 1
            batchMsgs += 1
          
            if (i % 100 == 0):
              logInfo('Processed ' + str(i) + ' messages')
          
            if 'operation' in msgJSON['control']:
              if msgJSON['control']['operation'] == "stop_message_processor":
                logInfo('RECEIVED stop_message_processor...')
                run = False
                break
        
            schema, rows = processMsg(msgJSON, rows)    
                            
            logDebug(D_LEVEL[1], 'COMPLETED MESSAGE')
          
            if STOP_AFTER is not None:
              if i >= STOP_AFTER:
                run = False
                break
                
          if len(rows) > 0:  
            writeData(table, schema, rows, msgs)
          elif len(msgs) == 1:
            receiver.complete_message(msg)
     
      logInfo('PROCESSED ' + str(i) + ' MESSAGES FROM QUEUE')
      totalMsgs += i  
      
    logInfo('TOTAL MESSAGES PROCESSED ' + str(totalMsgs))

Any thoughts on how to resolve the error?关于如何解决错误的任何想法?

Problem resolved with the following code:使用以下代码解决了问题:

New-AzServiceBusQueue -ResourceGroup myresourcegroup -NamespaceName mynamespace -QueueName myqueue ` -RequiresSession $True New-AzServiceBusQueue -ResourceGroup -NamespaceName mynamespace -RequiresSession $True

As described at the following link https://learn.microsoft.com/en-us/azure/service-bus-messaging/enable-message-sessions如以下链接所述 https://learn.microsoft.com/en-us/azure/service-bus-messaging/enable-message-sessions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法为 Azure 服务总线队列设置 maxMessageBatchSize - Not able to set maxMessageBatchSize for Azure Service Bus Queue 逻辑应用中的 Azure 服务总线队列错误 - Azure service bus queue error in the logic app 通过 PowerShell 创建服务总线队列时是否可以设置单个消息的最大大小? - Is it possible to set the max size of individual messages when creating a Service Bus queue through PowerShell? Azure 服务总线队列自动删除,如 RabbitMQ - Azure Service Bus queue autodelete like in RabbitMQ 清除 azure 服务总线队列 go - Clearing azure service bus queue in one go 使用 Databricks 将从 Azure 服务总线接收到的消息移动到 Azure DataLake - Moving Messages received from Azure Service Bus to Azure DataLake with Databricks Azure服务总线中是否存在Poison Queue? - Does Poison Queue exists in Azure Service Bus? .net 5 Azure 总线服务队列监听器 - .net 5 Azure Bus Service Queue Listener 为 Azure 服务总线使用 NamespaceManager 时出现 ConfigurationManager 错误 - Getting ConfigurationManager error when using NamespaceManager for Azure Service Bus Terraform:使用 local_account_disabled=true 创建 azure kube.netes 服务时出错 - Terraform: Error when creating azure kubernetes service with local_account_disabled=true
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM