更新时间:2023-12-01 07:49:45
带有QPID Proton库的QPID Java Broker可以正确进行匿名身份验证.
QPID Java Broker with QPID Proton library works without error for anonymous authentication.
请按照以下步骤操作,以避免QPID Java Broker 0.32的连接中止.
Please follow below steps to avoid connection abort for QPID Java Broker 0.32.
并单击添加提供者",输入以下详细信息并保存, 名称:匿名 类型:匿名
And click "Add Provider" enter following details and save, Name: anonymous Type: Anonymous
现在,再次转到代理"选项卡,然后向下滚动以找到端口"-AMQP.单击AMQP进行编辑.从下拉菜单中选择您在上面的步骤3中创建的身份验证提供程序",然后保存.
Now again, go to "Broker" tab and scroll down to locate "Ports" - AMQP. Click AMQP to edit. Select "Authentication Provider" to the one you have created in step #3 above from the drop-down and save.
尝试您的测试代码
在需要的情况下,这里是工作样本:
Here is the working sample in case required:
private static final String address = "amqp://guest:guest@localhost:5672/"; // (format : QPIDPortName://user:password@host:port you may use admin:admin as well if not removed from default setting by your administrator)
private static final String exchangeName = "MYTOPIC-EXCHANGE"; // First create this exchange in QPID Broker!
private static final String publishToAddress = new StringBuilder().append(address).append(exchangeName).toString();
public static boolean publishMessage(String msg)
{
boolean isMsgDelivered = false;
ApplicationProperties customAppProperties = null;
try
{
Messenger messenger = Proton.messenger();
messenger.start();
Message message = Proton.message();
message.setAddress(publishToAddress);
message.setContentEncoding("UTF-8");
message.setContentType("text/plain");
message.setSubject(exchangeName);
Section sec = new AmqpValue(msg);
message.setBody(sec);
messenger.put(message);
messenger.send();
messenger.stop();
isMsgDelivered = true;
}
catch (Exception e)
{
logger.log(Level.SEVERE, "Qpid Proton error: "+ e.getMessage(), e);
e.printStackTrace();
}
return isMsgDelivered;
}