简体   繁体   中英

500 Internal Server Error while sending a message to a Service Bus topic through Azure Java SDK

I have a problem when try to send a message to a service bus topic through java azure sdk, I receive 500 Internal Server Error.

I prepared code based on this link: https://azure.microsoft.com/en-us/documentation/articles/service-bus-java-how-to-use-topics-subscriptions/ and my code looks like below:

Configuration config = ServiceBusConfiguration.configureWithSASAuthentication(
    "NAMESPACE",
    "SAS_NAME",
    "SAS_KEY_VALUE",
    ".servicebus.windows.net");      
ServiceBusContract service = ServiceBusService.create(config);
try {
    BrokeredMessage message = new BrokeredMessage("Message content");
    service.sendTopicMessage("TOPIC_NAME", message);
} catch (ServiceException e) {
    e.printStackTrace();
}

I'm able to send a message with the same config values with .NET code.

And here is the exception that I receive: "com.sun.jersey.api.client.UniformInterfaceException: POST https://NAMESPACE.servicebus.windows.net/TOPIC_NAME/messages?api-version=2013-07 returned a response status of 500 Internal Server Error"

I have also a question about api-version. Why a library put so old api-version in the request? I use the latest version of azure sdk from maven repository:

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-servicebus</artifactId>
    <version>0.9.3</version>
</dependency>

I tried to reproduce your issue, but failed to not get any error information.

According to the REST API “Send Message” , the 500 status code means internal error that's not caused by your client source code.

So I think you can try to run the code again.

Could you share more information for helping analyze the issue if you still get the same error or others?

Any concern, please feel free to let me know.

I finally manage to find the reason of the issue. The real error is "There is no matching subscription found for the message with MessageId ..". This error occurs when in a topic configuration an option "Filter message before publishing" is checked and no matching subscription exists.

The problem is that a call to Azure REST API, which is used by Azure Java SDK, instead of information about no matching subscription found, returns just 500 Internal Server Error.. Only a call from Azure .NET SDK returns an exception with a useful comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM