69456

ActiveMQ - CreateSession failover timeout after a connection is resumed

I'm using ActiveMQ 5.6.0 and ActiveMQ NMS client.

I connect to the broker using the follow code:

var connectionFactory = new ConnectionFactory(
    "failover:(tcp://localhost:61616)?transport.timeout=5000"
    );

connection = connectionFactory.CreateConnection();    
connection.Start();

connection.ConnectionResumedListener += OnConnectionResumed;


Then I stop the broker and start it again. After that in the method OnConnectionResumed

private void OnConnectionResumed()
{
    var session = connection.CreateSession();

    ...
}


I always get the failover timeout exception when try to create a session.

What am I doing wrong?

Thanks

Answer1:

This problem appeared because I had created a session in the thread where the resumed call is made in.

The correct code is:

private void OnConnectionResumed()
{
    Task.Factory.StartNew(() =>
        {
            var session = connection.CreateSession();

            ...
        });
}

    

Recommend

  • Why do MongoDB docs recommend/insist on specific replica set priority configurations
  • Using jTDS to connect to SQL Server 2012 availability group listener
  • Hibernate web application with MySQL failover
  • infuriating heisenbug in Java/WAS 8.5 liberty profile on socket binding
  • How to handle mirrored(duplicated) iptables traffic after TEE?
  • How do you Configure the Connection String for ODP.NET Connection String with FailOver?
  • How is logback's “prudent mode” implemented?
  • Does Java's TCP Socket class block when sending data
  • Interprocess communication from SQL Server Project
  • How to implement TCP KeepAlive in VB.NET on a TCP Client(socket)
  • Boost asio socket: how to get your own IP, port adress?
  • Is it possible to find which user is at the other end of a localhost TCP connection?
  • Derby on Intellij
  • How do I check if a SSLSocket connection is sane on Java?
  • Windows Azure VM availability/Failover steps
  • How to setup a reverse proxy on several ports (tcp & udp)
  • How to use more than one custom filter invoked after each other?
  • How iperf calculates network statistics
  • PDO connection to MySQL database refused
  • Cannot log in using SQL authentication ONLY from a remote server
  • Mule ESB connecting to RabbitMQ
  • send mails via sendgrid
  • Remote debugging of a Java application launched as a Windows service
  • How can I do a 301 redirect from http to https in Wildfly 8.2?
  • How can I set the buffer size for the underneath Socket UDP?
  • Paramiko SSHException Channel Closed
  • Installing SSL on AWS EC2 Bitnami Mean Stack
  • How to make HttpWebRequest async
  • How secure are apple APNS push notifications?
  • How to map Request parameter in Spring?
  • JSON - slashes not escaping
  • CORS with socket.io
  • mave 3.2 not able to access local nexus instance return 502 code
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Tomcat memory Leak
  • Cannot upload to OneDrive using the new SDK
  • Cannot resolve symbol 'MyApi'
  • Ajax jQuery multiple calls at the same time - long wait for answer and not able to cancel
  • Hazelcast - OperationTimeoutException
  • File upload with ng-file-upload throwing error