You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Daga, Harshit" <ha...@gatech.edu> on 2017/02/19 01:12:39 UTC

Adding/Exposing a custom module/service as part of the tomcat

 Hi,

I want to add a custom service/module as part of the tomcat server which should start as part of tomcat startup.

Service : I want to expose a service as part of tomcat startup which can store all the active sessions for the application running on the server and when I call this service via RMI or HTTP (can expose anyhow) I get this information. This service will be used by other tomcat servers to know the information.
Usage :  tomcat_1 calls tomcat_2 (on a specific port at which service is exposed) for the given end point, let say, getListOfSessions and this will return the list.

I want to know suggestion for implementing/exposing/configuring such a service/module.

PS : I want to do this as part of tomcat service to keep changes transparent of application.


Thanks & Regards,
HD

Re: Adding/Exposing a custom module/service as part of the tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Harshit,

On 3/1/17 9:22 PM, Daga, Harshit wrote:
> Thanks Christopher for JMX option but it is taking more time.
> 
> Use case : I have two tomcat servers (s1 and s2). I will call a
> method in s1 server from external source. On the method invocation
> s1 contacts s2 and passes on the information (example some
> in-memory data stored for the s1 is passed on to s2).
> 
> If I use JMX, it is takes time to connect to server1 and fetch the 
> information and then connects to server2 and update the
> information.

Why can't server1 contact server2 directly? There's no need for a 3rd
party to be involved.

> What I am looking for is to create light service and expose to
> some port (let say 8100). Now if I call this service on s1 (from
> outside) the s1 should connect the s2 and pass on the information.

Okay, you can still use JMX.

1. Catalyst client contacts server 1
2. Server 1 accepts the request, recognizes a "check server 2" request
3. Server 1 connects to server 2 via JMX (or via JMXProxyServlet,
which is probably more convenient) to call GetListOfSessions
4. Server 2 returns the list of sessions to server 1
5. Server 1 does whatever it needs to do with the session list from s2
6. Server 1 returns an "OK" response to the catalyst client

> Kindly provide me some suggestion on how I can do this.

There is nothing in Tomcat that can specifically help you to do this
other than, for example, the availability of the session information
via JMX. You'll have to write everything else on your own.

If you want both servers to know about each others sessions, why not
cluster the nodes together and have Tomcat share the sessions between
the two servers?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYvZxvAAoJEBzwKT+lPKRYKjoP/R3G+HTqzKfL+CXWL3r5yQ7f
fshO6rtLZh+Ea5185XXya+33FYm09PCGfLUQSbSjNH2p2MSWxo4PUBoaqH27yTsY
KGHgO5pD49lGMMGR/NNd3k5ZJp/ij96TR3Oa5/w+Bi7FzmvY41p/lLjTTAQR8m0o
bEtcrlvBS8jQduNLw05/VjacUCtGpaZeODlYW5VNmqK26sLl/PzOmcdYm381XgI6
7xFmViqTx8lgPF7vjIc1H+L9DlAuLSbB24aLLuxqjsa/nehpajcbILB+qX34lA2K
nXX1b38L4Cv3dG1NMDdTUa2IPUUdxYfFootrVTqtefnNCO96D3YXUEHfp/jFL7FL
TZBvlHQp6M0VR1XaGfARkM/ZiftP4NUt9QtqXUza1vRd9QI4bQcVRDxYu3u2KcMG
6Ctfi8ntwz3QsEeaQJ1If8XlGezas+gJRoOnPRngETo75xIRq1F8DLUkE5MN8CbA
cKhzRnxRGwPrCB8NFUbaRF+g97PKZilY3Mq7vqUVGtZwtuLqjAUjBONYp85xTKGN
WvqPMT/PqIXEx36x4zH4j921cg/9JrGKIDPa52YvDbVnwKje/6KJeWGjwwOazb9n
qSQAZ4yyJmUFiBX2SAfTJQFD/LcTlzwL3FsNYjnMcr6tld5kZMJuSEm+V8svecGX
a/xYZTFRQ7W1UsL0IGKI
=RqBW
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Adding/Exposing a custom module/service as part of the tomcat

Posted by "Daga, Harshit" <ha...@gatech.edu>.
Hi,

Thanks Christopher for JMX option but it is taking more time.

Use case :
I have two tomcat servers (s1 and s2). I will call a method in s1 server from external source. On the method invocation s1 contacts s2 and passes on the information (example some in-memory data stored for the s1 is passed on to s2).

If I use JMX, it is takes time to connect to server1 and fetch the information and then connects to server2 and update the information.

What I am looking for is to create light service and expose to some port (let say 8100). Now if I call this service on s1 (from outside) the s1 should connect the s2 and pass on the information.

Kindly provide me some suggestion on how I can do this.


Thanks & Regards,
HD


On February 19, 2017 at 8:50:46 AM, Christopher Schultz (chris@christopherschultz.net<ma...@christopherschultz.net>) wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Harshit,

