You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Mello, Cody" <co...@brown.edu> on 2014/05/14 05:23:16 UTC

Using Distributed OSGi with dynamic dispatch?

Hello everyone,

I'm fairly new to CXF, and have been working on adapting a project to
use Distributed OSGi. I've been successful so far by following the
Spring DM example, but I've hit a wall. After some searching online, I
can't quite determine how to proceed. I have some code that works
something like this:

class A implements Service {

    public void register(String str, Client client) {
        this.map.put(str, client);
    }

    public void performLater(String str) {
        this.map.get(str).receive();
    }

    ....
}

class B implements Client {
    protected Service service;

    public void setService(Service serv) {
        this.service = serv;
    }

    public void registerWithServer() {
        this.service.register("myName", this);
    }

    public void receive() {
        ....
    }
}

Here, A is a service available on one Equinox instance, made available
over port 9000, and B is on another Equinox instance, making calls to
A. I have this working well in one direction so far, but the instant
that performLater() is called, I get an error message like this:

Exception in thread "pool-6-thread-1" java.lang.IllegalAccessError:
receive is not delegated.
    at org.apache.cxf.aegis.type.basic.InterfaceInvocationHandler.invoke(InterfaceInvocationHandler.java:57)
    at com.sun.proxy.$Proxy53.receive(Unknown Source)
    at net.beaconcontroller.core.internal.Controller.handleMessages(Controller.java:387)
    at net.beaconcontroller.core.internal.Controller.handleSwitchEvent(Controller.java:199)
    at net.beaconcontroller.core.internal.Controller.handleEvent(Controller.java:138)
    at net.beaconcontroller.core.io.internal.IOLoop.doLoop(IOLoop.java:122)
    at net.beaconcontroller.core.internal.Controller$2.run(Controller.java:541)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

I believe that I understand why this isn't working: I haven't exported
any service for Client which can be consumed by the Service. I don't
know where to head from here, though. I would like to be able to
deploy multiple Clients in multiple bundles on the same OSGi instance
and also deploy multiple Equinox instances on separate machines, which
can dynamically register and deregister themselves with the Service.
Is this something that I can do with DOSGi or any of the CXF projects?
If so, what would this look like, and are there any examples I can
reference?

Thanks!

- Cody

Re: Using Distributed OSGi with dynamic dispatch?

Posted by Christian Schneider <ch...@die-schneider.net>.
Yes ActiveMQ is a good fit. If you use Apache Karaf then installing 
ActiveMQ is especially easy thanks to the features they provide.

You might also look into the cxf jms transport. If you create a service 
with one oneway method and a topic as address you can easily do messaging.
See http://cxf.apache.org/docs/jms-transport.html
The good thing about jms is that you get location transparency without 
an additional service registry. For example you can just send to a topic 
or queue and anyone can register there without
the need for any service registry like the zookeeper one we use in 
distributed OSGi.

If you do not want to transport SOAP you can also look into apache camel 
pojo messaging which also makes jms easier 
http://www.liquid-reality.de/x/NoBe .

Christian

