Hi,
the DefaultServiceMixClient constructor that you use takes two arguments:
- the first one (jbi) is the JBIContainer itself.
- the second one is the activation spec.
When you start a ServiceMix 3 in embedded mode, you get it:
JBIContainer container = new JBIContainer();
container.setEmbedded(true);
container:init();
container.start();
DefaultServiceMixClient client = new DefaultServiceMixClient(container);
In your case, as you're at the component level, I think that you can't
get the JBI container in this context.
However, from CXF-SE, you can access to the JBI bus and use the
ServiceMixClientFacade.
To do it, in your POJO, you can inject the bus:
private javax.jbi.component.ComponentContext context;
public void setContext(javax.jbi.component.ComponentContext context) {
this.context = context;
}
after you can use this context in the client:
public void myMethod() {
ServiceMixClient client = new ServiceMixClientFacade(this.context);
QName service = new QName("http://servicemix.org/cheese/", "receiver");
EndpointResolver resolver = client.createResolverForService(service);
client.send(resolver, null, null, "<hello>world</hello>");
}
and that's it ;)
Regards
JB
jcamus wrote:
Hi!
I'am trying from a given CXF-SE to use a DefaultServiceMixClient to send a
sync message into the NMR.
I found the following URL : http://servicemix.apache.org/client-api.html
http://servicemix.apache.org/client-api.html describing how to use a JBI
client into a given component.
I tried to inject a given ServiceMix client into my component and I set up
my xbean.xml like this (as explained into the documentation) :
<bean id="clientWithRouting"
class="org.apache.servicemix.client.DefaultServiceMixClient">
<constructor-arg ref="jbi" />
<constructor-arg>
<sm:activationSpec
destinationService="parkeon:exportationReferencialRouter"/>
</constructor-arg>
</bean>
but, the ref="jbi" is not explained! And I have the message : No bean named
'jbi' is defined !
What is the "jbi" ref?
Help please!
Regards