You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Learn Learn <vi...@gmail.com> on 2007/11/01 21:53:00 UTC

ServiceMix Bean endpoint calling other endpoints...

Hi,

Can a Servicemix-bean endpoint call other endpoints? I realise that if we
implement the MessageExchangeListener, we wouldn't be able to do
so...nothing present in the MessageExchange object to set my target
Destination too..is there any other way of doing it? 

I need to do some routing in my Bean component (messages not XML based)
based on some business logic and decide my next in chain based on what my
routing logic evaluates to...similarly, if there is an exception somewhere,
I need to route to a ExceptionListener that we have that massages our
exception trace into a more amiable message..

Let me know if this can be done...if somebody has already done this and has
a little code to share, wonderful...

Thanks a lot for your help..

Victor
-- 
View this message in context: http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537231
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix Bean endpoint calling other endpoints...

Posted by MrRothstein <mr...@gmail.com>.
Take a look at the source code for some of the eip modules.  Also, look at
the ExchangeTarget class and how it's used. What Andy is suggesting is that
you do "manually" what the ExchangeTarget would do for you. You end up with
two message exchanges. One where you are the provider, the other where you
are the consumer.

For the exchange where you are the provider (assuming in-out), the bean has
to set the out message on the original, client sent, exchange. The client
will get that exchange back. For the exchange you create, you are the
consumer (again assuming in-out), the response will be in the form of an out
(or fault) message in the message exchange you create.


Learn Learn wrote:
> 
> That's an interesting way of doing it. How do you tie back your responses
> from the Exchanges? Do you use some kind of an interim store? Or do your
> clients get two responses and consider the first one to be an
> acknowledgement?
> 
> Basically, if I get in a sync/async request thru a Binding Component into
> the bus and I forward it to the bean component thru the NMR and later on
> create a new Exchange from the Bean Component...doesn't my client get two
> responses..first response after the bean endpoint creates and puts a new
> MessageExchange on the DC.. (since the first MessageExchange life is over
> and a blank response is sent back)..and the second response is the final
> response (the real one) through the new MessageExchange that should go
> back to the client ... hope that this is not a dumb question...Thanks for
> taking the time to answer this.
> 
> 
> 
> Mad Andy wrote:
>> 
>> Well, I am not here to give you free code or do your homework. The DC  
>> is enough to create a new ME through an exchange factory and then you  
>> can set the service name, endpoint or interface and its operation etc.  
>> Have a look at the JavaDoc and if everything else fails then you  
>> should try out something. The only thing I will say is that we use it  
>> this way !
>> 
>> Have fun
>> 
>> Andreas Schaefer
>> CEO of Madplanet.com Inc.
>> andreas.schaefer@madplanet.com
>> 
>> 
>> On Nov 1, 2007, at 2:13 PM, Learn Learn wrote:
>> 
>>>
>>> Well, that wont help me...that would only send back a response to my
>>> caller...what I want is to send this message across to some other  
>>> endpoint
>>> (determined thru business logic and configuration)
>>>
>>>
>>> Mad Andy wrote:
>>>>
>>>> Declare a Delivery Channel with the @Resource annotation and then use
>>>> the DC to create a ME, set the data and message and then send it.
>>>>
>>>> Have fun
>>>>
>>>> Andreas Schaefer
>>>> CEO of Madplanet.com Inc.
>>>> andreas.schaefer@madplanet.com
>>>>
>>>>
>>>> On Nov 1, 2007, at 1:53 PM, Learn Learn wrote:
>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> Can a Servicemix-bean endpoint call other endpoints? I realise that
>>>>> if we
>>>>> implement the MessageExchangeListener, we wouldn't be able to do
>>>>> so...nothing present in the MessageExchange object to set my target
>>>>> Destination too..is there any other way of doing it?
>>>>>
>>>>> I need to do some routing in my Bean component (messages not XML
>>>>> based)
>>>>> based on some business logic and decide my next in chain based on
>>>>> what my
>>>>> routing logic evaluates to...similarly, if there is an exception
>>>>> somewhere,
>>>>> I need to route to a ExceptionListener that we have that massages  
>>>>> our
>>>>> exception trace into a more amiable message..
>>>>>
>>>>> Let me know if this can be done...if somebody has already done this
>>>>> and has
>>>>> a little code to share, wonderful...
>>>>>
>>>>> Thanks a lot for your help..
>>>>>
>>>>> Victor
>>>>> -- 
>>>>> View this message in context:
>>>>> http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537231
>>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>>
>>>>
>>>>
>>>>
>>>
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537622
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13541160
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix Bean endpoint calling other endpoints...