Am 14.05.2014 18:35, schrieb Mello, Cody:
> Hey Christian,
>
> Thanks for your response! I found your guides on liquid-reality.de to
> be helpful while setting this up.
>
> Yes, you are correct about what I'm trying to do. It doesn't
> necessarily have to be asynchronous though. More generally, I would
> like the ability to make a call to A, which then calls back to B on an
> object it was passed as an argument. This could be in the original
> call to A, or later, on a saved object. This seems to work just fine
> when done synchronously. Reading over that post, it sounds like doing
> it asynchronously is outside of the scope of the original Remote
> Services specification.
>
> JMS might be a good solution. It would probably require restructuring
> the project somewhat, but it's probably the best way to do it, if
> doing it in DOSGi would bend it too much. I don't know too much about
> the available JMS providers; is ActiveMQ my best bet here?
>
> - Cody
>
>
> On Wed, May 14, 2014 at 5:43 AM, Christian Schneider
> <ch...@die-schneider.net> wrote:
>> I am not sure I understand what you are trying to achieve.
>> Can you formulate this from a pure business view so without the technology?
>>
>> This is what I think you want:
>>
>> B wants to receive events from A. So it registers with A as a kind of
>> listener. A then asynchronously sends events to B. Is that correct?
>> If yes then you might want to rather look into JMS or Distributed Event
>> Admin (http://blog.osgi.org/2013/06/distributed-eventing-rfp-158-now.html).
>>
>> I can imagine that it can be achieved with DOSGi but it would bend the scope
>> of the framework quite a bit.
>>
>> The easiest solution I can imagine as long as the above spec is not
>> implemented is using jms topics for communication and hiding jms behind a
>> regular OSGi service.
>>
>> Christian
>>
>>
>> On 14.05.2014 05:23, Mello, Cody wrote:
>>> Hello everyone,
>>>
>>> I'm fairly new to CXF, and have been working on adapting a project to
>>> use Distributed OSGi. I've been successful so far by following the
>>> Spring DM example, but I've hit a wall. After some searching online, I
>>> can't quite determine how to proceed. I have some code that works
>>> something like this:
>>>
>>> class A implements Service {
>>>
>>>       public void register(String str, Client client) {
>>>           this.map.put(str, client);
>>>       }
>>>
>>>       public void performLater(String str) {
>>>           this.map.get(str).receive();
>>>       }
>>>
>>>       ....
>>> }
>>>
>>> class B implements Client {
>>>       protected Service service;
>>>
>>>       public void setService(Service serv) {
>>>           this.service = serv;
>>>       }
>>>
>>>       public void registerWithServer() {
>>>           this.service.register("myName", this);
>>>       }
>>>
>>>       public void receive() {
>>>           ....
>>>       }
>>> }
>>>
>>> Here, A is a service available on one Equinox instance, made available
>>> over port 9000, and B is on another Equinox instance, making calls to
>>> A. I have this working well in one direction so far, but the instant
>>> that performLater() is called, I get an error message like this:
>>>
>>> Exception in thread "pool-6-thread-1" java.lang.IllegalAccessError:
>>> receive is not delegated.
>>>       at
>>> org.apache.cxf.aegis.type.basic.InterfaceInvocationHandler.invoke(InterfaceInvocationHandler.java:57)
>>>       at com.sun.proxy.$Proxy53.receive(Unknown Source)
>>>       at
>>> net.beaconcontroller.core.internal.Controller.handleMessages(Controller.java:387)
>>>       at
>>> net.beaconcontroller.core.internal.Controller.handleSwitchEvent(Controller.java:199)
>>>       at
>>> net.beaconcontroller.core.internal.Controller.handleEvent(Controller.java:138)
>>>       at
>>> net.beaconcontroller.core.io.internal.IOLoop.doLoop(IOLoop.java:122)
>>>       at
>>> net.beaconcontroller.core.internal.Controller$2.run(Controller.java:541)
>>>       at
>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>>>       at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>>>       at java.lang.Thread.run(Thread.java:744)
>>>
>>> I believe that I understand why this isn't working: I haven't exported
>>> any service for Client which can be consumed by the Service. I don't
>>> know where to head from here, though. I would like to be able to
>>> deploy multiple Clients in multiple bundles on the same OSGi instance
>>> and also deploy multiple Equinox instances on separate machines, which
>>> can dynamically register and deregister themselves with the Service.
>>> Is this something that I can do with DOSGi or any of the CXF projects?
>>> If so, what would this look like, and are there any examples I can
>>> reference?
>>>
>>> Thanks!
>>>
>>> - Cody
>>
>>
>> --
>> Christian Schneider
>> http://www.liquid-reality.de
>>
>> Open Source Architect
>> http://www.talend.com
>>


-- 
  
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: Using Distributed OSGi with dynamic dispatch?

Posted by "Mello, Cody" <co...@brown.edu>.
Hey Christian,

Thanks for your response! I found your guides on liquid-reality.de to
be helpful while setting this up.

Yes, you are correct about what I'm trying to do. It doesn't
necessarily have to be asynchronous though. More generally, I would
like the ability to make a call to A, which then calls back to B on an
object it was passed as an argument. This could be in the original
call to A, or later, on a saved object. This seems to work just fine
when done synchronously. Reading over that post, it sounds like doing
it asynchronously is outside of the scope of the original Remote
Services specification.

JMS might be a good solution. It would probably require restructuring
the project somewhat, but it's probably the best way to do it, if
doing it in DOSGi would bend it too much. I don't know too much about
the available JMS providers; is ActiveMQ my best bet here?

- Cody


On Wed, May 14, 2014 at 5:43 AM, Christian Schneider
<ch...@die-schneider.net> wrote:
> I am not sure I understand what you are trying to achieve.
> Can you formulate this from a pure business view so without the technology?
>
> This is what I think you want:
>
> B wants to receive events from A. So it registers with A as a kind of
> listener. A then asynchronously sends events to B. Is that correct?
> If yes then you might want to rather look into JMS or Distributed Event
> Admin (http://blog.osgi.org/2013/06/distributed-eventing-rfp-158-now.html).
>
> I can imagine that it can be achieved with DOSGi but it would bend the scope
> of the framework quite a bit.
>
> The easiest solution I can imagine as long as the above spec is not
> implemented is using jms topics for communication and hiding jms behind a
> regular OSGi service.
>
> Christian
>
>
> On 14.05.2014 05:23, Mello, Cody wrote:
>>
>> Hello everyone,
>>
>> I'm fairly new to CXF, and have been working on adapting a project to
>> use Distributed OSGi. I've been successful so far by following the
>> Spring DM example, but I've hit a wall. After some searching online, I
>> can't quite determine how to proceed. I have some code that works
>> something like this:
>>
>> class A implements Service {
>>
>>      public void register(String str, Client client) {
>>          this.map.put(str, client);
>>      }
>>
>>      public void performLater(String str) {
>>          this.map.get(str).receive();
>>      }
>>
>>      ....
>> }
>>
>> class B implements Client {
>>      protected Service service;
>>
>>      public void setService(Service serv) {
>>          this.service = serv;
>>      }
>>
>>      public void registerWithServer() {
>>          this.service.register("myName", this);
>>      }
>>
>>      public void receive() {
>>          ....
>>      }
>> }
>>
>> Here, A is a service available on one Equinox instance, made available
>> over port 9000, and B is on another Equinox instance, making calls to
>> A. I have this working well in one direction so far, but the instant
>> that performLater() is called, I get an error message like this:
>>
>> Exception in thread "pool-6-thread-1" java.lang.IllegalAccessError:
>> receive is not delegated.
>>      at
>> org.apache.cxf.aegis.type.basic.InterfaceInvocationHandler.invoke(InterfaceInvocationHandler.java:57)
>>      at com.sun.proxy.$Proxy53.receive(Unknown Source)
>>      at
>> net.beaconcontroller.core.internal.Controller.handleMessages(Controller.java:387)
>>      at
>> net.beaconcontroller.core.internal.Controller.handleSwitchEvent(Controller.java:199)
>>      at
>> net.beaconcontroller.core.internal.Controller.handleEvent(Controller.java:138)
>>      at
>> net.beaconcontroller.core.io.internal.IOLoop.doLoop(IOLoop.java:122)
>>      at
>> net.beaconcontroller.core.internal.Controller$2.run(Controller.java:541)
>>      at
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>>      at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>>      at java.lang.Thread.run(Thread.java:744)
>>
>> I believe that I understand why this isn't working: I haven't exported
>> any service for Client which can be consumed by the Service. I don't
>> know where to head from here, though. I would like to be able to
>> deploy multiple Clients in multiple bundles on the same OSGi instance
>> and also deploy multiple Equinox instances on separate machines, which
>> can dynamically register and deregister themselves with the Service.
>> Is this something that I can do with DOSGi or any of the CXF projects?
>> If so, what would this look like, and are there any examples I can
>> reference?
>>
>> Thanks!
>>
>> - Cody
>
>
>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com
>

Re: Using Distributed OSGi with dynamic dispatch?

Posted by Christian Schneider <ch...@die-schneider.net>.
I am not sure I understand what you are trying to achieve.
Can you formulate this from a pure business view so without the technology?

This is what I think you want:

B wants to receive events from A. So it registers with A as a kind of 
listener. A then asynchronously sends events to B. Is that correct?
If yes then you might want to rather look into JMS or Distributed Event 
Admin (http://blog.osgi.org/2013/06/distributed-eventing-rfp-158-now.html).

I can imagine that it can be achieved with DOSGi but it would bend the 
scope of the framework quite a bit.

The easiest solution I can imagine as long as the above spec is not 
implemented is using jms topics for communication and hiding jms behind 
a regular OSGi service.

Christian

On 14.05.2014 05:23, Mello, Cody wrote:
> Hello everyone,
>
> I'm fairly new to CXF, and have been working on adapting a project to
> use Distributed OSGi. I've been successful so far by following the
> Spring DM example, but I've hit a wall. After some searching online, I
> can't quite determine how to proceed. I have some code that works
> something like this:
>
> class A implements Service {
>
>      public void register(String str, Client client) {
>          this.map.put(str, client);
>      }
>
>      public void performLater(String str) {
>          this.map.get(str).receive();
>      }
>
>      ....
> }
>
> class B implements Client {
>      protected Service service;
>
>      public void setService(Service serv) {
>          this.service = serv;
>      }
>
>      public void registerWithServer() {
>          this.service.register("myName", this);
>      }
>
>      public void receive() {
>          ....
>      }
> }
>
> Here, A is a service available on one Equinox instance, made available
> over port 9000, and B is on another Equinox instance, making calls to
> A. I have this working well in one direction so far, but the instant
> that performLater() is called, I get an error message like this:
>
> Exception in thread "pool-6-thread-1" java.lang.IllegalAccessError:
> receive is not delegated.
>      at org.apache.cxf.aegis.type.basic.InterfaceInvocationHandler.invoke(InterfaceInvocationHandler.java:57)
>      at com.sun.proxy.$Proxy53.receive(Unknown Source)
>      at net.beaconcontroller.core.internal.Controller.handleMessages(Controller.java:387)
>      at net.beaconcontroller.core.internal.Controller.handleSwitchEvent(Controller.java:199)
>      at net.beaconcontroller.core.internal.Controller.handleEvent(Controller.java:138)
>      at net.beaconcontroller.core.io.internal.IOLoop.doLoop(IOLoop.java:122)
>      at net.beaconcontroller.core.internal.Controller$2.run(Controller.java:541)
>      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>      at java.lang.Thread.run(Thread.java:744)
>
> I believe that I understand why this isn't working: I haven't exported
> any service for Client which can be consumed by the Service. I don't
> know where to head from here, though. I would like to be able to
> deploy multiple Clients in multiple bundles on the same OSGi instance
> and also deploy multiple Equinox instances on separate machines, which
> can dynamically register and deregister themselves with the Service.
> Is this something that I can do with DOSGi or any of the CXF projects?
> If so, what would this look like, and are there any examples I can
> reference?
>
> Thanks!
>
> - Cody


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: Using Distributed OSGi with dynamic dispatch?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Does it work for a registerWithServer -> register sequence ?

Cheers, Sergey

On 14/05/14 04:23, Mello, Cody wrote:
> Hello everyone,
>
> I'm fairly new to CXF, and have been working on adapting a project to
> use Distributed OSGi. I've been successful so far by following the
> Spring DM example, but I've hit a wall. After some searching online, I
> can't quite determine how to proceed. I have some code that works
> something like this:
>
> class A implements Service {
>
>      public void register(String str, Client client) {
>          this.map.put(str, client);
>      }
>
>      public void performLater(String str) {
>          this.map.get(str).receive();
>      }
>
>      ....
> }
>
> class B implements Client {
>      protected Service service;
>
>      public void setService(Service serv) {
>          this.service = serv;
>      }
>
>      public void registerWithServer() {
>          this.service.register("myName", this);
>      }
>
>      public void receive() {
>          ....
>      }
> }
>
> Here, A is a service available on one Equinox instance, made available
> over port 9000, and B is on another Equinox instance, making calls to
> A. I have this working well in one direction so far, but the instant
> that performLater() is called, I get an error message like this:
>
> Exception in thread "pool-6-thread-1" java.lang.IllegalAccessError:
> receive is not delegated.
>      at org.apache.cxf.aegis.type.basic.InterfaceInvocationHandler.invoke(InterfaceInvocationHandler.java:57)
>      at com.sun.proxy.$Proxy53.receive(Unknown Source)
>      at net.beaconcontroller.core.internal.Controller.handleMessages(Controller.java:387)
>      at net.beaconcontroller.core.internal.Controller.handleSwitchEvent(Controller.java:199)
>      at net.beaconcontroller.core.internal.Controller.handleEvent(Controller.java:138)
>      at net.beaconcontroller.core.io.internal.IOLoop.doLoop(IOLoop.java:122)
>      at net.beaconcontroller.core.internal.Controller$2.run(Controller.java:541)
>      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>      at java.lang.Thread.run(Thread.java:744)
>
> I believe that I understand why this isn't working: I haven't exported
> any service for Client which can be consumed by the Service. I don't
> know where to head from here, though. I would like to be able to
> deploy multiple Clients in multiple bundles on the same OSGi instance
> and also deploy multiple Equinox instances on separate machines, which
> can dynamically register and deregister themselves with the Service.
> Is this something that I can do with DOSGi or any of the CXF projects?
> If so, what would this look like, and are there any examples I can
> reference?
>
> Thanks!
>
> - Cody
>