11.7. Setting Connection Options
There are two different ways to set connection options. The first is to do it in the Connection constructor:
- Python
connection = Connection("localhost:5672", reconnect = True, reconnect_urls = "amqp:tcp:127.0.0.1:5674", heartbeat = 1) try: connection.open()
- C++
Connection connection("localhost:5672", "{reconnect: true, reconnect_urls:'amqp:tcp:127.0.0.1:5674', reconnect:true, heartbeat: 1}"); try { connection.open();
- .NET/C#
Connection connection= new Connection("localhost:5672", "{reconnect: true, reconnect_urls:'amqp:tcp:127.0.0.1:5674', reconnect:true, heartbeat: 1}"); try { connection.Open();
The second approach is to do it through the Connection properties:
- Python
connection = Connection("localhost:5672") connection.reconnect = True try: connection.Open()
- C++
Connection connection("localhost:5672"); connection.setOption("reconnect", true); try { connection.open();
- .NET/C#
Connection connection = new Connection("localhost:5672"); connection.SetOption("reconnect", true); try { connection.Open();