Skip to content

Conversation

@Navyatha-reddi
Copy link

@Navyatha-reddi Navyatha-reddi commented Jun 12, 2020

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

@Navyatha-reddi Navyatha-reddi force-pushed the 2.0.0-maintenance branch 5 times, most recently from b3be3d6 to 9ee48ff Compare June 13, 2020 10:37
@Christoffer-Cortes
Copy link
Contributor

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;
Copy link
Contributor

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")){
Copy link
Contributor

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?

Copy link
Author

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.

@Navyatha-reddi Navyatha-reddi force-pushed the 2.0.0-maintenance branch 3 times, most recently from 19f7964 to 0571e54 Compare June 16, 2020 06:13
if(port==5672){
rabbitPort=15672;
}
rabbitManagementTemplate = new RabbitManagementTemplate("http://"+host+":"+rabbitPort+"/api/",user,password);
Copy link
Contributor

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.

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);

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.

Copy link
Author

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.

Copy link
Contributor

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 ?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

@tobiasake tobiasake Jun 23, 2020

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.

Copy link
Author

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".

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)

Copy link
Contributor

@tobiasake tobiasake Jul 7, 2020

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

Copy link
Contributor

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.

Copy link
Contributor

@tobiasake tobiasake left a 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.

@Navyatha-reddi
Copy link
Author

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.

@tobiasake
Copy link
Contributor

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.
I see that you are using some RabbitAdmin library,, I guess that is a RabbitMq API specific library, does that work with normal AMQP standards and Qpid which is the embedded AMQP server that is used for functional tests.
If RabbitAdmin only works with RabbitMq and not AMQP in general, then I guess this is only possible to test as an integrationTests. I think we have the integrationTests in the EI-Frontend, which tests both backend and frontend .. ?
Someone can correct me if I am wrong!
From that test framework we use docker-compose and RabbitMq AMQP server.
In that test framework we could add integration test which tests start EI-backend with one bindingkey and then restart EI-Backend with new bindingkey and check RabbitMq queue if bindinkey has changed and also check that MongoDB bindingKey collection has removed the old bindingKey and newBindingkey has been added.
What is your ideas about testing this? @e-pettersson-ericsson @Christoffer-Cortes

@Christoffer-Cortes
Copy link
Contributor

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.
I see that you are using some RabbitAdmin library,, I guess that is a RabbitMq API specific library, does that work with normal AMQP standards and Qpid which is the embedded AMQP server that is used for functional tests.
If RabbitAdmin only works with RabbitMq and not AMQP in general, then I guess this is only possible to test as an integrationTests. I think we have the integrationTests in the EI-Frontend, which tests both backend and frontend .. ?
Someone can correct me if I am wrong!
From that test framework we use docker-compose and RabbitMq AMQP server.
In that test framework we could add integration test which tests start EI-backend with one bindingkey and then restart EI-Backend with new bindingkey and check RabbitMq queue if bindinkey has changed and also check that MongoDB bindingKey collection has removed the old bindingKey and newBindingkey has been added.
What is your ideas about testing this? @e-pettersson-ericsson @Christoffer-Cortes

@Christoffer-Cortes
Copy link
Contributor

Sorry about the closing. =P Github reply/comment can be a bit confusing at times.
Anyway, either an integration test with docker components in the frontend if there is a way to programmatically restart a docker component... or a functionaltest and do like in scaling and failover test and start/close spring application from the code.

Copy link
Contributor

@tobiasake tobiasake left a 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.

@SantoshNC68
Copy link
Member

Merging the PR.

@SantoshNC68 SantoshNC68 merged commit c373473 into eiffel-community:2.0.0-maintenance Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants