Как отправить сообщение на Azure Service Bus topi c из Java Spring Boot - PullRequest
0 голосов
/ 23 января 2020

В моем приложении Spring Boot мне нужно отправить сообщение на topi c на Azure Service Bus. Это мой код:

@PostConstruct
    public  void afterConstruct() throws ServiceBusException, InterruptedException{

        ConnectionStringBuilder builder = new ConnectionStringBuilder("servicebusnamespace001968.servicebus.windows.net/",
                "servicebustopic0001968","uqO7UZg8Mx27deELaz05GLeIhOKG+QSD6L/WXvBkkLA=");

               subscriptionClient =new SubscriptionClient(builder, ReceiveMode.PEEKLOCK);

        topicClient = new TopicClient(builder);

        final Message message = new Message("test message");
        topicClient.send(message);

        receiveSubscriptionMessage();
    }

Когда я запускаю это, я получаю следующее исключение:

    : Sending CBS Token for amqp://servicebusnamespace001968.servicebus.windows.net/servicebustopic0001968 failed.

    com.microsoft.azure.servicebus.primitives.ServiceBusException: Error{condition=com.microsoft:auth-failed, 

description='MissingAudience: The provided token does not specify the 'Audience'.', info=null}
        at com.microsoft.azure.servicebus.primitives.ExceptionUtil.toException(ExceptionUtil.java:121) ~[azure-servicebus-1.2.15.jar:na]

Как правильно указать эту «аудиторию», чтобы сделать отправку этой сообщение возможно?

...