• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web Service as an RMI Client?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

This is a post similar to the one I've done on the Web Service section (link) but I'm posting here because I have a side question related to that issue that involves RMI.

I have a Web Service, and I have another project which consists of a Server that has an always active connection to a remote host and that is able to send and receive messages. I need a way of invoking the "sendMessage(message, destination)" method of the server from within my Web Service, and to acheive this I have only come up with the idea of using RMI... converting the server to an RMI server also, and converting the web service to a RMI Client.

Have any of you used this configuration? Does any of you advise against it? It is even feasible to use a Web Service as an RMI Client? The thing is I MUST have a web service for sending messages to the server, and I MUST have the server always running and keeping the connection alive.

Do you think this is the way to go, or maybe I should consider another architecture?

Thank you in advance.
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gerardo,

if I understand you correctly the question is (more or less) simply what communication protocol to use in your application which is composed of multiple sub-projects?!?

I think RMI as well as a web service technology has advantages and disadvantages. It all depends on your requirements an application details. The biggest difference between RMI and web service based remote invocation is probably the portability issue. If you only have Java applications involved I'd say RMI is more comfortable to use.
On the other hand it should be clear that you usually can't use RMI communication end points with non Java clients.

It doesn't make a big difference if there are multiple communication partners involved. You still have to figure out the requirements for each communication link and decide which protocol allows you to achieve the goals.

Marco
 
Gerardo Sepulveda
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Marco,

Well the question is more less the one you mention, but the thing is I'm required to use a Web Service and at the sime time I'm required to have a local server always connected to the remote host (this is already coded an working). So my issue is communicating my web service with my server, so when I get a request via the Web Service, it should get an instance of the server and execute something like server.sendMessage() to send it. I think this'll help clarify it:

. - My System -
. -----------------------------------
--->| Web Service ---> SMPP Server | <----> Remote Server
. -----------------------------------

So I already have the SMPP Server Developed and works just fine, but as I said I'm required to have it always running and every now and then invoke the sendMessage() method on it to communicate with the "Remote Server" (The information to be sent to the remote server is the one I'm going to receive on the Web Service).

So the issue is how to communicate my WebService module with my SMPP Server module, by using RMI? Or is there a simpler solution? Is it even right to use RMI under this scenario?

I hope I explained it well, do you think RMI is the way to go? Or am I missing something that I can acheive from a normal "Dynamic Web Project" (Keep in mind i'm fairly new to both Web Services and RMI, even though I'm capable of implementing both). The limitation that I see is that under a "Dynamic Web Project" I can't keep the instance of the server always running, hence my interest in trying to implement it through RMI.

Thanks.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simply create a RMI-based server. The server is always running (unless you turn it off, of course.)

However, you don't "get an instance" of a server application. You invoke the server's functions via RMI objects. You get the references to the RMI object via JNDI.

Application A ---> Web Serivice ----> RMI Server ----- > Web Service ----> Application A


An RMI server is running 24 hours a day 7 days a week just like a HTTP-based web server.

Note, if your "SMPP Server" is not running 24/7, then you shouldn't be calling it a server, cause it is not.
 
Gerardo Sepulveda
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello James,

First of all my "Smpp Server" is indeed a server since it's suppossed to be running 24/7. Second, by reading your post I realized what my mistake was... I was trying to get the same instance of the remote object for executing its methods locally (if that even makes sense), when what I should have done since the beginning was execute the method on the server. This mistake I did because at first I was using the server as a singleton class, and when I decided to use RMI I continued to try to use it as a singleton class and this created double instantiation, anyway this problem has been fixed, thanks a lot.

On the other hand, would you advice any specific way of assuring that the server will always be running? that is... if the connection is lost or if an exception occurs how would you handle the fact that you now need to reconnect? I'll start getting some literature on this topic.

Thanks for all the help I've received through this space.
 
Gerardo Sepulveda
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Just to let everyone know that the problem was solved. At the end I was able to use a WebService as an RMI Client without further problems.

I was also able to figure out how to reconnect.

Thank you.
 
I like tacos! And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic