Search code examples
node.jsazurenestjsazureservicebusazure-servicebus-subscriptions

ServiceBusError: The messaging entity


I am using the @azure/service-bus library in NestJs. The code is working and I can send and receive messages. However, when I receive messages, I am getting the following error.

ServiceBusError: The messaging entity `'sb://[Namespace].servicebus.windows.net/test_topic.reply'` could not be found. To know more visit https://aka.ms/sbResourceMgrExceptions.  TrackingId:40f1665b-7838-4e40-acbe-5d7472766844_G10, SystemTracker:[Namespace].servicebus.windows.net:test_topic.reply, Timestamp:2022-12-19T16:31:29

How can I create the sb://[Namespace].servicebus.windows.net/test_topic.reply in my account or is there any other way to solve it?

Thanks


Solution

    • Here when I use the following code, I am not getting any error.

    code:

    
    const { delay, ServiceBusClient, ServiceBusMessage } = require("@azure/service-bus");
    
      
    
    const  connectionString = "Connection String From The Portal "
    
    const  topicName = "<Name OF TOPIC>";
    
    const  subscriptionName = "<NAME OF SUBSCRIPTION YOU CREATED IN AZURE SERVICE  Bus>";
    
      
      
    
    const  client = new  ServiceBusClient(connectionString);
    
      
    
    const  receiver = client.createReceiver(topicName,subscriptionName);
    
      
    
    const  messageProcessor = async (message) => {
    
        console.log(` message: ${message.body}`);
    
    };
    
      
    
    const  errorProcessor = async (err)=>{
    
        console.log(err);
    
    };
    
      
    
    receiver.subscribe({
    
        processMessage:messageProcessor,
    
        processError:errorProcessor
    
    });
    
    

    Output:

    enter image description here

    • Message Entities in the context of the Service Bus are Queues, Topics and Subscription make sure they are created prior to processing the messages

    Refer this MS DOCS for service bus .