-
Notifications
You must be signed in to change notification settings - Fork 73
Old bindingkey is removed if binding key is changed in configuration #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Old bindingkey is removed if binding key is changed in configuration #468
Conversation
…oved from mb queue
b3be3d6 to
9ee48ff
Compare
9ee48ff to
14c637e
Compare
|
There is an error with that new bean: Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rmqHandler': Unsatisfied dependency expressed through field 'rabbitManagementTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deleteBindingKeys' defined in class path resource [com/ericsson/ei/handlers/RmqHandler.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.core.RabbitManagementTemplate]: Circular reference involving containing bean 'rmqHandler' - consider declaring the factory method as static for independence from its containing instance. Factory method 'deleteBindingKeys' threw exception; nested exception is org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:15672/api/bindings/": Connect to localhost:15672 [localhost/127.0.0.1] failed: Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:15672 [localhost/127.0.0.1] failed: Connection refused (Connection refused) |
|
|
||
| @Bean | ||
| public RabbitManagementTemplate deleteBindingKeys() { | ||
| Integer rabbitPort=port; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use primitive type int?
| public RabbitManagementTemplate deleteBindingKeys() { | ||
| Integer rabbitPort=port; | ||
| String rabbitHttp = "https://"; | ||
| if(port==5672 && host.equals("localhost")){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the logic behind this code block? The API is exposed through the management page usually located at 15672 but if the port is anything other than 5672 we don't attempt to redirect to the website API? Won't this fail unless the user specifially configures the API url?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,Actually for removing old binding keys we have gone through some websites on google, and found out the RabbitManagementTemplate to remove the old binding keys and used for implementation. So as part of it we are facing issues with RabbitManagementTemplate in test class. So we tried to solve it with this kind of approach, just for testing purpose.
19f7964 to
0571e54
Compare
0571e54 to
b2f72a0
Compare
| if(port==5672){ | ||
| rabbitPort=15672; | ||
| } | ||
| rabbitManagementTemplate = new RabbitManagementTemplate("http://"+host+":"+rabbitPort+"/api/",user,password); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if un-secure http is disabled and only https is available in target environment?
Then this implementation will not work, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is other Eiffel component handling restart of Eiffel components with new bindingKey ?
This binding change will happen from some of the Eiffel components, but rebind is not implemented in Eiffel components.
| if(port==5672){ | ||
| rabbitPort=15672; | ||
| } | ||
| rabbitManagementTemplate = new RabbitManagementTemplate("http://"+host+":"+rabbitPort+"/api/",user,password); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RabbitManagementTemplate will use the http calls to connect with RabbitMQ and RabbitTemplate uses the amqp. both implementations are different. so better to change the new implementation to amqp based.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per raja's comment, we have investigated for the other way of getting the binding keys form the RabbitMq,but rather that RabbitManagmentTemplate/Client we couldn't find any way to fetch the list of bindings using current EI implementation (Spring AMQP). Also digged into the code level referring the RabbitTemplate, channels and connectionFactory but there is no such functionality to get the bindingKeys.
So other way of approach for this implementation is using files, i.e to store the binding keys into the file/List and check with the existing bindingkeys, add or update the file with the required binding keys on EI start. The file gets updated when the binding configuration is changed.With this approach the manually created bindings cannot be retrieved which in turn cannot be deleted from the code.
Please suggest if this can be implemented in any other way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is other Eiffel component handling restart of Eiffel components with new bindingKey ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't EI create a new queue with the new BindingKey name as suffix to the queue name and let the administrator choose to do with old queue and old event data, if it should be kept or removed.
EI starts to consume messages from new queue with new binding key(s) when started with new binding keys.
By doing that we don't wipe any persistent data or what it can cause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or if the administrator want the old queue and old bindingkeys to be removed automatically, set durable queue flag to False and old queue+bindingkeys will be removed automatically at shutdown and when EI starts a new queue will be created with new bindingkey(s), if I understand it correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only solution is to bind and unbind the queue when EI starts and shutdowns.
Since EI is not aware of previous binding keys used in other/previous running EI instances.
Documentation
https://pika.readthedocs.io/en/latest/modules/channel.html?highlight=bind#pika.channel.Channel.queue_unbind
If I understand what you trying to achieve.
I thinks its not safe/secure to let next EI instance to figure out what previously binding key was used and remove it.
Other option is what I commented about in previous comment, create a new queue with the new binding key and let rabbitmq remove the old queue+bindingkey with Queue TTL flag.
These two options is what I can find currently, but maybe it exist more options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a discussion regarding the implementation way and the proposed solution suggested in the meeting is to use mongodb collection to store the binding keys and use the collection for removing the binding keys and updating the new binding keys.
Will start the implementation using mongo db with collection name "BindingKeys".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we see this behavior on latest version of Eiffel Intelligence (and I think it is the same) we will need to transfer this fix also to the master branch, which will be included in an upcoming 4.x release (when the API versioning has been added)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't "binding-keys" better collection name,, then its easier to administrate MongoDb if using mongo client command and typing the collection name in mongo shell.
Its easier to type only lower letters in the shell, instead typing mix of lower and upper letters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This collection need to be unique also for each EI instance if same mongodb is used, so collection name need to be configurable from application.config.
So we get unique collection name per instance, if same MongoDb is used.
Same MongoDb is used by tests and also in Easy2Use, maybe in other setups as well.
tobiasake
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And tests is missing.
Tried implementing the test scenario for the binding keys stored in mongodb. Please help me out in any changes or any test cases to be added. |
|
|
|
Sorry about the closing. =P Github reply/comment can be a bit confusing at times. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will not be available coming weeks, so I will have no possibility to review coming changes on this PR.
So I set this to Approve for removing my "Request Changes" state on the PR.
If others review and Approve the change, then its ok to merge.
|
Merging the PR. |
Applicable Issues
Description of the Change
If binding key is changed in configuration, the old bindingkey is removed from mb queue.
Alternate Designs
Benefits
Reduction in conflicts between the binding keys.
Possible Drawbacks
Sign-off
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
Signed-off-by: Navyatha Reddi navyatha.reddi@tcs.com, Durga vasaadi durga.vasaadi@tcs.com, Surya Kumari Kolli