You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by "jack.jonson@libero.it" <ja...@libero.it> on 2010/12/03 09:16:56 UTC
Clustering a POJO with ServiceMix 4
Hello,
I recently came across a ServiceMix 4 Clustering Demo (http://fusesource.
com/forums/thread.jspa?threadID=1933) which I’m currently trying to extend.
The idea is to put a "clustered JBI POJO" (let's call it proxy-bean) in
between the file-poller and the consumer-bean.
The point is that if I succeed with the POJO thing I can prove that SMX can be
used to cluster any real/complex java application exposing a JBI service.
Unluckily the proxy-bean does not "see" consumer-bean on the other SMX
instance and hence I’m stuck.
I sum up here my modification to the aforementioned example:
1. file-poller sends messages to the proxy-bean
2. proxy-bean receives messages, then
2.1 creates a new InOnly exchange targeted to consumer-bean and sends it to
the NMR
2.2 sends back to the NMR the received exchange (from file-poller) decorated
with DONE status
3. consumer-bean receives messages from proxy-bean and sends back an exchange
decorated with DONE status
I configured two separate, network-connected instances of SMX4 (let's call
them smxA and smxB) with conduitSubscriptions turned off, as per http:
//trenaman.blogspot.com/2010/04/four-things-you-need-to-know-about-new.html.
File-poller and proxy-bean are deployed on smxA, while consumer-bean is
deployed on smxB.
I defined proxy-bean as follows:
---------------------------------------------------------------------------------------------------------
public class MyProxy implements MessageExchangeListener
{
@Resource
private ComponentContext context;
public void onMessageExchange(final MessageExchange exchange) throws
MessagingException
{
final DeliveryChannel channel = context.getDeliveryChannel();
final QName service = new QName("http://fusesource.com/clusterdemo",
"payload-receiver");
final ServiceEndpoint[] endpoints = context.getEndpointsForService
(service);
final InOnly newExchange = channel.createExchangeFactory(endpoints[0]).
createInOnlyExchange();
final NormalizedMessage newMessage = newExchange.createMessage();
newMessage.setContent(new StringSource("<a>Hello</a>"));
newExchange.setMessage(newMessage, "in");
channel.send(newExchange);
final Source content = exchange.getMessage("in").getContent();
System.out.println("Proxy received exchange: " + content);
exchange.setStatus(ExchangeStatus.DONE);
channel.send(exchange);
}
}
---------------------------------------------------------------------------------------------------------
and configured it as follows:
---------------------------------------------------------------------------------------------------------
<bean:endpoint id="beanProxy" service="clu:proxy" endpoint="endpoint" bean="
#myProxy" />
<bean id="myProxy" class="org.file.processor.su.MyProxy" />
<bean class="org.apache.servicemix.jbi.cluster.engine.
OsgiSimpleClusterRegistration">
<property name="endpoint" ref="beanProxy" />
</bean>
<bean class="org.apache.servicemix.common.osgi.EndpointExporter" />
---------------------------------------------------------------------------------------------------------
The problem is that proxy-bean does not "see" consumer-bean on the other smx
instance: the context.getEndpointsForService(QName) method returns an empty
array.
I also tried:
- context.getEndpoint(QName, String) and context.getEndpoints(QName) methods
=> no endpoint/s found
- a Destination object annotated with @ExchangeTarget => no injection occurs
Notice that all works if consumer-bean is on the same smx instance as proxy-
bean.
For sure I am missing something, but I can't figure out what/where.
Can you give a look at my example?
Thanks a lot for your help.
Re: Clustering a POJO with ServiceMix 4
Posted by "jack.jonson" <ja...@libero.it>.
>The problem is that proxy-bean does not "see" consumer-bean on the other smx
>instance: the context.getEndpointsForService(QName) method returns an empty
>array.
>I also tried:
>- context.getEndpoint(QName, String) and context.getEndpoints(QName)
methods
>=> no endpoint/s found
>- a Destination object annotated with @ExchangeTarget => no injection
occurs
>Notice that all works if consumer-bean is on the same smx instance as
proxy-
>bean.
I tried channel.createExchangeFactoryForService(QName) which solved the
problem.
It seems that servicemix endpoint discovery feature (see
context.getEndpoints() and similar methods in the previous post) is not
capable of discovering remote endpoints.
Is it correct?
Since servicemix succeed in delivering exchanges to remote endpoints, I
think it must be somewhat aware of existing remote endpoints!
Is there other specific configuration that allows endpoint discovery in the
clustered scenario?
Thanks in advance
JJ
--
View this message in context: http://servicemix.396122.n5.nabble.com/Clustering-a-POJO-with-ServiceMix-4-tp3290530p3296257.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.