Posted by Learn Learn <vi...@gmail.com>.
That's an interesting way of doing it. How do you tie back your responses
from the Exchanges? Do you use some kind of an interim store? Or do your
clients get two responses and consider the first one to be an
acknowledgement?

Basically, if I get in a sync/async request thru a Binding Component into
the bus and I forward it to the bean component thru the NMR and later on
create a new Exchange from the Bean Component...doesn't my client get two
responses..first response after the bean endpoint creates and puts a new
MessageExchange on the DC.. (since the first MessageExchange life is over
and a blank response is sent back)..and the second response is the final
response (the real one) through the new MessageExchange that should go back
to the client ... hope that this is not a dumb question...Thanks for taking
the time to answer this.



Mad Andy wrote:
> 
> Well, I am not here to give you free code or do your homework. The DC  
> is enough to create a new ME through an exchange factory and then you  
> can set the service name, endpoint or interface and its operation etc.  
> Have a look at the JavaDoc and if everything else fails then you  
> should try out something. The only thing I will say is that we use it  
> this way !
> 
> Have fun
> 
> Andreas Schaefer
> CEO of Madplanet.com Inc.
> andreas.schaefer@madplanet.com
> 
> 
> On Nov 1, 2007, at 2:13 PM, Learn Learn wrote:
> 
>>
>> Well, that wont help me...that would only send back a response to my
>> caller...what I want is to send this message across to some other  
>> endpoint
>> (determined thru business logic and configuration)
>>
>>
>> Mad Andy wrote:
>>>
>>> Declare a Delivery Channel with the @Resource annotation and then use
>>> the DC to create a ME, set the data and message and then send it.
>>>
>>> Have fun
>>>
>>> Andreas Schaefer
>>> CEO of Madplanet.com Inc.
>>> andreas.schaefer@madplanet.com
>>>
>>>
>>> On Nov 1, 2007, at 1:53 PM, Learn Learn wrote:
>>>
>>>>
>>>> Hi,
>>>>
>>>> Can a Servicemix-bean endpoint call other endpoints? I realise that
>>>> if we
>>>> implement the MessageExchangeListener, we wouldn't be able to do
>>>> so...nothing present in the MessageExchange object to set my target
>>>> Destination too..is there any other way of doing it?
>>>>
>>>> I need to do some routing in my Bean component (messages not XML
>>>> based)
>>>> based on some business logic and decide my next in chain based on
>>>> what my
>>>> routing logic evaluates to...similarly, if there is an exception
>>>> somewhere,
>>>> I need to route to a ExceptionListener that we have that massages  
>>>> our
>>>> exception trace into a more amiable message..
>>>>
>>>> Let me know if this can be done...if somebody has already done this
>>>> and has
>>>> a little code to share, wonderful...
>>>>
>>>> Thanks a lot for your help..
>>>>
>>>> Victor
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537231
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537622
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13540522
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix Bean endpoint calling other endpoints...

Posted by Andreas Schaefer <an...@madplanet.com>.
Well, I am not here to give you free code or do your homework. The DC  
is enough to create a new ME through an exchange factory and then you  
can set the service name, endpoint or interface and its operation etc.  
Have a look at the JavaDoc and if everything else fails then you  
should try out something. The only thing I will say is that we use it  
this way !

Have fun

Andreas Schaefer
CEO of Madplanet.com Inc.
andreas.schaefer@madplanet.com


On Nov 1, 2007, at 2:13 PM, Learn Learn wrote:

>
> Well, that wont help me...that would only send back a response to my
> caller...what I want is to send this message across to some other  
> endpoint
> (determined thru business logic and configuration)
>
>
> Mad Andy wrote:
>>
>> Declare a Delivery Channel with the @Resource annotation and then use
>> the DC to create a ME, set the data and message and then send it.
>>
>> Have fun
>>
>> Andreas Schaefer
>> CEO of Madplanet.com Inc.
>> andreas.schaefer@madplanet.com
>>
>>
>> On Nov 1, 2007, at 1:53 PM, Learn Learn wrote:
>>
>>>
>>> Hi,
>>>
>>> Can a Servicemix-bean endpoint call other endpoints? I realise that
>>> if we
>>> implement the MessageExchangeListener, we wouldn't be able to do
>>> so...nothing present in the MessageExchange object to set my target
>>> Destination too..is there any other way of doing it?
>>>
>>> I need to do some routing in my Bean component (messages not XML
>>> based)
>>> based on some business logic and decide my next in chain based on
>>> what my
>>> routing logic evaluates to...similarly, if there is an exception
>>> somewhere,
>>> I need to route to a ExceptionListener that we have that massages  
>>> our
>>> exception trace into a more amiable message..
>>>
>>> Let me know if this can be done...if somebody has already done this
>>> and has
>>> a little code to share, wonderful...
>>>
>>> Thanks a lot for your help..
>>>
>>> Victor
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537231
>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537622
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>


