You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jose María Zaragoza <de...@gmail.com> on 2013/07/02 08:45:50 UTC

Share info across different sessions & servers

Hello:

I need to share data between sessions running in different Tomcat server.

I 'd been thinking about using a JMS broker (as ActiveMQ ):

- when a new session is created in Tomcat A, it's created a new unique
topic for this session
- the session registers itself as listener of that topic ( the only one
listener )
- publish the name of this topic by some way , so it can be found by
another session in Tomcat B

I don't know if somebody has used something like this sometime, and how
he/she did it
Any suggestion/opinion  ?

I'm not sure either use only one topic for all session created or one topic
per session ?
I think that one topic per session is more safe because if I use one topic
for all sessions, if one message is not read quickly by one consumer ( a
session ), could block the topic,
Obviously , i'll define a TTL for messages/topic

Thanks and regards

Re: Share info across different sessions & servers

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

Jose,

On 7/2/13 3:43 PM, Jose María Zaragoza wrote:
> Maybe I explained myself badly I really need to send messages to a
> specific web session , not share data
> 
> I need to pass some data ( message ) to a specific session from a
> remote system ( a remote process from a remote system). Finally,
> this data is passed to client's browser by AJAX Reverse
> 
> My idea is the session creates a dynamic Queue and it configures
> itself as Consumer If I pass the Queue to remote process ( in
> message.replyTo() ) , the remote process can send data to that
> specific session
> 
> I could use a RDBS but , in this case, session needs to create a
> thread to polling on a share table. And I don't like this idea,
> sorry.
> 
> memcached sounds good but I don't know anything about it and I
> don't know is is based on a event-driven architecture

No, memcached does not sound good for your requirements.

> I need
> 
> 1) send data/message from a remote process to a specific web
> session 2) execute some code in this session

For example?

> 3) consume ( a.k.a, delete ) that message
> 
> Persistence is not a requirement but ActiveMQ allows it
> 
> I'll try it with ActiveMQ

What if the session no longer exists? What should happen to the
message? This is starting to sound more like one of those situations
where EJBs are actually necessary. Then again, I have rarely seen an
environment where EJBs are actually necessary... only used because it
makes the system more "enterprisey".

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJR2hwHAAoJEBzwKT+lPKRYzfgP/20Y42iqmMDb3a/plqXYL6Jt
52yuVdhAF5zqfC3Wz3cjw776SE0f2lqbZ83WX39IfbYUEdQQavh2bNZwXgJ32EkB
POokex5ej+y1kyYNmY4mkz9eMQq1iX0fJKR3sqc5mW97swsIpLUQy7cuaBAdwhft
jHL34GLe6ZFAUh6w3xnwkRu9vJMPzVIY9za5zmNdOssALsGZTZlHgZbvJCImLkfJ
iwFHqiK35bgTfUDhxOweOoeyPB2mgiJYM8NrGs06BEu0KCnhF63O/TVIiyOt3y7M
hmpFno7XQN2CGEv6FOpEx1vRDW2hyznHKx6pfVBkEK2MA+SEHVW7iPbX968htezE
aeYGTnvNPtNmiHINMzetVnQBNbs4dlgunWFUOdWfkLlj1r1grquY+u0tjrEgFXgD
/0uGlxOosNGWuLc72rn1RgfKn6LkWNS95KqIGMtXBfhoDT569My9AE9sFE4JyVgG
XL52UTtx4x1QxmDyuNSD6d7yNGyI11lVyo2UJhKvoHJrSX61cyQ0rDVmiVuIkC5q
m5rEMhqczw8TK7l2j4t3KNYr+BW204fBhTnvsKHpfjy3k0xTYu+sA5yGFemR4MI1
TR5MHZmnBao6aWLUVBJqKK3JWyrikNCq59rfGk11NUCiHJSN0H9XHCXBRbujOl7s
HQd4pmn2ocSwBOWQw60p
=lwin
-----END PGP SIGNATURE-----

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


Re: Share info across different sessions & servers

Posted by Jose María Zaragoza <de...@gmail.com>.
Thanks Vince


2013/7/6 Vince Stewart <st...@gmail.com>

> hi Jose,
> here is a working demo for exchanging messages between remote hosts using
> tribes
>
>
> import java.io.IOException;
> import java.io.Serializable;
> import java.net.InetAddress;
> import java.net.NetworkInterface;
> import java.net.SocketException;
> import java.nio.charset.Charset;
> import java.util.ArrayList;
> import java.util.Enumeration;
> import java.util.Vector;
> import java.util.logging.Level;
> import java.util.logging.Logger;
> import org.apache.catalina.tribes.ByteMessage;
> import org.apache.catalina.tribes.Channel;
> import org.apache.catalina.tribes.ChannelException;
> import org.apache.catalina.tribes.Member;
> import org.apache.catalina.tribes.MembershipListener;
> import org.apache.catalina.tribes.ChannelListener;
> import org.apache.catalina.tribes.group.GroupChannel;
> import org.apache.catalina.tribes.membership.StaticMember;
>
>
> /**
>  *
>  * @author vince
>  * demonstration of tribes messaging between remote hosts
>  * three jar files are required
>    (org.apache)
>    catalina.jar
>    catalina-tribes.jar
>    tomcat-embed-logging-juli.jar
>
>    compile and run with following arguments
>    java -jar jarfileName.jar ss
>    java -jar jarfileName.jar xx.xx.xx.xx NNNN
>
>   where jarfileName is whatever you call your jar file
>   ss is the literal argument "ss" for the machine designated as
> "superserver" (sort of arbitrary)
>
>   for machines other than superserver:
>   xx.xx.xx.xx is the IPv4 address for the superserver machine
>   NNNN is relevant port number
>
>   Note that tribes normally uses port 4000. However if you run the
> application at superserver first
>   you will then know which port number tribes is using (could be 4001, 4002
> ...)
>
>   Note also that if the superserver is part of a LAN, there will be a
> router involved;
>   the remote applications will then need to point to the router IP address
> and the router port that
>   is redirected to the machine/port running tribes (more of this below)
>
>   If non-superserver machines use a router, these also have to have
> appropriate redirections set up.
>
>  Some log output refers to clustering functionality operating.
>  This does not seem to interfere with the messaging operations used.
>  I have not looked into any possible mechanisms to suppress clustering
> threads.
>  A very important limitation to remote messaging (and a possible solution)
> is discussed here.
> http://tomcat.10.x6.nabble
>
> .com/overcoming-a-message-size-limitation-in-tribes-parallel-messaging-with-NioSender-tt4995446.html
>
>  */
> public class TribesRemote {
> static TribesRemote tribesRemote;
> static Charset UTF8=Charset.forName("UTF-8");
> static int membersOnLine=0;
> ChannelListener msgListener;// = new MyMessageListener(this);
> MembershipListener mbrListener;// = new MyMemberListener();
> StaticMember superServerStaticMember;
> boolean amSuperServer=false;
> private long lastMessageReceived;
> String remoteHostIPv4Address;
> int remoteHostPort;
> Channel myChannel;
>
> public static void log(String s){
> System.out.println("INFO:  "+s);
> }
>
> public static void log(Exception ex){
> System.out.println("ERROR  "+ex.getMessage());
> //Logger.getLogger(TribesRemote.class.getName()).log(Level.SEVERE, null,
> ex);//uncomment here for detailed error msg
> }
>
> public static void main(String[]args) throws IOException, ChannelException{
> TribesRemote.tribesRemote=new TribesRemote(args);
> TribesRemote.tribesRemote.engage();
> }
>
> TribesRemote(String[] args) throws IOException, ChannelException{
> log(this.addressesForThisMachine());
> remoteHostIPv4Address="xx.xx.xx.xx"; //actual superserver address may be
> placed here
> remoteHostPort=4000; //actual superserver port may be placed here
> if(args.length==0){
> log("TribesRemote has been lauched with zero arguments");
> }
> else{
> String argz="";
> for(int i=0;i<args.length;i++)argz=argz+args[i]+"  ";
> log("TribesRemote has been lauched with the following arguments "+argz);
>  if(args.length>1){   // otherwise subservers can be started using two
> arguments
>  remoteHostIPv4Address=args[0]; // IPv4 adddress in xx.xx.xx.xx format
> where x is numeric
>  remoteHostPort=Integer.parseInt(args[1]); //the port number which tribes
> starts on
>  }
>  if(args[0].equalsIgnoreCase("ss")){ ///NB superserver started with
> singular argument "ss"
>  amSuperServer=true;
>  log("this is deginated superserver and will wait for members to introduce
> themselves");
>  }
>  else{
>  superServerStaticMember=new
> StaticMember(remoteHostIPv4Address,remoteHostPort,0);
>  }
> }
>
>                          //tribes always uses 4000 if available (otherwise
> it uses 4001, 4002 etc)
>                          //this application will output the actual tribes
> address => std output
>                          //but setting remoteHostPort to 4000 may not be
> appropriate if you have a router
>                          //if you have a router then the remote host needs
> to know the IPv4 for the router and
>                          //the redirection port number pointing to a tribes
> socket for a LAN machine
>                          //for example:
>                          //the remote router has fixed IP address say
> 203.12.32.235
>                          //the remote machine running tribes (on p4000) has
> fixed LAN address say 192.168.1.63
>                          //(in Linux you set fixed LAN IP address in the
> '/etc/hosts' file)
>                          //lets say you create a port-forwarding in the
> router so port 45555 redirects to 192.168.1.63 / port 4000
>                          //in such a case the value for
> remoteHostIPv4Address will be 203.12.32.235
>                          //and remoteHostPort will be 45555
>                          //ie {203.12.32.235 , 45555} => redirects to =>
> {192.168.1.63 , 4000}
>                          //if there is no router (say you have 2 VPS), then
> no redirect is required
>                          //whereupon remoteHostPort will probably be 4000
> (as long as that address is free when tribes starts)
>
>
> msgListener = new MyMessageListener();
> mbrListener = new MyMemberListener();
> myChannel = new GroupChannel();
> myChannel.addMembershipListener(mbrListener);
> myChannel.addChannelListener(msgListener);
> myChannel.start(Channel.DEFAULT);
> log("TRIBES HAS STARTED ON PORT: "+Integer.toString(getLocalPort()));
> }
>
> void sendMessage(String message,Member member) throws ChannelException{
> Member[] group = new Member[]{member};
> this.myChannel.send(group,new
> ByteMessage(message.getBytes(UTF8)),Channel.SEND_OPTIONS_DEFAULT);
> }
>
> String addressesForThisMachine() throws SocketException{
> String ss="network addresses for this machine: ";
> Enumeration<InetAddress>ee;
> Enumeration<NetworkInterface>ei;
> ei=NetworkInterface.getNetworkInterfaces();
>  while(ei.hasMoreElements()){
>  ee=((NetworkInterface)ei.nextElement()).getInetAddresses();
>   while(ee.hasMoreElements()){
>   ss=ss+ee.nextElement().getHostAddress()+";    ";
>   }
>  }
> return ss;
> }
>
>
> /*
>  * subserver will run this
>  */
> private void engageInDialogue(){
>  do{
>   try{
>   this.sendMessage("* hello superserver *",superServerStaticMember);
>   }
>   catch (ChannelException ex) {
>   TribesRemote.log(ex);
>   }
>   try {
>   Thread.currentThread().sleep(10000);
>   }
>   catch (InterruptedException ex) {
>   System.exit(0);
>   }
>   if(System.currentTimeMillis()-lastMessageTime()>12000){
>   log("no messages in last 12 seconds");
>   }
>  }while(true);
> }
> /*
>  * superserver will run this
>  */
> private void waitForMessages(){
>  do{
>   try{
>   Thread.currentThread().sleep(10000);
>   }
>   catch (InterruptedException ex) {
>   System.exit(0);
>   }
>  }while(true);
> }
>
>  int getLocalPort() {
>  return this.myChannel.getLocalMember(true).getPort();
>  }
>
>  private void engage(){
>   if(this.amSuperServer){
>   this.waitForMessages();
>   }
>   else{
>   this.engageInDialogue();
>   }
>  }
>
>  private long lastMessageTime() {
>  return this.lastMessageReceived;
>  }
>
>  void messageReceived(String message, Member sender) throws
> ChannelException {
>  this.lastMessageReceived=System.currentTimeMillis();
>   if(this.amSuperServer){
>   this.sendMessage(message + " ((hello back ))",sender);
>   }
>  }
>
>  private static class MyMessageListener implements ChannelListener{
>
>   @Override
>   public void messageReceived(Serializable s,Member sender){
>   byte[] b=((ByteMessage)s).getMessage();
>   String message=new String(b,TribesRemote.UTF8);
>   TribesRemote.log("message received:  "+message);
>    try{
>    TribesRemote.tribesRemote.messageReceived(message,sender);
>    }
>    catch (ChannelException ex) {
>    TribesRemote.log(ex);
>    }
>   }
>
>   @Override
>   public boolean accept(Serializable msg, Member sender) {
>   return true;
>   }
>  }
>
>  //this is part of clustering that has not been removed from tribes
>  private static class MyMemberListener implements MembershipListener{
>
>  @Override
>  public void memberAdded(Member member){
>  //TribesRemote.tribesRemote.memberDetected(member);
>  }
>
>  @Override
>  public void memberDisappeared(Member member){
>  //TribesRemote.tribesRemote.memberGone(member);
>  }
>
>  }
>
>
>
>
>
>
>
> }
>
>
> On Thu, Jul 4, 2013 at 6:57 PM, Jose María Zaragoza <demablogia@gmail.com
> >wrote:
>
> > Thanks Vince.
> > I'll take a look , but , it doesn't look trivial , not at all
> >
> > Regards
> >
> >
> > 2013/7/4 Vince Stewart <st...@gmail.com>
> >
> > > Hi Jose,
> > >
> > > a couple of things,
> > > 1) I use embedded Tomcat to build my application and this has allowed
> me
> > to
> > > maintain 2 single-line patches in tribes classes by adding tribes
> source
> > > code to my compilations. However those patches are only necessary with
> > > large messages that take more than 3 seconds to be transmitted from the
> > > transmitting machine to the Internet Service Provider machine (approx
> 0.5
> > > meg for my system). There is a config setting
> (Sender/Transport/timeout)
> > > that's supposed to alter this 3 second timeout limit but I'm not sure
> it
> > > works.
> > > 2) The implementation is not at all trivial. You have to register
> > > StaticMember objects because usual member discovery does not work over
> > > wide-area network (WAN). I allocate one machine as "SuperServer" and
> all
> > > other machines have to enroll with SuperServer at startup. All machines
> > > need to have a unique combination of Ipv4 address and port number
> (which
> > > might represent a redirection port for use by the router whereupon
> > > networked machines also need LAN addresses set). Once registration is
> > > complete, all sub-Server machines can send/receive SuperServer and vice
> > > versa.
> > >
> > > There is a tutorial on-line which is adequate but not for WAN. I think
> > you
> > > have at least two weeks of work in front of you using tribes but I am
> > very
> > > happy I used this method.
> > > None of my code would add much (except confusion) to that in the
> > tutorial.
> > > Make sure you start without multicast enabled as it currently is
> suitable
> > > only for LAN.
> > >
> > >  ///Class Constructor
> > >  public ServerMessaging() throws SocketException{
> > >  this.myChannel=new GroupChannel();
> > >  ChannelListener msgListener = new ServerMessaging.MyMessageListener();
> > >  MembershipListener mbrListener = new
> ServerMessaging.MyMemberListener();
> > >  myChannel.addMembershipListener(mbrListener);
> > >  myChannel.addChannelListener(msgListener);
> > >   try{
> > >
> > >
> > >
> >
> myChannel.start(Channel.MBR_TX_SEQ|Channel.MBR_RX_SEQ|Channel.SND_TX_SEQ|Channel.SND_RX_SEQ);//no
> > > multicast
> > >   }
> > >   catch(ChannelException e){
> > >   U.log(e);
> > >   }
> > >  }
> > >
> > > public void detectOrderNumber_EnrollWithSuperServer() throws
> > > ChannelException{
> > > setMyServerOrderStatus(); // machine reads its mac address or some
> file;
> > > then from a table will set serverOrderNumber to 0 for superserver ;
> > others
> > > 1,2,3...
> > >  if(this.getServerOrderNumber()==0){  ////meaning this is the
> superserver
> > >  someObject.doSomeThingMaybe();
> > >  }
> > >  else{
> > >  this.sendAckRequiredMessage(0,"Enrollment"); /// first argument
> > specifies
> > > SuperServer, member 0 (a table will need to be provided to hold IPv4
> > > address and port for each member)
> > >  }
> > > }
> > >
> >
>
>
>
> --
> Vince Stewart
>

