You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by jsexton0 <js...@gmail.com> on 2008/06/04 23:58:55 UTC

RemoteServiceMixClient - Example?

I created some code, successfully, using examples I found here and there to
create a local JBIContainer instance, a couple components to send and
receive messages, hooked them together, and it worked fine.  

Now I'd like to try using a RemoteServiceMixClient instance.  I'd like to
create, in my local application code, a sender and a receiver object, hook
them up in to a remote Servicemix and pass a message through.  I am able to
connect to the remote server, and do a few other thing, but I'm a bit foggy
on the details of how to do the plumbing on this.  

RemoteServiceMixClient remoteServiceMixClient = new
RemoteServiceMixClient("tcp://192.168.xx.xx:61616");
remoteServiceMixClient.init();
remoteServiceMixClient.start();

This works.  And I can get the current endpoints from it.
Now, does the following get me anyplace?

componentContext = serviceMixClient.getContext();
SenderComponent sender = new SenderComponent();
componentContext.activateEndpoint(sender.SERVICE, sender.ENDPOINT);

Where SenderComponent looks like this...

public class SenderComponent extends ComponentSupport implements Sender {
    public static final QName SERVICE = new
QName("http://servicemix.org/example/", "sender");
    public static final String ENDPOINT = "sender";
etc...

I'm guessing here...  Is there some code around that does this?  Thanks
-- 
View this message in context: http://www.nabble.com/RemoteServiceMixClient---Example--tp17657659p17657659.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: RemoteServiceMixClient - Example?

Posted by jsexton0 <js...@gmail.com>.
I changed RemoteServiceMixClient to include a "public JBIContainer
getContainer()".  This allows me to get the container and use it to call
activateComponent() with a couple of ActivationSpec instances.  That works
perfectly.  The issue I have remaining, which may be unimportant, is that on
calling shutdown() I get an exception thrown and a java thread ends up
hanging around.

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/xbean/classloader/DestroyableClassLoader

What's the proper way to shutdown the remote JBI container instance?


jsexton0 wrote:
> 
> Here's a code fragment from what I working with.  It seems real close, or
> maybe it's complete nonsense, one or the other.  It runs fine, it create
> an endpoint, but no message is received by the receiver component
> instance.  The context here is obtained from a remote client instance...
> 
>             receiver = new ReceiverComponent();
>             ServiceEndpoint receiverEndpoint =
> componentContext.activateEndpoint(receiver.SERVICE, receiver.ENDPOINT);
>             InOnly exchange =
> componentContext.getDeliveryChannel().createExchangeFactory().createInOnlyExchange();
>             NormalizedMessage message = exchange.createMessage();
> 
>             String xml = 
>                 "<s12:Envelope " + 
>                 "   xmlns:s12='http://www.w3.org/2003/05/soap-envelope'>"
> + 
>                 "   <s12:Body>" + 
>                 "      <data>Hello</data>" + 
>                 "   </s12:Body>" + 
>                 "</s12:Envelope>";
>             message.setContent(new StringSource(xml));
> 
>             exchange.setInMessage(message);
>             exchange.setService(receiver.SERVICE);        
>             exchange.setEndpoint(receiverEndpoint);
>             serviceMixClient.send(exchange);
> 
>             // The receiver shows up in this list...
>             ServiceEndpoint[] endPoints =
> componentContext.getEndpoints(null);
> 
> 

-- 
View this message in context: http://www.nabble.com/RemoteServiceMixClient---Example--tp17657659p17735051.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: RemoteServiceMixClient - Example?

Posted by jsexton0 <js...@gmail.com>.
Here's a code fragment from what I working with.  It seems real close, or
maybe it's complete nonsense, one or the other.  It runs fine, it create an
endpoint, but no message is received by the receiver component instance. 
The context here is obtained from a remote client instance...

            receiver = new ReceiverComponent();
            ServiceEndpoint receiverEndpoint =
componentContext.activateEndpoint(receiver.SERVICE, receiver.ENDPOINT);
            InOnly exchange =
componentContext.getDeliveryChannel().createExchangeFactory().createInOnlyExchange();
            NormalizedMessage message = exchange.createMessage();

            String xml = 
                "<s12:Envelope " + 
                "   xmlns:s12='http://www.w3.org/2003/05/soap-envelope'>" + 
                "   <s12:Body>" + 
                "      <data>Hello</data>" + 
                "   </s12:Body>" + 
                "</s12:Envelope>";
            message.setContent(new StringSource(xml));

            exchange.setInMessage(message);
            exchange.setService(receiver.SERVICE);        
            exchange.setEndpoint(receiverEndpoint);
            serviceMixClient.send(exchange);

