英文:
Connecting to http-remoting address in Wildfly ActiveMQ Artemis using C# .NET - what am I missing?
问题
我有一个运行ActiveMQ Artemis的Wildfly实例。如何在C# .NET中设置并连接到地址"http-remoting://x.x.x.x:xxxx",并使用用户名和密码?
string url = "amqp://" + username + ":" + password + "@" + ipAddress + ":" + port;
try
{
var address = new Address(url);
connection = new Connection(address);
session = new Session(connection);
Source source = CreateBasicSource();
// 创建一个持久性消费者Source。
source.Address = topic;
source.ExpiryPolicy = new Symbol("never");
source.Durable = 2;
source.DistributionMode = new Symbol("copy");
ReceiverLink receiver = new ReceiverLink(session, "test-subscription", source, null);
LogService.Warning("Connected successfully to: " + url);
Consumer_Listener(receiver);
}
catch (Exception e)
{
LogService.Warning("Failed to connect! " + e.Message);
}
上述代码在连接到地址"amqp://x.x.x.x:xxxx"时工作正常,但如果我尝试更改地址为"http-remoting://x.x.x.x:xxxx",则不起作用。我不确定如何更改我的代码,以便它能够连接到我想要的地址。
英文:
I have a Wildfly instance running ActiveMQ Artemis. How can I set up and connect to an address "http-remoting://x.x.x.x:xxxx" in C# .NET with using a username and password?
string url = "amqp://" + username + ":" + password + "@" + ipAddress + ":" + port;
try
{
var address = new Address(url);
connection = new Connection(address);
session = new Session(connection);
Source source = CreateBasicSource();
// Create a Durable Consumer Source.
source.Address = topic;
source.ExpiryPolicy = new Symbol("never");
source.Durable = 2;
source.DistributionMode = new Symbol("copy");
ReceiverLink receiver = new ReceiverLink(session, "test-subscription", source, null);
LogService.Warning("Connected succesfully to: " + url);
Consumer_Listener(receiver);
}
catch (Exception e)
{
LogService.Warning("Failed to connect! " + e.Message);
}
The above code works, when connecting to an address "amqp://x.x.x.x:xxxx", but does not work if I try to change the address to "http-remoting://x.x.x.x:xxxx". I am unsure on how to change my code, so that it will connect to my desired address.
答案1
得分: 1
"http-remoting"方案由Java WildFly客户端实现,通常用于在消息上下文中查找JNDI中的JMS ConnectionFactory
和Destination
。当然,使用AMQP的C# .NET消息客户端对JNDI没有概念或需求,因为那确实是Java特定的东西。
你遇到的问题是WildFly默认未配置为支持AMQP。即使ActiveMQ Artemis是一个多协议代理,WildFly实际上只是使用它来支持JMS,因此它只配置了这一点。要启用对AMQP的支持,您需要添加新的remote-acceptor
和新的socket-binding
,例如:
<server>
...
<profile>
...
<subsystem xmlns="urn:jboss:domain:messaging-activemq:15.0">
<server name="default">
...
<remote-acceptor name="amqp" socket-binding="amqp">
<param name="protocols" value="AMQP"/>
</remote-acceptor>
...
</server>
</subsystem>
...
</profile>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<socket-binding name="amqp" port="5672"/>
...
</socket-binding-group>
</server>
英文:
The "http-remoting" scheme is implemented by the Java WildFly client and it's used for various things, but in the messaging context it's usually used to look up the JMS ConnectionFactory
and Destination
in JNDI. Of course, a C# .NET messaging client that speaks AMQP has no notion or need of JNDI since that's really a Java-specific thing.
The issue you're hitting is that WildFly, by default, isn't configured to support AMQP. Even though ActiveMQ Artemis is a multi-protocol broker WildFly really just uses it for JMS support so that's all it's configured for out-of-the-box. In order to enable support for AMQP you'd need to add a new remote-acceptor
as well as a new socket-binding
, e.g.:
<server>
...
<profile>
...
<subsystem xmlns="urn:jboss:domain:messaging-activemq:15.0">
<server name="default">
...
<remote-acceptor name="amqp" socket-binding="amqp">
<param name="protocols" value="AMQP"/>
</remote-acceptor>
...
</server>
</subsystem>
...
</profile>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<socket-binding name="amqp" port="5672"/>
...
</socket-binding-group>
</server>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论