Skip to content
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

Issue with Entity Manager when using in worker #91

Open
mrvnklm opened this issue Jul 22, 2018 · 3 comments
Open

Issue with Entity Manager when using in worker #91

mrvnklm opened this issue Jul 22, 2018 · 3 comments

Comments

@mrvnklm
Copy link

mrvnklm commented Jul 22, 2018

Hey, I inject my entity manager into the worker via dependency injection and I receive following error when running the worker:

Detached entity Dtc\QueueBundle\Entity\Run@0000000078ced8230000000079c36310 cannot be removed

Is that because the bundle is using a different em? Actually I configured it to use the default orm.

EDIT:
I figured out passing the class is not a problem, but inside the worker I need to use its own EntityManager like the following:
public function getProducts(Customer $customer) { $customer = $this->entityManager->find('App:Customer', $customer->getId()); ...

Would that be the right way or should I pass the EM aswell?

@maikelreyes
Copy link

I'm issuing the same problem...any tips for this?

@mrvnklm
Copy link
Author

mrvnklm commented Jan 18, 2019

@maikelreyes Well, I think I've learned that passing objects as argument isn't the best way to go. Especially if you switch from using ORM driven queue to RabbitMQ for example (which I would recommend due to performance and stability), you can't pass objects anymore and you should use IDs. So when I switched to IDs, I haven't had any issues like that anymore.

@klodoma
Copy link
Contributor

klodoma commented Aug 26, 2019

Ok, I kind of understand what happens.

In my case I passed an entity object to the worker. Indeed the worker uses a different entity manager, because it's a different PHP process, it makes sense.

Not sure if "passing objects as argument isn't the best way to go", but indeed this can be very tricky, depending on what is passed on.

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

No branches or pull requests

3 participants