On 2/18/17 8:12 PM, Daga, Harshit wrote:
> Hi,
>
> I want to add a custom service/module as part of the tomcat server
> which should start as part of tomcat startup.
>
> Service : I want to expose a service as part of tomcat startup
> which can store all the active sessions for the application
> running on the server and when I call this service via RMI or HTTP
> (can expose anyhow) I get this information. This service will be
> used by other tomcat servers to know the information. Usage :
> tomcat_1 calls tomcat_2 (on a specific port at which service is
> exposed) for the given end point, let say, getListOfSessions and
> this will return the list.
>
> I want to know suggestion for implementing/exposing/configuring
> such a service/module.
>
> PS : I want to do this as part of tomcat service to keep changes
> transparent of application.

Why not just use the existing JMX beans to get that information? I
don't think you have to write anything new.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYqaKjAAoJEBzwKT+lPKRYny8P/30C0NKWPClWwO9nYEM450OP
WtWYqqSv6REwNyS5DArGBa1WzTPKAZyqu4Ae5CE4PqlXxRwiWyUkwDBxQU7YwXXi
6YA3sThhWxNPzB03CFExEUsupKG76Td+RaiZ9T9fCsvYMKbLWBcrGTL2ZM53wnzb
XiKuOGcTb3IpmZlBDYcY/top4yvx1gF1bGvOmODKvDU8AuS7mMXqVhtcABB5BVPC
1yyeQ+AkdFveR+rq7tC7HlGUj4CD11zunGKIk/biNxfQFhGW0Xr+KA4fTabARZJd
Unnpo3PF23L/QWsc+Ibv6hna117z19KFnEzuy3NSgdHJLLXDGTWodactuj1EhJ0+
qKu3y8apIEEvyNoOLH9aMM4KhIK5HDACzF+LEqpivVMQ1yj5jhNs39RNfFjXjXgr
yAStlm8CWfEdEUiEo/QNODMarK71eKdYQPCU20qGls37SaauPJKerAf/FCtLp39/
ogLTMxQFTpI+b8ScO1XUE60Gq7m1uWz6HvTH4TZFO7xX7PBAPNau7+ovfsrQAbRC
PZUpC/G4SZv8tDxptsn845b3cMe2+mJYA37wDQI2OyXSf5qd/ZaE1vgQNktqToCg
mB+rN8cTFkaXlLulCLE2xIZXGrecy4/UkwHCR9g/OPKJWS7LrsRA5B+xiafNp/an
oAgaj1r/5qM8DxHAz6Fh
=ox2w
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Adding/Exposing a custom module/service as part of the tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Harshit,

On 2/18/17 8:12 PM, Daga, Harshit wrote:
> Hi,
> 
> I want to add a custom service/module as part of the tomcat server 
> which should start as part of tomcat startup.
> 
> Service : I want to expose a service as part of tomcat startup 
> which can store all the active sessions for the application
> running on the server and when I call this service via RMI or HTTP
> (can expose anyhow) I get this information. This service will be
> used by other tomcat servers to know the information. Usage :
> tomcat_1 calls tomcat_2 (on a specific port at which service is
> exposed) for the given end point, let say, getListOfSessions and
> this will return the list.
> 
> I want to know suggestion for implementing/exposing/configuring 
> such a service/module.
> 
> PS : I want to do this as part of tomcat service to keep changes 
> transparent of application.

Why not just use the existing JMX beans to get that information? I
don't think you have to write anything new.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYqaKjAAoJEBzwKT+lPKRYny8P/30C0NKWPClWwO9nYEM450OP
WtWYqqSv6REwNyS5DArGBa1WzTPKAZyqu4Ae5CE4PqlXxRwiWyUkwDBxQU7YwXXi
6YA3sThhWxNPzB03CFExEUsupKG76Td+RaiZ9T9fCsvYMKbLWBcrGTL2ZM53wnzb
XiKuOGcTb3IpmZlBDYcY/top4yvx1gF1bGvOmODKvDU8AuS7mMXqVhtcABB5BVPC
1yyeQ+AkdFveR+rq7tC7HlGUj4CD11zunGKIk/biNxfQFhGW0Xr+KA4fTabARZJd
Unnpo3PF23L/QWsc+Ibv6hna117z19KFnEzuy3NSgdHJLLXDGTWodactuj1EhJ0+
qKu3y8apIEEvyNoOLH9aMM4KhIK5HDACzF+LEqpivVMQ1yj5jhNs39RNfFjXjXgr
yAStlm8CWfEdEUiEo/QNODMarK71eKdYQPCU20qGls37SaauPJKerAf/FCtLp39/
ogLTMxQFTpI+b8ScO1XUE60Gq7m1uWz6HvTH4TZFO7xX7PBAPNau7+ovfsrQAbRC
PZUpC/G4SZv8tDxptsn845b3cMe2+mJYA37wDQI2OyXSf5qd/ZaE1vgQNktqToCg
mB+rN8cTFkaXlLulCLE2xIZXGrecy4/UkwHCR9g/OPKJWS7LrsRA5B+xiafNp/an
oAgaj1r/5qM8DxHAz6Fh
=ox2w
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org