            // The receiver shows up in this list...
            ServiceEndpoint[] endPoints =
componentContext.getEndpoints(null);



Gert Vanthienen wrote:
> 
> L.S.,
> 
> On this page (http://servicemix.apache.org/client-api.html), you'll find 
> an introduction to the ServiceMixClient API.  Once you're connected, 
> there isn't that much of a difference between the RemoteServiceMixClient 
> and the other ServiceMixClient implementations.  I'm afraid we don't 
> have any additional code samples available on the website, you can take 
> a look at our unit test classes at 
> http://svn.apache.org/repos/asf/servicemix/smx3/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/client/ 
> though.
> 
> Gert
> 
> jsexton0 wrote:
>> I created some code, successfully, using examples I found here and there
>> to
>> create a local JBIContainer instance, a couple components to send and
>> receive messages, hooked them together, and it worked fine.  
>>
>> Now I'd like to try using a RemoteServiceMixClient instance.  I'd like to
>> create, in my local application code, a sender and a receiver object,
>> hook
>> them up in to a remote Servicemix and pass a message through.  I am able
>> to
>> connect to the remote server, and do a few other thing, but I'm a bit
>> foggy
>> on the details of how to do the plumbing on this.  
>>
>> RemoteServiceMixClient remoteServiceMixClient = new
>> RemoteServiceMixClient("tcp://192.168.xx.xx:61616");
>> remoteServiceMixClient.init();
>> remoteServiceMixClient.start();
>>
>> This works.  And I can get the current endpoints from it.
>> Now, does the following get me anyplace?
>>
>> componentContext = serviceMixClient.getContext();
>> SenderComponent sender = new SenderComponent();
>> componentContext.activateEndpoint(sender.SERVICE, sender.ENDPOINT);
>>
>> Where SenderComponent looks like this...
>>
>> public class SenderComponent extends ComponentSupport implements Sender {
>>     public static final QName SERVICE = new
>> QName("http://servicemix.org/example/", "sender");
>>     public static final String ENDPOINT = "sender";
>> etc...
>>
>> I'm guessing here...  Is there some code around that does this?  Thanks
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://www.anova.be
> 

-- 
View this message in context: http://www.nabble.com/RemoteServiceMixClient---Example--tp17657659p17680712.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: RemoteServiceMixClient - Example?

Posted by jsexton0 <js...@gmail.com>.
The unit tests are helpful, but what about setting up something to receive a
message?  Is that possible using a RemoteServiceMixClient instance?  When
using a JBIContainer instance I'm able to simply do something like
"jbiContainer.activateComponent(receverActivationSpec);" after getting an
ActivationSpec using a receiver instance, and it's ready to receive. 

Can I do that with a remote client handle?

Thanks


Gert Vanthienen wrote:
> 
> L.S.,
> 
> On this page (http://servicemix.apache.org/client-api.html), you'll find 
> an introduction to the ServiceMixClient API.  Once you're connected, 
> there isn't that much of a difference between the RemoteServiceMixClient 
> and the other ServiceMixClient implementations.  I'm afraid we don't 
> have any additional code samples available on the website, you can take 
> a look at our unit test classes at 
> http://svn.apache.org/repos/asf/servicemix/smx3/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/client/ 
> though.
> 
> Gert
> 
> jsexton0 wrote:
>> I created some code, successfully, using examples I found here and there
>> to
>> create a local JBIContainer instance, a couple components to send and
>> receive messages, hooked them together, and it worked fine.  
>>
>> Now I'd like to try using a RemoteServiceMixClient instance.  I'd like to
>> create, in my local application code, a sender and a receiver object,
>> hook
>> them up in to a remote Servicemix and pass a message through.  I am able
>> to
>> connect to the remote server, and do a few other thing, but I'm a bit
>> foggy
>> on the details of how to do the plumbing on this.  
>>
>> RemoteServiceMixClient remoteServiceMixClient = new
>> RemoteServiceMixClient("tcp://192.168.xx.xx:61616");
>> remoteServiceMixClient.init();
>> remoteServiceMixClient.start();
>>
>> This works.  And I can get the current endpoints from it.
>> Now, does the following get me anyplace?
>>
>> componentContext = serviceMixClient.getContext();
>> SenderComponent sender = new SenderComponent();
>> componentContext.activateEndpoint(sender.SERVICE, sender.ENDPOINT);
>>
>> Where SenderComponent looks like this...
>>
>> public class SenderComponent extends ComponentSupport implements Sender {
>>     public static final QName SERVICE = new
>> QName("http://servicemix.org/example/", "sender");
>>     public static final String ENDPOINT = "sender";
>> etc...
>>
>> I'm guessing here...  Is there some code around that does this?  Thanks
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://www.anova.be
> 

-- 
View this message in context: http://www.nabble.com/RemoteServiceMixClient---Example--tp17657659p17679757.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: RemoteServiceMixClient - Example?

Posted by Gert Vanthienen <ge...@skynet.be>.
L.S.,

On this page (http://servicemix.apache.org/client-api.html), you'll find 
an introduction to the ServiceMixClient API.  Once you're connected, 
there isn't that much of a difference between the RemoteServiceMixClient 
and the other ServiceMixClient implementations.  I'm afraid we don't 
have any additional code samples available on the website, you can take 
a look at our unit test classes at 
http://svn.apache.org/repos/asf/servicemix/smx3/trunk/core/servicemix-core/src/test/java/org/apache/servicemix/client/ 
though.

Gert

jsexton0 wrote:
> I created some code, successfully, using examples I found here and there to
> create a local JBIContainer instance, a couple components to send and
> receive messages, hooked them together, and it worked fine.  
>
> Now I'd like to try using a RemoteServiceMixClient instance.  I'd like to
> create, in my local application code, a sender and a receiver object, hook
> them up in to a remote Servicemix and pass a message through.  I am able to
> connect to the remote server, and do a few other thing, but I'm a bit foggy
> on the details of how to do the plumbing on this.  
>
> RemoteServiceMixClient remoteServiceMixClient = new
> RemoteServiceMixClient("tcp://192.168.xx.xx:61616");
> remoteServiceMixClient.init();
> remoteServiceMixClient.start();
>
> This works.  And I can get the current endpoints from it.
> Now, does the following get me anyplace?
>
> componentContext = serviceMixClient.getContext();
> SenderComponent sender = new SenderComponent();
> componentContext.activateEndpoint(sender.SERVICE, sender.ENDPOINT);
>
> Where SenderComponent looks like this...
>
> public class SenderComponent extends ComponentSupport implements Sender {
>     public static final QName SERVICE = new
> QName("http://servicemix.org/example/", "sender");
>     public static final String ENDPOINT = "sender";
> etc...
>
> I'm guessing here...  Is there some code around that does this?  Thanks
>