Re: Share info across different sessions & servers

Posted by Vince Stewart <st...@gmail.com>.
hi Jose,
here is a working demo for exchanging messages between remote hosts using
tribes


import java.io.IOException;
import java.io.Serializable;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.catalina.tribes.ByteMessage;
import org.apache.catalina.tribes.Channel;
import org.apache.catalina.tribes.ChannelException;
import org.apache.catalina.tribes.Member;
import org.apache.catalina.tribes.MembershipListener;
import org.apache.catalina.tribes.ChannelListener;
import org.apache.catalina.tribes.group.GroupChannel;
import org.apache.catalina.tribes.membership.StaticMember;


/**
 *
 * @author vince
 * demonstration of tribes messaging between remote hosts
 * three jar files are required
   (org.apache)
   catalina.jar
   catalina-tribes.jar
   tomcat-embed-logging-juli.jar

   compile and run with following arguments
   java -jar jarfileName.jar ss
   java -jar jarfileName.jar xx.xx.xx.xx NNNN

  where jarfileName is whatever you call your jar file
  ss is the literal argument "ss" for the machine designated as
"superserver" (sort of arbitrary)

  for machines other than superserver:
  xx.xx.xx.xx is the IPv4 address for the superserver machine
  NNNN is relevant port number

  Note that tribes normally uses port 4000. However if you run the
application at superserver first
  you will then know which port number tribes is using (could be 4001, 4002
...)

  Note also that if the superserver is part of a LAN, there will be a
router involved;
  the remote applications will then need to point to the router IP address
and the router port that
  is redirected to the machine/port running tribes (more of this below)

  If non-superserver machines use a router, these also have to have
appropriate redirections set up.

 Some log output refers to clustering functionality operating.
 This does not seem to interfere with the messaging operations used.
 I have not looked into any possible mechanisms to suppress clustering
threads.
 A very important limitation to remote messaging (and a possible solution)
is discussed here.
http://tomcat.10.x6.nabble
.com/overcoming-a-message-size-limitation-in-tribes-parallel-messaging-with-NioSender-tt4995446.html

 */
public class TribesRemote {
static TribesRemote tribesRemote;
static Charset UTF8=Charset.forName("UTF-8");
static int membersOnLine=0;
ChannelListener msgListener;// = new MyMessageListener(this);
MembershipListener mbrListener;// = new MyMemberListener();
StaticMember superServerStaticMember;
boolean amSuperServer=false;
private long lastMessageReceived;
String remoteHostIPv4Address;
int remoteHostPort;
Channel myChannel;

public static void log(String s){
System.out.println("INFO:  "+s);
}

public static void log(Exception ex){
System.out.println("ERROR  "+ex.getMessage());
//Logger.getLogger(TribesRemote.class.getName()).log(Level.SEVERE, null,
ex);//uncomment here for detailed error msg
}

public static void main(String[]args) throws IOException, ChannelException{
TribesRemote.tribesRemote=new TribesRemote(args);
TribesRemote.tribesRemote.engage();
}

TribesRemote(String[] args) throws IOException, ChannelException{
log(this.addressesForThisMachine());
remoteHostIPv4Address="xx.xx.xx.xx"; //actual superserver address may be
placed here
remoteHostPort=4000; //actual superserver port may be placed here
if(args.length==0){
log("TribesRemote has been lauched with zero arguments");
}
else{
String argz="";
for(int i=0;i<args.length;i++)argz=argz+args[i]+"  ";
log("TribesRemote has been lauched with the following arguments "+argz);
 if(args.length>1){   // otherwise subservers can be started using two
arguments
 remoteHostIPv4Address=args[0]; // IPv4 adddress in xx.xx.xx.xx format
where x is numeric
 remoteHostPort=Integer.parseInt(args[1]); //the port number which tribes
starts on
 }
 if(args[0].equalsIgnoreCase("ss")){ ///NB superserver started with
singular argument "ss"
 amSuperServer=true;
 log("this is deginated superserver and will wait for members to introduce
themselves");
 }
 else{
 superServerStaticMember=new
StaticMember(remoteHostIPv4Address,remoteHostPort,0);
 }
}

                         //tribes always uses 4000 if available (otherwise
it uses 4001, 4002 etc)
                         //this application will output the actual tribes
address => std output
                         //but setting remoteHostPort to 4000 may not be
appropriate if you have a router
                         //if you have a router then the remote host needs
to know the IPv4 for the router and
                         //the redirection port number pointing to a tribes
socket for a LAN machine
                         //for example:
                         //the remote router has fixed IP address say
203.12.32.235
                         //the remote machine running tribes (on p4000) has
fixed LAN address say 192.168.1.63
                         //(in Linux you set fixed LAN IP address in the
'/etc/hosts' file)
                         //lets say you create a port-forwarding in the
router so port 45555 redirects to 192.168.1.63 / port 4000
                         //in such a case the value for
remoteHostIPv4Address will be 203.12.32.235
                         //and remoteHostPort will be 45555
                         //ie {203.12.32.235 , 45555} => redirects to =>
{192.168.1.63 , 4000}
                         //if there is no router (say you have 2 VPS), then
no redirect is required
                         //whereupon remoteHostPort will probably be 4000
(as long as that address is free when tribes starts)


