You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Erol <er...@erol.si> on 2017/02/14 16:33:41 UTC

Implementing custom endpoint with multiple methods or custom beans

Hello

I'm building a simple app to connect filesystem with magento (using rest
API). I have 2 flows:

- read stock.txt -> parse stock -> send updated stock to magento
- read periodically orders from magento -> map to object -> write file to
orders.xml

How I currently solve this is:

- use file component to read stock.txt -> bindy to parse csv -> bean to
update magento
- timer with period -> bean to read orders -> xml marshal -> use file
component to write

This works, but I feel like it's not correct. My next goal is to replace
magento beans with magento endpoint. So I can write

- use file component to read stock.txt -> bindy to parse csv -> to endpoint
magento with method updatestock
- from magento orders read periodically -> xml marshal -> file component to
write

The flow looks much more clear. But is this correct way?

If I implement this as an endpoint, then if I want to support all methods
(magento rest calls) in Producer and Consumer, code becomes huge and it's
not nicely separated as with beans. But on the other hand, it looks more
correct from flow point-of-view. Other idea is to have multiple endpoints
(magento-orders, magento-stocks, ..).

What is the correct way to implement this?



--
View this message in context: http://camel.465427.n5.nabble.com/Implementing-custom-endpoint-with-multiple-methods-or-custom-beans-tp5793884.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Implementing custom endpoint with multiple methods or custom beans

Posted by Erol <er...@erol.si>.
Giovanni, thank you again for your reply.

Just to clarify what I did. I ended up using custom components (sure I spent
more time) but the final result is much better.

Thank you again for all your help



--
View this message in context: http://camel.465427.n5.nabble.com/Implementing-custom-endpoint-with-multiple-methods-or-custom-beans-tp5793884p5794340.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Implementing custom endpoint with multiple methods or custom beans

Posted by "Condello, Giovanni" <g....@techgap.it>.
Hi,

unfortunately I cannot show any code, but we basically followed these:

http://camel.apache.org/creating-a-new-camel-component.html
http://camel.apache.org/writing-components.html

Plus we took some ideas from the direct and jms endpoints source code.

That being said, again, if the Magento talks over REST I would use a
properly configured set of http4 routes
(http://camel.apache.org/http4.html) instead of rolling my own
component

Giovanni

2017-02-15 20:41 GMT+01:00 Erol <er...@erol.si>:
> Giovanni, thank you for your reply.
>
> Can you please tell me more about your custom endpoint? Any tips how to
> correctly structure it?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Implementing-custom-endpoint-with-multiple-methods-or-custom-beans-tp5793884p5793932.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Implementing custom endpoint with multiple methods or custom beans

Posted by Erol <er...@erol.si>.
Giovanni, thank you for your reply.

Can you please tell me more about your custom endpoint? Any tips how to
correctly structure it?



--
View this message in context: http://camel.465427.n5.nabble.com/Implementing-custom-endpoint-with-multiple-methods-or-custom-beans-tp5793884p5793932.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Implementing custom endpoint with multiple methods or custom beans

Posted by Giovanni Condello <g....@techgap.it>.
Hi,

I don't think there's a "correct" way of doing things. It's just a matter
of usability vs time invested. As an example, we started by wrapping a
proprietary Java API inside a camel processor and just recently we went all
in by writing a custom camel endpoint for it.

That being said, if magento talks REST over HTTP I'd definitely start by
using the http4 camel component instead of writing custom beans.

Cheers ,
Giovanni

Il mar 14 feb 2017, 19:23 Erol <er...@erol.si> ha scritto:

> Hello
>
> I'm building a simple app to connect filesystem with magento (using rest
> API). I have 2 flows:
>
> - read stock.txt -> parse stock -> send updated stock to magento
> - read periodically orders from magento -> map to object -> write file to
> orders.xml
>
> How I currently solve this is:
>
> - use file component to read stock.txt -> bindy to parse csv -> bean to
> update magento
> - timer with period -> bean to read orders -> xml marshal -> use file
> component to write
>
> This works, but I feel like it's not correct. My next goal is to replace
> magento beans with magento endpoint. So I can write
>
> - use file component to read stock.txt -> bindy to parse csv -> to endpoint
> magento with method updatestock
> - from magento orders read periodically -> xml marshal -> file component to
> write
>
> The flow looks much more clear. But is this correct way?
>
> If I implement this as an endpoint, then if I want to support all methods
> (magento rest calls) in Producer and Consumer, code becomes huge and it's
> not nicely separated as with beans. But on the other hand, it looks more
> correct from flow point-of-view. Other idea is to have multiple endpoints
> (magento-orders, magento-stocks, ..).
>
> What is the correct way to implement this?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Implementing-custom-endpoint-with-multiple-methods-or-custom-beans-tp5793884.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>