Árvore de páginas

Cria um objeto que permite o compartilhado de dados entre os servidores através de uma Fila.

Sintaxe

 

oTQLS := TQueueSvc():New( cName )

Parâmetros

NomeTipoDescriçãoObrigatórioReferênciaObservações
cName
caractere

Nome que será atribuído a Fila ou Lista

X Nome não deve ser vazio (Nulo)

Retorno

NomeTipoDescriçãoObservações
oTQLS
objeto

objeto de Fila ou Lista

Se algum erro ocorrer será retornado Nulo (Nil)

Observações

Exemplos

Exemplo 

#include 'protheus.ch'
 
// Setup AWS
Static cRegiao    := "SA_EAST_1"
Static cCred      := "RICARDOLIMA732CREDID"
Static cCredKey   := "7O8US89ZjbcwuxdyL361IEWOSEmYQChlln6hMK/r"
 
// Setup Redis
Static cRedisHost := "tec-clima"
Static nRedisPort := 6379
 
User Function newFila()
  Local nRet       := 0
 
  // Nome da Fila
  Local cQueueName := "Fila_TQLS"
  // Indica que estara usando a Infra-Estrutura da Amazon para gerenciar Filas no SQS
  Local lIsAws     := .F.
  // Tempo de espera de tratamento de mensagem
  Local nVisibTimeOut := 45 // segundos
  // Tempo de armazenamento da mensagem
  Local nMsgRetPeriod := (14 * 24 * 60 * 60) // 14 dias (em segundos)
 
  // Objeto de Fila
  Local oTQLS := Nil
 
  Local cBuild := GetBuild()
  ConOut("Usando Build: " + cBuild)
 
  // Cria um novo objeto de Fila
  oTQLS := TQueueSvc():New(cQueueName)
  If(oTQLS == Nil)
    ConOut("### ERRO ### " + "Erro na criacao da Fila - " + cQueueName)
    Return .F.
  Else
    ConOut("Criacao da Fila  OK - " + oTQLS:cName)
  EndIf
 
  If(lIsAws)
    // Configurando a Fila AWS SQS
    nRet := oTQLS:SetupSQS(cRegiao, cCred, cCredKey, nMsgRetPeriod, nVisibTimeOut)
  Else
    // Configurando a Fila
    nRet := oTQLS:Setup(cRedisHost, nRedisPort, , nVisibTimeOut)
  EndIf
 
  If nRet != 0
    ConOut("### ERRO ### " + "Erro ao fazer o Setup" + " Erro: " + AllTrim(Str(nRet)))
    Return .F.
  Else
    ConOut("Setup de Fila     OK - " + oTQLS:cName)
  EndIf
 
Return .T.

Veja também

  • Sem rótulos