msgListener = new MyMessageListener();
mbrListener = new MyMemberListener();
myChannel = new GroupChannel();
myChannel.addMembershipListener(mbrListener);
myChannel.addChannelListener(msgListener);
myChannel.start(Channel.DEFAULT);
log("TRIBES HAS STARTED ON PORT: "+Integer.toString(getLocalPort()));
}

void sendMessage(String message,Member member) throws ChannelException{
Member[] group = new Member[]{member};
this.myChannel.send(group,new
ByteMessage(message.getBytes(UTF8)),Channel.SEND_OPTIONS_DEFAULT);
}

String addressesForThisMachine() throws SocketException{
String ss="network addresses for this machine: ";
Enumeration<InetAddress>ee;
Enumeration<NetworkInterface>ei;
ei=NetworkInterface.getNetworkInterfaces();
 while(ei.hasMoreElements()){
 ee=((NetworkInterface)ei.nextElement()).getInetAddresses();
  while(ee.hasMoreElements()){
  ss=ss+ee.nextElement().getHostAddress()+";    ";
  }
 }
return ss;
}


/*
 * subserver will run this
 */
private void engageInDialogue(){
 do{
  try{
  this.sendMessage("* hello superserver *",superServerStaticMember);
  }
  catch (ChannelException ex) {
  TribesRemote.log(ex);
  }
  try {
  Thread.currentThread().sleep(10000);
  }
  catch (InterruptedException ex) {
  System.exit(0);
  }
  if(System.currentTimeMillis()-lastMessageTime()>12000){
  log("no messages in last 12 seconds");
  }
 }while(true);
}
/*
 * superserver will run this
 */
private void waitForMessages(){
 do{
  try{
  Thread.currentThread().sleep(10000);
  }
  catch (InterruptedException ex) {
  System.exit(0);
  }
 }while(true);
}

 int getLocalPort() {
 return this.myChannel.getLocalMember(true).getPort();
 }

 private void engage(){
  if(this.amSuperServer){
  this.waitForMessages();
  }
  else{
  this.engageInDialogue();
  }
 }

 private long lastMessageTime() {
 return this.lastMessageReceived;
 }

 void messageReceived(String message, Member sender) throws
ChannelException {
 this.lastMessageReceived=System.currentTimeMillis();
  if(this.amSuperServer){
  this.sendMessage(message + " ((hello back ))",sender);
  }
 }

 private static class MyMessageListener implements ChannelListener{

  @Override
  public void messageReceived(Serializable s,Member sender){
  byte[] b=((ByteMessage)s).getMessage();
  String message=new String(b,TribesRemote.UTF8);
  TribesRemote.log("message received:  "+message);
   try{
   TribesRemote.tribesRemote.messageReceived(message,sender);
   }
   catch (ChannelException ex) {
   TribesRemote.log(ex);
   }
  }

  @Override
  public boolean accept(Serializable msg, Member sender) {
  return true;
  }
 }

 //this is part of clustering that has not been removed from tribes
 private static class MyMemberListener implements MembershipListener{

 @Override
 public void memberAdded(Member member){
 //TribesRemote.tribesRemote.memberDetected(member);
 }

 @Override
 public void memberDisappeared(Member member){
 //TribesRemote.tribesRemote.memberGone(member);
 }

 }







}


On Thu, Jul 4, 2013 at 6:57 PM, Jose María Zaragoza <de...@gmail.com>wrote:

> Thanks Vince.
> I'll take a look , but , it doesn't look trivial , not at all
>
> Regards
>
>
> 2013/7/4 Vince Stewart <st...@gmail.com>
>
> > Hi Jose,
> >
> > a couple of things,
> > 1) I use embedded Tomcat to build my application and this has allowed me
> to
> > maintain 2 single-line patches in tribes classes by adding tribes source
> > code to my compilations. However those patches are only necessary with
> > large messages that take more than 3 seconds to be transmitted from the
> > transmitting machine to the Internet Service Provider machine (approx 0.5
> > meg for my system). There is a config setting (Sender/Transport/timeout)
> > that's supposed to alter this 3 second timeout limit but I'm not sure it
> > works.
> > 2) The implementation is not at all trivial. You have to register
> > StaticMember objects because usual member discovery does not work over
> > wide-area network (WAN). I allocate one machine as "SuperServer" and all
> > other machines have to enroll with SuperServer at startup. All machines
> > need to have a unique combination of Ipv4 address and port number (which
> > might represent a redirection port for use by the router whereupon
> > networked machines also need LAN addresses set). Once registration is
> > complete, all sub-Server machines can send/receive SuperServer and vice
> > versa.
> >
> > There is a tutorial on-line which is adequate but not for WAN. I think
> you
> > have at least two weeks of work in front of you using tribes but I am
> very
> > happy I used this method.
> > None of my code would add much (except confusion) to that in the
> tutorial.
> > Make sure you start without multicast enabled as it currently is suitable
> > only for LAN.
> >
> >  ///Class Constructor
> >  public ServerMessaging() throws SocketException{
> >  this.myChannel=new GroupChannel();
> >  ChannelListener msgListener = new ServerMessaging.MyMessageListener();
> >  MembershipListener mbrListener = new ServerMessaging.MyMemberListener();
> >  myChannel.addMembershipListener(mbrListener);
> >  myChannel.addChannelListener(msgListener);
> >   try{
> >
> >
> >
> myChannel.start(Channel.MBR_TX_SEQ|Channel.MBR_RX_SEQ|Channel.SND_TX_SEQ|Channel.SND_RX_SEQ);//no
> > multicast
> >   }
> >   catch(ChannelException e){
> >   U.log(e);
> >   }
> >  }
> >
> > public void detectOrderNumber_EnrollWithSuperServer() throws
> > ChannelException{
> > setMyServerOrderStatus(); // machine reads its mac address or some file;
> > then from a table will set serverOrderNumber to 0 for superserver ;
> others
> > 1,2,3...
> >  if(this.getServerOrderNumber()==0){  ////meaning this is the superserver
> >  someObject.doSomeThingMaybe();
> >  }
> >  else{
> >  this.sendAckRequiredMessage(0,"Enrollment"); /// first argument
> specifies
> > SuperServer, member 0 (a table will need to be provided to hold IPv4
> > address and port for each member)
> >  }
> > }
> >
>



-- 
Vince Stewart

Re: Share info across different sessions & servers

Posted by Jose María Zaragoza <de...@gmail.com>.
Thanks Vince.
I'll take a look , but , it doesn't look trivial , not at all

Regards


2013/7/4 Vince Stewart <st...@gmail.com>

> Hi Jose,
>
> a couple of things,
> 1) I use embedded Tomcat to build my application and this has allowed me to
> maintain 2 single-line patches in tribes classes by adding tribes source
> code to my compilations. However those patches are only necessary with
> large messages that take more than 3 seconds to be transmitted from the
> transmitting machine to the Internet Service Provider machine (approx 0.5
> meg for my system). There is a config setting (Sender/Transport/timeout)
> that's supposed to alter this 3 second timeout limit but I'm not sure it
> works.
> 2) The implementation is not at all trivial. You have to register
> StaticMember objects because usual member discovery does not work over
> wide-area network (WAN). I allocate one machine as "SuperServer" and all
> other machines have to enroll with SuperServer at startup. All machines
> need to have a unique combination of Ipv4 address and port number (which
> might represent a redirection port for use by the router whereupon
> networked machines also need LAN addresses set). Once registration is
> complete, all sub-Server machines can send/receive SuperServer and vice
> versa.
>
> There is a tutorial on-line which is adequate but not for WAN. I think you
> have at least two weeks of work in front of you using tribes but I am very
> happy I used this method.
> None of my code would add much (except confusion) to that in the tutorial.
> Make sure you start without multicast enabled as it currently is suitable
> only for LAN.
>
>  ///Class Constructor
>  public ServerMessaging() throws SocketException{
>  this.myChannel=new GroupChannel();
>  ChannelListener msgListener = new ServerMessaging.MyMessageListener();
>  MembershipListener mbrListener = new ServerMessaging.MyMemberListener();
>  myChannel.addMembershipListener(mbrListener);
>  myChannel.addChannelListener(msgListener);
>   try{
>
>
> myChannel.start(Channel.MBR_TX_SEQ|Channel.MBR_RX_SEQ|Channel.SND_TX_SEQ|Channel.SND_RX_SEQ);//no
> multicast
>   }
>   catch(ChannelException e){
>   U.log(e);
>   }
>  }
>
> public void detectOrderNumber_EnrollWithSuperServer() throws
> ChannelException{
> setMyServerOrderStatus(); // machine reads its mac address or some file;
> then from a table will set serverOrderNumber to 0 for superserver ; others
> 1,2,3...
>  if(this.getServerOrderNumber()==0){  ////meaning this is the superserver
>  someObject.doSomeThingMaybe();
>  }
>  else{
>  this.sendAckRequiredMessage(0,"Enrollment"); /// first argument specifies
> SuperServer, member 0 (a table will need to be provided to hold IPv4
> address and port for each member)
>  }
> }
>

Re: Share info across different sessions & servers

Posted by "mailinglist@j-b-s.de" <ma...@j-b-s.de>.
Hi!

what about treating this problem as a chat system? You want to broadcast messages, right? Maybe http://cometd.org/
is of any help (did not use it now personally)

Jens

Sent from my iPhone

On 04.07.2013, at 00:14, Vince Stewart <st...@gmail.com> wrote:

> Hi Jose,
> 
> a couple of things,
> 1) I use embedded Tomcat to build my application and this has allowed me to
> maintain 2 single-line patches in tribes classes by adding tribes source
> code to my compilations. However those patches are only necessary with
> large messages that take more than 3 seconds to be transmitted from the
> transmitting machine to the Internet Service Provider machine (approx 0.5
> meg for my system). There is a config setting (Sender/Transport/timeout)
> that's supposed to alter this 3 second timeout limit but I'm not sure it
> works.
> 2) The implementation is not at all trivial. You have to register
> StaticMember objects because usual member discovery does not work over
> wide-area network (WAN). I allocate one machine as "SuperServer" and all
> other machines have to enroll with SuperServer at startup. All machines
> need to have a unique combination of Ipv4 address and port number (which
> might represent a redirection port for use by the router whereupon
> networked machines also need LAN addresses set). Once registration is
> complete, all sub-Server machines can send/receive SuperServer and vice
> versa.
> 
> There is a tutorial on-line which is adequate but not for WAN. I think you
> have at least two weeks of work in front of you using tribes but I am very
> happy I used this method.
> None of my code would add much (except confusion) to that in the tutorial.
> Make sure you start without multicast enabled as it currently is suitable
> only for LAN.
> 
> ///Class Constructor
> public ServerMessaging() throws SocketException{
> this.myChannel=new GroupChannel();
> ChannelListener msgListener = new ServerMessaging.MyMessageListener();
> MembershipListener mbrListener = new ServerMessaging.MyMemberListener();
> myChannel.addMembershipListener(mbrListener);
> myChannel.addChannelListener(msgListener);
>  try{
> 
> myChannel.start(Channel.MBR_TX_SEQ|Channel.MBR_RX_SEQ|Channel.SND_TX_SEQ|Channel.SND_RX_SEQ);//no
> multicast
>  }
>  catch(ChannelException e){
>  U.log(e);
>  }
> }
> 
> public void detectOrderNumber_EnrollWithSuperServer() throws
> ChannelException{
> setMyServerOrderStatus(); // machine reads its mac address or some file;
> then from a table will set serverOrderNumber to 0 for superserver ; others
> 1,2,3...
> if(this.getServerOrderNumber()==0){  ////meaning this is the superserver
> someObject.doSomeThingMaybe();
> }
> else{
> this.sendAckRequiredMessage(0,"Enrollment"); /// first argument specifies
> SuperServer, member 0 (a table will need to be provided to hold IPv4
> address and port for each member)
> }
> }

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


Re: Share info across different sessions & servers

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

Vince,

On 7/3/13 6:14 PM, Vince Stewart wrote:
> 1) I use embedded Tomcat to build my application and this has
> allowed me to maintain 2 single-line patches in tribes classes by
> adding tribes source code to my compilations. However those patches
> are only necessary with large messages that take more than 3
> seconds to be transmitted from the transmitting machine to the
> Internet Service Provider machine (approx 0.5 meg for my system).
> There is a config setting (Sender/Transport/timeout) that's
> supposed to alter this 3 second timeout limit but I'm not sure it 
> works. 2) The implementation is not at all trivial. You have to
> register StaticMember objects because usual member discovery does
> not work over wide-area network (WAN). I allocate one machine as
> "SuperServer" and all other machines have to enroll with
> SuperServer at startup. All machines need to have a unique
> combination of Ipv4 address and port number (which might represent
> a redirection port for use by the router whereupon networked
> machines also need LAN addresses set). Once registration is 
> complete, all sub-Server machines can send/receive SuperServer and
> vice versa.
> 
> There is a tutorial on-line which is adequate but not for WAN. I
> think you have at least two weeks of work in front of you using
> tribes but I am very happy I used this method.

If you want to simplify things over a WAN, just use a VLAN / VPN or
brute-force it all with stunnel. Then you can pretend you are running
"locally".

> None of my code would add much (except confusion) to that in the
> tutorial. Make sure you start without multicast enabled as it
> currently is suitable only for LAN.

... or VPN/VLAN.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJR2hzeAAoJEBzwKT+lPKRYroUP/jM9FotiJ1oirhizPljCy8Qi
Dl1ZKiA2kefL/RQkUc5M0ne9QU5wK8q7b7AjvBjAjWyZq1+Adm9+ZhPmFfVqCSox
dtuV5uNCYjWPkPQiBh4CWUEkBdZs9b4tbRkDir1zYgFGWgAJBV67Umoa6bouuOil
qmAEG/9CZf7HNb5qzQZgrD52T/2kPpLMkzQtnqYVA9PSieNZxNiEMBPCqTviNeYD
nxQUD6BOMJ2eTjX03ovZw0ogBa5EoaP0Az6FrJhQJkSs/Kq6IaznlY5ati3Eck42
Xkvr6KT3zssKlzMRlVUOY7MhB3YgCf7O09rCgoc+vyfB6KpXNhzHlHI5th9aqyi+
a4Mp+YtPjUuXEj16jygAhRLh1KPTULttlmfdmwF+3MbOWYRGuFab+X3uK3t/3pTn
AQMMEUjYoh+4a8QgvFNdZL7C3ETzbwozi+dO038fIzOX47SGaJIxy/ocbyEgN6lk
SPv8dfLQ7lMqkFEQhYBamr4KIP2iKFFgnlOfPwj1iMt1AtrKZCJFYYiLz1lwW8pG
wWGJkwdo1mrJAJjTQWr2DTmTX+iXj5UWuoypMKFk26uQvcrYxuJQW5i7p98DKa92
I9nI2XpfDg5mjxy5yRoykujJqzpzi4qBm9FtDq0VjBoxoS6COgGjGTkh61M/MVha
sWrP494NGhHNMT6WQ+EN
=j7t6
-----END PGP SIGNATURE-----

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


