-
Notifications
You must be signed in to change notification settings - Fork 36
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
Comments
I'm issuing the same problem...any tips for this? |
@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. |
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. |
Hey, I inject my entity manager into the worker via dependency injection and I receive following error when running the worker:
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?
The text was updated successfully, but these errors were encountered: