You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by davsclaus <ci...@yahoo.dk> on 2011/03/07 17:25:56 UTC

Re: [EIP] Can you please help me choose a correct design pattern ?

Welcome to the Camel community

The pattern you talk about smells like the composite message processor
http://camel.apache.org/composed-message-processor.html

Its in the EIP book as well.

However in your case you don't split a message beforehand, but send a
message to 2 clients.

In Camel you could do something like (pseudo code)

from(client)
to(a)
to(b)

from(client-replies)
aggregate
   correlate using some sort of ID so you can "pair" replies
   completionSize = 2
   to(okay msg received)
   // finish


See more details about the Aggregate pattern
http://camel.apache.org/composed-message-processor.html

Also its in chapter 8 in the book.



--
View this message in context: http://camel.465427.n5.nabble.com/EIP-Can-you-please-help-me-choose-a-correct-design-pattern-tp3412244p3412683.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: [EIP] Can you please help me choose a correct design pattern ?

Posted by Maxence Button <ma...@gmail.com>.
Hi James !

Thanks for spending time in helping me out !
Okay, about the completion predicate, is that a custom Predicate I have to
code or is it a built-in function ?
Anyway, I guess that solves one of my problem 

When you say there's no concurrency in my system, that's not exactly true. I
may have some but I doesn't matter : my system has to be able to receive
messages when they come, whereas it's in a sequential or parallel way.
Also, there's no pre-defined order or some pre-sorting : I just have to
react when a message arrives !
It is my mistake that I took the "order" example : I wanted a simple example
for you guys to be able to figure out what I'm talking about. But my system
has nothing to do with that example.

In fact, I'm gonna detail my need to be sure we're dealing with the same
thing.
My process is a daily process, it means that everyday, a brand new process
is started and at the end of the day, it's normally closed.
It's composed of 15 steps, that are sequentially executed. Say that Step1 is
started in the morning and when it's complete, it sends a message to starts
Step2 and so on, until Step15 is over in its turn, at then end of the day.

Step1 is as follow :
It's complete when it has received MSG1, MSG2 & MSG3.
MSG1 is sent when MSGA & MSGB have been received by a subprocess. Same
principle for MSG2 & MSG3.
I hope you're still with me at this point  ...

Explained another way :
SubProcess receives MSGA or MSGB (the order does not matter) and then
receives the other one. That triggers the sending of MSG1 which is expected
by Step1. But Step1 could have first received MSG2 or MSG3 : the only thing
that matters is that Step1 ends when it's got all the required messages.
(and it could receive several times the same message, as long as the
sequence is not over).

That's why I was interested in the Aggregator pattern because it is the only
one which describes the reception of several messages to be able to proceed
further. But I do NOT need to aggregate them. 
It's a simple event management : when MSG1 & MSG2 are received, MSG3 is sent
(and has nothing to do with MSG1 & MSG2 bodies).
Ex : US_Done & Canada_Done => North_America_Done

You talked about a the filter pattern, it could be interesting but I don't
see how to use it in my case.
How to define a route that has three filters and that knows when the three
filters have been successfully triggered ?
I'm kinda WLI blinded : I'm just trying to get away from that way of seeing
things, but it's pretty hard.

Hope I was clear enough (sometimes, it is for me but unfortunately not for
the others )
Don't hesitate to question me if you need me to explain further or
differently.

Again, thanks for your time and for your quick answers !

Regards,
Maxence.



--
View this message in context: http://camel.465427.n5.nabble.com/EIP-Can-you-please-help-me-choose-a-correct-design-pattern-tp3412244p3413935.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: [EIP] Can you please help me choose a correct design pattern ?