Re: Share info across different sessions & servers

Posted by Vince Stewart <st...@gmail.com>.
Hi Jose,

a couple of things,
1) I use embedded Tomcat to build my application and this has allowed me to
maintain 2 single-line patches in tribes classes by adding tribes source
code to my compilations. However those patches are only necessary with
large messages that take more than 3 seconds to be transmitted from the
transmitting machine to the Internet Service Provider machine (approx 0.5
meg for my system). There is a config setting (Sender/Transport/timeout)
that's supposed to alter this 3 second timeout limit but I'm not sure it
works.
2) The implementation is not at all trivial. You have to register
StaticMember objects because usual member discovery does not work over
wide-area network (WAN). I allocate one machine as "SuperServer" and all
other machines have to enroll with SuperServer at startup. All machines
need to have a unique combination of Ipv4 address and port number (which
might represent a redirection port for use by the router whereupon
networked machines also need LAN addresses set). Once registration is
complete, all sub-Server machines can send/receive SuperServer and vice
versa.

There is a tutorial on-line which is adequate but not for WAN. I think you
have at least two weeks of work in front of you using tribes but I am very
happy I used this method.
None of my code would add much (except confusion) to that in the tutorial.
Make sure you start without multicast enabled as it currently is suitable
only for LAN.

 ///Class Constructor
 public ServerMessaging() throws SocketException{
 this.myChannel=new GroupChannel();
 ChannelListener msgListener = new ServerMessaging.MyMessageListener();
 MembershipListener mbrListener = new ServerMessaging.MyMemberListener();
 myChannel.addMembershipListener(mbrListener);
 myChannel.addChannelListener(msgListener);
  try{

myChannel.start(Channel.MBR_TX_SEQ|Channel.MBR_RX_SEQ|Channel.SND_TX_SEQ|Channel.SND_RX_SEQ);//no
multicast
  }
  catch(ChannelException e){
  U.log(e);
  }
 }

public void detectOrderNumber_EnrollWithSuperServer() throws
ChannelException{
setMyServerOrderStatus(); // machine reads its mac address or some file;
then from a table will set serverOrderNumber to 0 for superserver ; others
1,2,3...
 if(this.getServerOrderNumber()==0){  ////meaning this is the superserver
 someObject.doSomeThingMaybe();
 }
 else{
 this.sendAckRequiredMessage(0,"Enrollment"); /// first argument specifies
SuperServer, member 0 (a table will need to be provided to hold IPv4
address and port for each member)
 }
}

Re: Share info across different sessions & servers

Posted by Jose María Zaragoza <de...@gmail.com>.
Thanks Vince.
This could be an option.
The documentation is poor and I don't see many examples in the web

Could you send to  me some code as example & server.xml configuration ?

Regards





2013/7/3 Vince Stewart <st...@gmail.com>

