Petals-SE-RMI 1.7.x

Version 1 by Christophe DENEUX
on Dec 09, 2015 17:37.

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (32)

View Page History

Your RMI client will depend on the following Maven artifacts as RMI client libraries:
* {{org.ow2.petals:petals-rmi-proxyclient:1.2.0}},
* {{org.ow2.petals:petals-rmi-server:1.56.0}},
* {{org.ow2.petals:petals-rmi-common:1.4.1}}

h2. Accessing the RMI registry

The client package of the RMI component contains only one class (the {{ComponentContextFactoryLocator}}). To instantiate an object of this class, three inputs parameters are required in the constructor:
* the IP address of the RMI registry server,
* the port to access to the RMI registry (the port used by the RMI registry to handle requests),
The instantiation of object of this class is presented below:
{code:java}
ComponentContextLocator ccl = new ComponentContextLocator("192.168.1.150", 1099, "RMIComponentContext");
ComponentContexFactoryLocator ccl = new ComponentContexFactoryLocator("192.168.1.150", 1099, "RMIComponentContext");
{code}

{note}

{note}If the Petals SE RMI component is not started when the {{ComponentContexFactoryLocator}} object is instantiated, a remote exception is raised.{note}

Once the object is instantiated, it is possible to access to remote component context.

h2. Getting the remote component context and activate/deactivate endpoints
h2. Getting a remote component context

The code lines presented below allows a client to access to the remote component context, to activate and deactivate an endpoint:
Once you have an instance of {{ComponentContexFactoryLocator}}, you will retrieve a remote component context that is your entry point on the Petals SE RMI to access the NMR. Two different kinds of remote component context are available:
* a remote component context for RMI client acting as a service 'provider',
* and a remote component context for RMI client acting as a service 'consumer'.

h3. RMI client acting as a RMI client 'provider'

The code lines presented below allows a RMI client 'provider' to access to the remote component context to activate and deactivate an endpoint, to wait incoming message exchanges, to send message exchanges:
{code:java}
// Access to the remote component context 'provider' from the ComponentContextLocator
RemoteComponentContext rcc = ccl.getComponentContext();
RemoteComponentContextClient rccc = ccl.getComponentClientContextFactory().createRemoteComponentContextProviderClient();

// Activation of an endpoint
ServiceEndpoint endpoint = rccc.activateEndpoint(new QName("http://petals.objectweb.org/", "RmiService"), "RmiEndpoint");

// Wait an incoming message exchange
MessageExchange exchange = rccc.getDeliveryChannel().accept();

// Send a message exchange
rccc.getDeliveryChannel().send(exchange);

// Deactivation of the endpoint
rcc.deactivateEndpoint(endpoint);
{code}

h2. Getting the remote message exchange factory and create different kind of messages
h3. RMI client acting as a RMI client 'consumer'

The code lines presented below allows a client to access to the remote message exchange factory and create different kind of messages:
The code lines presented below allows a RMI client 'consumer' to access to the remote component context to get the remote message exchange factory and create different kind of messages, to send message exchanges and wait replies:
{code:java}
// Access to the remote component context 'consumer' from the ComponentContextLocator
RemoteComponentContextClient rccc = ccl.getComponentClientContextFactory().createRemoteComponentContextConsumerClient();

// Access to Create the remote message exchange factory from remote component context
RemoteMessageExchangeFactory rmef = rcc.getDeliveryChannel().createExchangeFactory();

{code}

h2. Getting the remote delivery channel and send/accept JBI messages
// Send a message exchange
rccc.getDeliveryChannel().send(msgInOut);

The following code snippet allows a client to access to the remote delivery channel:
// Wait comeback of the message exchanges
MessageExchange exchange = rccc.getDeliveryChannel().accept();
{code}

The following code snippet shows an synchronous message exchange between the client and a provider:
{code:java}
// Access to the remote delivery channel from remote component context
RemoteDeliveryChannel rdc = rccc.getDeliveryChannel();

The following code snippet shows an asynchronous message exchange between the client and a provider:
// Create the remote message exchange factory from remote component context
RemoteMessageExchangeFactory rmef = rdc.createExchangeFactory();

// Send a asynchronous message
rdc.send(msgInOnly);
// create an in out message exchange
MessageExchange msgInOut = rmef.createInOutExchange();

// Accept the response of provider
MessageExchange msgResponseInOnly = rdc.accept();

The following code snippet shows an synchronous message exchange between the client and a provider:

// Send a synchronous message
msgInOut = rdc.sendSync(msgInOut);