Re: ServiceMix Bean endpoint calling other endpoints...

Posted by Learn Learn <vi...@gmail.com>.
Well, that wont help me...that would only send back a response to my
caller...what I want is to send this message across to some other endpoint
(determined thru business logic and configuration)


Mad Andy wrote:
> 
> Declare a Delivery Channel with the @Resource annotation and then use  
> the DC to create a ME, set the data and message and then send it.
> 
> Have fun
> 
> Andreas Schaefer
> CEO of Madplanet.com Inc.
> andreas.schaefer@madplanet.com
> 
> 
> On Nov 1, 2007, at 1:53 PM, Learn Learn wrote:
> 
>>
>> Hi,
>>
>> Can a Servicemix-bean endpoint call other endpoints? I realise that  
>> if we
>> implement the MessageExchangeListener, we wouldn't be able to do
>> so...nothing present in the MessageExchange object to set my target
>> Destination too..is there any other way of doing it?
>>
>> I need to do some routing in my Bean component (messages not XML  
>> based)
>> based on some business logic and decide my next in chain based on  
>> what my
>> routing logic evaluates to...similarly, if there is an exception  
>> somewhere,
>> I need to route to a ExceptionListener that we have that massages our
>> exception trace into a more amiable message..
>>
>> Let me know if this can be done...if somebody has already done this  
>> and has
>> a little code to share, wonderful...
>>
>> Thanks a lot for your help..
>>
>> Victor
>> -- 
>> View this message in context:
>> http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537231
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537622
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: ServiceMix Bean endpoint calling other endpoints...

Posted by Andreas Schaefer <an...@madplanet.com>.
Declare a Delivery Channel with the @Resource annotation and then use  
the DC to create a ME, set the data and message and then send it.

Have fun

Andreas Schaefer
CEO of Madplanet.com Inc.
andreas.schaefer@madplanet.com


On Nov 1, 2007, at 1:53 PM, Learn Learn wrote:

>
> Hi,
>
> Can a Servicemix-bean endpoint call other endpoints? I realise that  
> if we
> implement the MessageExchangeListener, we wouldn't be able to do
> so...nothing present in the MessageExchange object to set my target
> Destination too..is there any other way of doing it?
>
> I need to do some routing in my Bean component (messages not XML  
> based)
> based on some business logic and decide my next in chain based on  
> what my
> routing logic evaluates to...similarly, if there is an exception  
> somewhere,
> I need to route to a ExceptionListener that we have that massages our
> exception trace into a more amiable message..
>
> Let me know if this can be done...if somebody has already done this  
> and has
> a little code to share, wonderful...
>
> Thanks a lot for your help..
>
> Victor
> -- 
> View this message in context: http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537231
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>


Re: ServiceMix Bean endpoint calling other endpoints...

Posted by Andreas Schaefer <an...@madplanet.com>.
It is fairly easy. In the synchronous case meaning if you send with  
DC.sendSync() the thread waits until the response comes back and the  
ME will contain the response. In case of the asynchronous case with  
DC.send() your thread will go on and you onMessageExchange() will end.  
When the response comes back your Bean is invoked again with the  
response on onMessageExchange() and you will have to deal how to  
return the response to your caller.

Have fun

Andreas Schaefer
CEO of Madplanet.com Inc.
andreas.schaefer@madplanet.com


On Nov 1, 2007, at 1:53 PM, Learn Learn wrote:

>
> Hi,
>
> Can a Servicemix-bean endpoint call other endpoints? I realise that  
> if we
> implement the MessageExchangeListener, we wouldn't be able to do
> so...nothing present in the MessageExchange object to set my target
> Destination too..is there any other way of doing it?
>
> I need to do some routing in my Bean component (messages not XML  
> based)
> based on some business logic and decide my next in chain based on  
> what my
> routing logic evaluates to...similarly, if there is an exception  
> somewhere,
> I need to route to a ExceptionListener that we have that massages our
> exception trace into a more amiable message..
>
> Let me know if this can be done...if somebody has already done this  
> and has
> a little code to share, wonderful...
>
> Thanks a lot for your help..
>
> Victor
> -- 
> View this message in context: http://www.nabble.com/ServiceMix-Bean-endpoint-calling-other-endpoints...-tf4733999s12049.html#a13537231
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>