> I have am using "tribes" messaging to send messages between remote
> applications which include tomcat embedded. You construct your message and
> submit to a "sendMessage" process. All running apps are always listening
> for messages. They receive the message and then may or may not reply or
> broadcast as a result.
>
>
> On Wed, Jul 3, 2013 at 7:43 AM, Jose María Zaragoza <demablogia@gmail.com
> >wrote:
>
> > Thanks Christopher :
> >
> > Maybe I explained myself badly
> > I really need to send messages to a specific web session , not share data
> >
> > I need to pass some data ( message ) to a specific session from a remote
> > system ( a remote process from a remote system).
> > Finally, this data is passed to client's browser by AJAX Reverse
> >
> > My idea is the session creates a dynamic Queue and it configures itself
> as
> > Consumer
> > If I pass the Queue to remote process ( in message.replyTo() ) , the
> remote
> > process can send data to that specific session
> >
> > I could use a RDBS but , in this case, session needs to create a thread
> to
> > polling on a share table. And I don't like this idea, sorry.
> >
> > memcached sounds good but I don't know anything about it and I don't know
> > is is based on a event-driven architecture
> >
> >
> >
> > I need
> >
> > 1) send data/message from a remote process to a specific web session
> > 2) execute some code in this session
> > 3) consume ( a.k.a, delete ) that message
> >
> > Persistence is not a requirement but ActiveMQ allows it
> >
> > I'l try it with ActiveMQ
> >
> > Thanks again and regards
> >
> >
> >
> >
> >
> > 2013/7/2 Christopher Schultz <ch...@christopherschultz.net>
> >
> > > -----BEGIN PGP SIGNED MESSAGE-----
> > > Hash: SHA256
> > >
> > > Jose,
> > >
> > > On 7/2/13 3:22 AM, Jose María Zaragoza wrote:
> > > > Thanks I need to share formatted text data  ( XML, key/value,
> > > > ...I'm not sure yet )
> > > >
> > > > I don't understand your comment about JMS . I will use a JMS broker
> > > > as ActiveMQ . Probably it will be embebbed into the same JVM than
> > > > Tomcat server. ActiveMQ supports  persistent messages
> > >
> > > While JMS may work, it's really not the right solution. JMS is a
> > > messaging service, and you want a data-storage service.
> > >
> > > > I could use a database but I don't want to be making polling every
> > > > X seconds by a session
> > >
> > > You don't have to pull any data that the user doesn't need, do you?
> > >
> > > If you don't want to use a RDBMS, how about something like memcached?
> > > I asked about using memcached a while back on this list and got some
> > > other suggestions as well (as memcached doesn't make a great fail-safe
> > > shared-data storage system... it's really meant to be more of a cache
> > > of data available elsewhere).
> > >
> > > - -chris
> > > -----BEGIN PGP SIGNATURE-----
> > > Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> > > Comment: GPGTools - http://gpgtools.org
> > > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> > >
> > > iQIcBAEBCAAGBQJR0ycOAAoJEBzwKT+lPKRYaAsP+wfhqoLQWwJoYLpur0Z5VOeJ
> > > GUmylaW+kllpcbdFdVG81691rjUW1Ph5yQ2MQzPFKv0bCp2cyHMWQuJgAp1rq/Lo
> > > T6Bpba6IHeyucxEAk0XZfGu4efS+wc39ncq9C3GPamEvrN+locYGtM/lqSpkSxKz
> > > 5ADXD9o2//U5Nk00N0KHPH4xsp/wtx0NJgT1p9f1VUKgU9pVvGFhHvrozvdAEcnv
> > > 9U7IQroNO7uR3RnKL/rq9CH3MsxL/gbWCWEZ21WkaguLFysc67naaSQvimIoLok9
> > > eUfCK6Z5Bll4VeefK6YlA6E49sj01NZD1zuj0J/DGUiwBuFiNSZc1Z2NOZlue7Oo
> > > efpaRkjINouIfyk3RONa8/ZuNWf80ImX5vvJKEYK7ujc2LB7G8+ID95Toeej0eyg
> > > cZWHZo3N67nYgker4Kp4xn4VXBs4QfDzY/uOfsUyp8voNcCz6lBo38w8T3jvVJzV
> > > ci18cbWdRXQ3NrlaBkI8qJeEzMWAegM7C1IqJUspmlDHvsUIiamGA+ZF6nBNPr16
> > > w3lx8X8xWjGM63OQaoYMbTc2ZXFCkP0zkXXEcx49zyGMSEDSk2NySw2HkAOh9iVx
> > > tr7YCDChtFg8mBQPY6CiiasEtn8j9JMK/XawdDI34LTsO1molB5OvJDGo558BqMm
> > > 3hK/JZGxPkEPapvOfWRM
> > > =tOMh
> > > -----END PGP SIGNATURE-----
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > > For additional commands, e-mail: users-help@tomcat.apache.org
> > >
> > >
> >
>
>
>
> --
> Vince Stewart
>

Re: Share info across different sessions & servers

Posted by Vince Stewart <st...@gmail.com>.
I have am using "tribes" messaging to send messages between remote
applications which include tomcat embedded. You construct your message and
submit to a "sendMessage" process. All running apps are always listening
for messages. They receive the message and then may or may not reply or
broadcast as a result.


On Wed, Jul 3, 2013 at 7:43 AM, Jose María Zaragoza <de...@gmail.com>wrote:

> Thanks Christopher :
>
> Maybe I explained myself badly
> I really need to send messages to a specific web session , not share data
>
> I need to pass some data ( message ) to a specific session from a remote
> system ( a remote process from a remote system).
> Finally, this data is passed to client's browser by AJAX Reverse
>
> My idea is the session creates a dynamic Queue and it configures itself as
> Consumer
> If I pass the Queue to remote process ( in message.replyTo() ) , the remote
> process can send data to that specific session
>
> I could use a RDBS but , in this case, session needs to create a thread to
> polling on a share table. And I don't like this idea, sorry.
>
> memcached sounds good but I don't know anything about it and I don't know
> is is based on a event-driven architecture
>
>
>
> I need
>
> 1) send data/message from a remote process to a specific web session
> 2) execute some code in this session
> 3) consume ( a.k.a, delete ) that message
>
> Persistence is not a requirement but ActiveMQ allows it
>
> I'l try it with ActiveMQ
>
> Thanks again and regards
>
>
>
>
>
> 2013/7/2 Christopher Schultz <ch...@christopherschultz.net>
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA256
> >
> > Jose,
> >
> > On 7/2/13 3:22 AM, Jose María Zaragoza wrote:
> > > Thanks I need to share formatted text data  ( XML, key/value,
> > > ...I'm not sure yet )
> > >
> > > I don't understand your comment about JMS . I will use a JMS broker
> > > as ActiveMQ . Probably it will be embebbed into the same JVM than
> > > Tomcat server. ActiveMQ supports  persistent messages
> >
> > While JMS may work, it's really not the right solution. JMS is a
> > messaging service, and you want a data-storage service.
> >
> > > I could use a database but I don't want to be making polling every
> > > X seconds by a session
> >
> > You don't have to pull any data that the user doesn't need, do you?
> >
> > If you don't want to use a RDBMS, how about something like memcached?
> > I asked about using memcached a while back on this list and got some
> > other suggestions as well (as memcached doesn't make a great fail-safe
> > shared-data storage system... it's really meant to be more of a cache
> > of data available elsewhere).
> >
> > - -chris
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> > Comment: GPGTools - http://gpgtools.org
> > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> >
> > iQIcBAEBCAAGBQJR0ycOAAoJEBzwKT+lPKRYaAsP+wfhqoLQWwJoYLpur0Z5VOeJ
> > GUmylaW+kllpcbdFdVG81691rjUW1Ph5yQ2MQzPFKv0bCp2cyHMWQuJgAp1rq/Lo
> > T6Bpba6IHeyucxEAk0XZfGu4efS+wc39ncq9C3GPamEvrN+locYGtM/lqSpkSxKz
> > 5ADXD9o2//U5Nk00N0KHPH4xsp/wtx0NJgT1p9f1VUKgU9pVvGFhHvrozvdAEcnv
> > 9U7IQroNO7uR3RnKL/rq9CH3MsxL/gbWCWEZ21WkaguLFysc67naaSQvimIoLok9
> > eUfCK6Z5Bll4VeefK6YlA6E49sj01NZD1zuj0J/DGUiwBuFiNSZc1Z2NOZlue7Oo
> > efpaRkjINouIfyk3RONa8/ZuNWf80ImX5vvJKEYK7ujc2LB7G8+ID95Toeej0eyg
> > cZWHZo3N67nYgker4Kp4xn4VXBs4QfDzY/uOfsUyp8voNcCz6lBo38w8T3jvVJzV
> > ci18cbWdRXQ3NrlaBkI8qJeEzMWAegM7C1IqJUspmlDHvsUIiamGA+ZF6nBNPr16
> > w3lx8X8xWjGM63OQaoYMbTc2ZXFCkP0zkXXEcx49zyGMSEDSk2NySw2HkAOh9iVx
> > tr7YCDChtFg8mBQPY6CiiasEtn8j9JMK/XawdDI34LTsO1molB5OvJDGo558BqMm
> > 3hK/JZGxPkEPapvOfWRM
> > =tOMh
> > -----END PGP SIGNATURE-----
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>



-- 
Vince Stewart

Re: Share info across different sessions & servers

Posted by Jose María Zaragoza <de...@gmail.com>.
Thanks Christopher :

Maybe I explained myself badly
I really need to send messages to a specific web session , not share data

I need to pass some data ( message ) to a specific session from a remote
system ( a remote process from a remote system).
Finally, this data is passed to client's browser by AJAX Reverse

My idea is the session creates a dynamic Queue and it configures itself as
Consumer
If I pass the Queue to remote process ( in message.replyTo() ) , the remote
process can send data to that specific session

I could use a RDBS but , in this case, session needs to create a thread to
polling on a share table. And I don't like this idea, sorry.

memcached sounds good but I don't know anything about it and I don't know
is is based on a event-driven architecture



I need

1) send data/message from a remote process to a specific web session
2) execute some code in this session
3) consume ( a.k.a, delete ) that message

Persistence is not a requirement but ActiveMQ allows it

I'l try it with ActiveMQ

Thanks again and regards