Posted by James Strachan <ja...@fusesource.com>.
On 8 March 2011 09:59, Maxence Button <ma...@gmail.com> wrote:
> Hi Claus !
>
> Thank you for welcoming me in the Camel community. I'm honored that you
> replied to my question .
>
> Yet, I'm afraid it's not that simple : as I wrote it earlier, I played with
> the Aggregator and I guess it's almost what I'm looking for. I came to that
> pattern thanks to your book and the other reference book about EIP.
> What I have doubts about is the completion criteria. The case I described
> was voluntarily simplified but my patterns are much more complex.
>
> For instance, I have a process that should be able to receive an
> undetermined number of messages (let's say of type "Item") and when a single
> message "EndOfOrder" is received, then the process sends another message on
> the message broker saying the order has been completed. And that message
> triggers another process and so on.

So the completion predicate is then an expression detecting the
EndOfOrder message.


> About the correlation, I had exactly the same "problem" with BPEL process
> manager : my messages have no correlation between them : they come from
> different routes linked to different partners who have nothing in common. I
> was forced to trick the system by asking all the partners to enter a fake
> property on which I could base my correlation. It's working but I'm not
> fully satisfied with it ...

So there is no concurrency in your system and all messages arrive in
the exact order, pre sorted into aggregation pairs right? OrderA,
Order B, EndOfOrder then OrderC, OrderD, EndOfOrder etc? Things never
get mixed up out of order on a route?

If there is no correlation at all between the messages, then all
messages correlate with each other. So just use a constant expression
for the correlation key, like "foo".


> What I'm looking for, is exactly the Oracle | BEA WLI message broker feature
> : channels with components listening for some messages, matching the
> criteria I've defined, that's all. No correlation needed.

If there's no correlation or aggregation and its just a filter, then
this sounds like a message filter?
http://camel.apache.org/message-filter.html

But your previous post sounded like you were trying to aggregate
messages together; that is that when you have completed a set of
messages you want to send a message (but only when a set is complete).
So its sounding like an Aggregator; the difference is that there's no
correlation required as everything arrives in order - and you don't
need to aggregate the messages together as you are sending a constant
message at the end. But other than that its sounding like an
aggregator where you either use a fixed batch size or a completion
predicate (detecting the EndOfOrder message)?

-- 
James
-------
FuseSource
Email: james@fusesource.com
Web: http://fusesource.com
Twitter: jstrachan
Blog: http://macstrac.blogspot.com/

Open Source Integration

Re: [EIP] Can you please help me choose a correct design pattern ?

Posted by Maxence Button <ma...@gmail.com>.
Hi Claus !

Thank you for welcoming me in the Camel community. I'm honored that you
replied to my question .

Yet, I'm afraid it's not that simple : as I wrote it earlier, I played with
the Aggregator and I guess it's almost what I'm looking for. I came to that
pattern thanks to your book and the other reference book about EIP.
What I have doubts about is the completion criteria. The case I described
was voluntarily simplified but my patterns are much more complex.

For instance, I have a process that should be able to receive an
undetermined number of messages (let's say of type "Item") and when a single
message "EndOfOrder" is received, then the process sends another message on
the message broker saying the order has been completed. And that message
triggers another process and so on.

About the correlation, I had exactly the same "problem" with BPEL process
manager : my messages have no correlation between them : they come from
different routes linked to different partners who have nothing in common. I
was forced to trick the system by asking all the partners to enter a fake
property on which I could base my correlation. It's working but I'm not
fully satisfied with it ...

What I'm looking for, is exactly the Oracle | BEA WLI message broker feature
: channels with components listening for some messages, matching the
criteria I've defined, that's all. No correlation needed.

First, my team and I wanted to implement that solution using topics & MDBs,
aiming at full stateless solution (to meet our scalability requirements) but
we thought it would be reinventing the wheel. So we naturally thought of
Camel, but from what I read it does not propose the exact solution (which is
pretty normal I guess), but I hope we can build it around Camel though.

As you designed the Aggregator pattern, you're my best shot to understand
whether it will fit my need or not.

Thank you for your patience and your time.

Best regards,
Maxence.

--
View this message in context: http://camel.465427.n5.nabble.com/EIP-Can-you-please-help-me-choose-a-correct-design-pattern-tp3412244p3413734.html
Sent from the Camel - Users mailing list archive at Nabble.com.