I am trying to connect to a JMS topic in C# using the Apache.NMS.ActiveMQ library. When trying to connect I get the following error "Error creating transport".
Here is my code.
try
{
Uri uri = new Uri("remoting://" + textBoxIPAddress.Text + ":" + textBoxPort.Text);
ConnectionFactory connectionFactory = new ConnectionFactory(uri);
LogService.Warning("CONNECTING TO: activemq:tcp://" + textBoxIPAddress.Text + ":" + textBoxPort.Text);
// create a connection
if (username != null && password != null)
this.connection = await connectionFactory.CreateConnectionAsync(username, password);
else
textBoxMessages.Text = "INSERT USERNAME AND PASSWORD";
if (this.connection != null)
{
await this.connection.StartAsync();
LogService.Warning("START CONNECTION!");
// create a session
this.session = await connection.CreateSessionAsync(AcknowledgementMode.AutoAcknowledge);
// get the destination
IDestination destination = await this.session.GetTopicAsync(topic);
LogService.Warning("GET TOPIC AND SUBSCRIBE TO IT!");
// create a MessageProducer from the session to the topic
this.consumer = await this.session.CreateConsumerAsync(destination);
this.consumer.Listener += Consumer_Listener;
}
}
catch (Exception e)
{
LogService.Warning("FAILED TO CONNECT TO THE TOPIC! " + e.Message);
}
When testing this on my local machine, running ActiveMQ on localhost I do not get this error. Any help or explanation on what I am doing wrong is appreciated. My goal connection is to subscribe to a topic running on WildFly.
Your connection URI is incorrect as you are passing "remoting://" to the connection factory which it would not know what to do with. Your logging statement indicates you wanted "activemq:tcp://" which would be more in line with what I'd expect from a client connection.
As Justin pointed out in his comment you also need to enable Openwire in Wildfly as it isn't supported out of the box.