无法使用 Azure 服务总线发送消息
Not able to send the message using Azure service bus
Dotnet 示例 (send/receive) 工作正常。
来自 java 我无法发送消息,但接收消息正常。
private boolean connectServer()
{
try {
if (null != senderClient) return true;
senderClient = new ServiceBusClientBuilder()
.connectionString(connectionString)
.transportType(AmqpTransportType.AMQP_WEB_SOCKETS)
.sender()
.queueName(queueName)
.buildAsyncClient();
return true;
}
catch (Exception ex)
{
System.out.println(ex);
return false;
}
}
public boolean sendMessage(String message) throws InterruptedException {
try {
connectServer();
senderClient.sendMessage(new ServiceBusMessage(BinaryData.fromString(message)));
return true;
}
catch (Exception ex)
{
System.out.println(ex);
return false;
}
}
我没有收到任何错误。在Azure portal --> Overview
。我可以看到多个 传入请求 但 传入消息 为 0。
问题请参考以下代码
ServiceBusSenderClient senderClient = new ServiceBusClientBuilder()
.connectionString(connectionString)
.sender()
.queueName(queueName)
.buildClient();
ServiceBusMessage message = new ServiceBusMessage("Hello world!");
senderClient.sendMessage(message);
System.out.println("Sent messages to the queue: " + queueName);
Dotnet 示例 (send/receive) 工作正常。 来自 java 我无法发送消息,但接收消息正常。
private boolean connectServer()
{
try {
if (null != senderClient) return true;
senderClient = new ServiceBusClientBuilder()
.connectionString(connectionString)
.transportType(AmqpTransportType.AMQP_WEB_SOCKETS)
.sender()
.queueName(queueName)
.buildAsyncClient();
return true;
}
catch (Exception ex)
{
System.out.println(ex);
return false;
}
}
public boolean sendMessage(String message) throws InterruptedException {
try {
connectServer();
senderClient.sendMessage(new ServiceBusMessage(BinaryData.fromString(message)));
return true;
}
catch (Exception ex)
{
System.out.println(ex);
return false;
}
}
我没有收到任何错误。在Azure portal --> Overview
。我可以看到多个 传入请求 但 传入消息 为 0。
问题请参考以下代码
ServiceBusSenderClient senderClient = new ServiceBusClientBuilder()
.connectionString(connectionString)
.sender()
.queueName(queueName)
.buildClient();
ServiceBusMessage message = new ServiceBusMessage("Hello world!");
senderClient.sendMessage(message);
System.out.println("Sent messages to the queue: " + queueName);