You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes your connection information may need to be dynamic. Dynamic connection parameters allow you to supply or
override parameters programmatically through a service.
e.g. In a scenario when the `vhost` parameter of the connection depends on the current tenant of your white-labeled
application and you do not want (or can't) change it's configuration every time.
Define a service under `connection_parameters_provider` that implements the `ConnectionParametersProviderInterface`,
and add it to the appropriate `connections` configuration.
```yaml
connections:
default:
host: 'localhost'
port: 5672
user: 'guest'
password: 'guest'
vhost: 'foo' # to be dynamically overridden by `connection_parameters_provider`
connection_parameters_provider: connection_parameters_provider_service
```
Example Implementation:
```php
class ConnectionParametersProviderService implements ConnectionParametersProvider {
...
public function getConnectionParameters() {
return array('vhost' => $this->getVhost());
}
...
}
```
In this case, the `vhost` parameter will be overridden by the output of `getVhost()`.
Copy file name to clipboardExpand all lines: README.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,6 +184,42 @@ by default to avoid possible breaks in applications already using this bundle.
184
184
185
185
It's a good idea to set the ```read_write_timeout``` to 2x the heartbeat so your socket will be open. If you don't do this, or use a different multiplier, there's a risk the __consumer__ socket will timeout.
186
186
187
+
### Dynamic Connection Parameters ###
188
+
189
+
Sometimes your connection information may need to be dynamic. Dynamic connection parameters allow you to supply or
190
+
override parameters programmatically through a service.
191
+
192
+
e.g. In a scenario when the `vhost` parameter of the connection depends on the current tenant of your white-labeled
193
+
application and you do not want (or can't) change it's configuration every time.
194
+
195
+
Define a service under `connection_parameters_provider` that implements the `ConnectionParametersProviderInterface`,
196
+
and add it to the appropriate `connections` configuration.
197
+
198
+
```yaml
199
+
connections:
200
+
default:
201
+
host: 'localhost'
202
+
port: 5672
203
+
user: 'guest'
204
+
password: 'guest'
205
+
vhost: 'foo' # to be dynamically overridden by `connection_parameters_provider`
class ConnectionParametersProviderService implements ConnectionParametersProvider {
213
+
...
214
+
public function getConnectionParameters() {
215
+
return array('vhost' => $this->getVhost());
216
+
}
217
+
...
218
+
}
219
+
```
220
+
221
+
In this case, the `vhost` parameter will be overridden by the output of `getVhost()`.
222
+
187
223
## Producers, Consumers, What? ##
188
224
189
225
In a messaging application, the process sending messages to the broker is called __producer__ while the process receiving those messages is called __consumer__. In your application you will have several of them that you can list under their respective entries in the configuration.
0 commit comments