2013/7/2 Christopher Schultz <ch...@christopherschultz.net>

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Jose,
>
> On 7/2/13 3:22 AM, Jose María Zaragoza wrote:
> > Thanks I need to share formatted text data  ( XML, key/value,
> > ...I'm not sure yet )
> >
> > I don't understand your comment about JMS . I will use a JMS broker
> > as ActiveMQ . Probably it will be embebbed into the same JVM than
> > Tomcat server. ActiveMQ supports  persistent messages
>
> While JMS may work, it's really not the right solution. JMS is a
> messaging service, and you want a data-storage service.
>
> > I could use a database but I don't want to be making polling every
> > X seconds by a session
>
> You don't have to pull any data that the user doesn't need, do you?
>
> If you don't want to use a RDBMS, how about something like memcached?
> I asked about using memcached a while back on this list and got some
> other suggestions as well (as memcached doesn't make a great fail-safe
> shared-data storage system... it's really meant to be more of a cache
> of data available elsewhere).
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJR0ycOAAoJEBzwKT+lPKRYaAsP+wfhqoLQWwJoYLpur0Z5VOeJ
> GUmylaW+kllpcbdFdVG81691rjUW1Ph5yQ2MQzPFKv0bCp2cyHMWQuJgAp1rq/Lo
> T6Bpba6IHeyucxEAk0XZfGu4efS+wc39ncq9C3GPamEvrN+locYGtM/lqSpkSxKz
> 5ADXD9o2//U5Nk00N0KHPH4xsp/wtx0NJgT1p9f1VUKgU9pVvGFhHvrozvdAEcnv
> 9U7IQroNO7uR3RnKL/rq9CH3MsxL/gbWCWEZ21WkaguLFysc67naaSQvimIoLok9
> eUfCK6Z5Bll4VeefK6YlA6E49sj01NZD1zuj0J/DGUiwBuFiNSZc1Z2NOZlue7Oo
> efpaRkjINouIfyk3RONa8/ZuNWf80ImX5vvJKEYK7ujc2LB7G8+ID95Toeej0eyg
> cZWHZo3N67nYgker4Kp4xn4VXBs4QfDzY/uOfsUyp8voNcCz6lBo38w8T3jvVJzV
> ci18cbWdRXQ3NrlaBkI8qJeEzMWAegM7C1IqJUspmlDHvsUIiamGA+ZF6nBNPr16
> w3lx8X8xWjGM63OQaoYMbTc2ZXFCkP0zkXXEcx49zyGMSEDSk2NySw2HkAOh9iVx
> tr7YCDChtFg8mBQPY6CiiasEtn8j9JMK/XawdDI34LTsO1molB5OvJDGo558BqMm
> 3hK/JZGxPkEPapvOfWRM
> =tOMh
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Share info across different sessions & servers

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

Jose,

On 7/2/13 3:22 AM, Jose María Zaragoza wrote:
> Thanks I need to share formatted text data  ( XML, key/value,
> ...I'm not sure yet )
> 
> I don't understand your comment about JMS . I will use a JMS broker
> as ActiveMQ . Probably it will be embebbed into the same JVM than
> Tomcat server. ActiveMQ supports  persistent messages

While JMS may work, it's really not the right solution. JMS is a
messaging service, and you want a data-storage service.

> I could use a database but I don't want to be making polling every
> X seconds by a session

You don't have to pull any data that the user doesn't need, do you?

If you don't want to use a RDBMS, how about something like memcached?
I asked about using memcached a while back on this list and got some
other suggestions as well (as memcached doesn't make a great fail-safe
shared-data storage system... it's really meant to be more of a cache
of data available elsewhere).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJR0ycOAAoJEBzwKT+lPKRYaAsP+wfhqoLQWwJoYLpur0Z5VOeJ
GUmylaW+kllpcbdFdVG81691rjUW1Ph5yQ2MQzPFKv0bCp2cyHMWQuJgAp1rq/Lo
T6Bpba6IHeyucxEAk0XZfGu4efS+wc39ncq9C3GPamEvrN+locYGtM/lqSpkSxKz
5ADXD9o2//U5Nk00N0KHPH4xsp/wtx0NJgT1p9f1VUKgU9pVvGFhHvrozvdAEcnv
9U7IQroNO7uR3RnKL/rq9CH3MsxL/gbWCWEZ21WkaguLFysc67naaSQvimIoLok9
eUfCK6Z5Bll4VeefK6YlA6E49sj01NZD1zuj0J/DGUiwBuFiNSZc1Z2NOZlue7Oo
efpaRkjINouIfyk3RONa8/ZuNWf80ImX5vvJKEYK7ujc2LB7G8+ID95Toeej0eyg
cZWHZo3N67nYgker4Kp4xn4VXBs4QfDzY/uOfsUyp8voNcCz6lBo38w8T3jvVJzV
ci18cbWdRXQ3NrlaBkI8qJeEzMWAegM7C1IqJUspmlDHvsUIiamGA+ZF6nBNPr16
w3lx8X8xWjGM63OQaoYMbTc2ZXFCkP0zkXXEcx49zyGMSEDSk2NySw2HkAOh9iVx
tr7YCDChtFg8mBQPY6CiiasEtn8j9JMK/XawdDI34LTsO1molB5OvJDGo558BqMm
3hK/JZGxPkEPapvOfWRM
=tOMh
-----END PGP SIGNATURE-----

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


Re: Share info across different sessions & servers

Posted by Jose María Zaragoza <de...@gmail.com>.
Thanks
I need to share formatted text data  ( XML, key/value, ...I'm not sure yet )

I don't understand your comment about JMS . I will use a JMS broker as
ActiveMQ . Probably it will be embebbed into the same JVM than Tomcat
server. ActiveMQ supports  persistent messages


I could use a database but I don't want to be making polling every X
seconds by a session


Regards



2013/7/2 mailinglist@j-b-s.de <ma...@j-b-s.de>

> Hi!
>
> What kind of data do you want to share? Just a view "bytes"? Is there an
> requirement concerning durability/persistence/performance?
> Is this user=session related or do you want to share data in general?
> Usually if you have a session id the lb will route your user always to the
> same container? What about session replication, a database, terracotta?
>
> JMS: i doubt this will be working... you need a persistent message or a
> container started after the change was send will not noticed about it...
>
> Jens
>
>
>
> Sent from my iPhone
>
> On 02.07.2013, at 08:45, Jose María Zaragoza <de...@gmail.com> wrote:
>
> > Hello:
> >
> > I need to share data between sessions running in different Tomcat server.
> >
> > I 'd been thinking about using a JMS broker (as ActiveMQ ):
> >
> > - when a new session is created in Tomcat A, it's created a new unique
> > topic for this session
> > - the session registers itself as listener of that topic ( the only one
> > listener )
> > - publish the name of this topic by some way , so it can be found by
> > another session in Tomcat B
> >
> > I don't know if somebody has used something like this sometime, and how
> > he/she did it
> > Any suggestion/opinion  ?
> >
> > I'm not sure either use only one topic for all session created or one
> topic
> > per session ?
> > I think that one topic per session is more safe because if I use one
> topic
> > for all sessions, if one message is not read quickly by one consumer ( a
> > session ), could block the topic,
> > Obviously , i'll define a TTL for messages/topic
> >
> > Thanks and regards
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Share info across different sessions & servers

Posted by "mailinglist@j-b-s.de" <ma...@j-b-s.de>.
Hi!

What kind of data do you want to share? Just a view "bytes"? Is there an requirement concerning durability/persistence/performance?
Is this user=session related or do you want to share data in general? Usually if you have a session id the lb will route your user always to the same container? What about session replication, a database, terracotta?

JMS: i doubt this will be working... you need a persistent message or a container started after the change was send will not noticed about it...

Jens



Sent from my iPhone

On 02.07.2013, at 08:45, Jose María Zaragoza <de...@gmail.com> wrote:

> Hello:
> 
> I need to share data between sessions running in different Tomcat server.
> 
> I 'd been thinking about using a JMS broker (as ActiveMQ ):
> 
> - when a new session is created in Tomcat A, it's created a new unique
> topic for this session
> - the session registers itself as listener of that topic ( the only one
> listener )
> - publish the name of this topic by some way , so it can be found by
> another session in Tomcat B
> 
> I don't know if somebody has used something like this sometime, and how
> he/she did it
> Any suggestion/opinion  ?
> 
> I'm not sure either use only one topic for all session created or one topic
> per session ?
> I think that one topic per session is more safe because if I use one topic
> for all sessions, if one message is not read quickly by one consumer ( a
> session ), could block the topic,
> Obviously , i'll define a TTL for messages/topic
> 
> Thanks and regards

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