Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
Azure Event Hub 5.6.0 - How to send an event to a specific partition id Nodejs?

I was using azure/event-hubs 1.0.8 version in nodejs for sending the data to a specific partition id. Below is the sample code

enter image description here

Please could someone help me how to send data to event to a specific partition id using azure/event-hubs 5.6.0 version in nodejs?. I research a lot but couldn't find any source. Any help would be appreciated!

Below is the code for EventHub 5.6.0

 const insertOneInPartition = (data, partition, eventsHub) => {
  const dataToInsert = { body: { ...data } };
  return new Promise((resolve, reject) => {
    eventsHub.createBatch({ partitionId : partition }).then(async eventDataBatch => {
      if (data) {
        eventDataBatch.tryAdd(dataToInsert);
        await eventsHub.sendBatch(eventDataBatch);
        resolve(eventsHub);
      } else {
        // eslint-disable-next-line prefer-promise-reject-errors
        reject('error');
      }
    }).catch(error => {
      reject(error);
    });
  });
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

For nodejs clients, see the createBatch() that takes an options argument that can contain either the partitionId or partition Key, see the sendEvents sample code at github, see line 41. You can use this browser app to send test messages to your specific partition.

For Javascript clients, you should pass the partition ID when creating the batch. frame the batchOptions with partition id and send it to create_batch(batchOptions), see line 35 for setting partitionId in code sample at https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/eventhub/event-hubs/samples/v5/javascript/sendEvents.js

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda