APE (Ajax Push Engine) Does APE-Server processes the push requests synchronously or asynchronously - comet

I am using APE (Ajax Push Engine) at my application. The connection between the application and the ape-server is inline push. And I am using APE only to broadcast messages to the clients. I.e. the clients do not send messages to the application or to each other.
My question is: Does APE-Server processes the push requests synchronously or asynchronously.
I.e. if I send a message to push over APE-Server,
does APE-Server responses immediately to the application, and after that it pushes the messages to the clients? (asynchronously) OR
does APE-Server responses to the application after it has pushed the messages to the clients (synchronously)
I am asking this, because sometimes responses from APE-Server to the application last to long (sometimes over 1 minute).
Thanks in advance.

The connection type is asychronous as you embed the server logic in webserver and ape communicates using http with the webserver (client <-> APE <-> web server)

Related

When is gunicorn worker ready to process incoming request?

I've a long request to handle at post_worker_init hook to download metadata from remote server, which will block the worker for several seconds. Wondering what's the behavior of the worker if a request comes in during this time. Will the arbiter assign the request to the worker, or the worker won't be assigned as it's still calling the callback at post_worker_init hook?

Implement two phase commit protocol between EJB Application(Running on Glassfish) and Swing application

I have a EJB application running on Glassfish server which stores data on MySQL DB which I call as Global DB.
I have two exact remote Swing applications which are stand alone applications accessing EJB's using RMI. They have their own local DB in case of lost connection.
My aim is to implement two phase commit protocol i.e to make one participant as coordinator and others as participants.
One method which I could think of was to implement using JMS i.e send a message across queue and make remote clients listen to these messages and take appropriate action.
I do this my sending a message on Buttonclick of one of the Swing application.
Problem is, even tough I have implemented MessageListener, onMessage() method does not receive any message for the other client.
Each Remote client has following properties set:
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
This is to connect to Glassfish server and access the connectionFactory and Queue which I have already configured.
Is it because only application running on server are allowed to receive messages and not remote applications?
Any suggestions for topology for 2 PC are welcome.
For this, we used JMS for exchanging the messages between these systems i.e one acting as coordinator who will initiate the process by sending message on the queue and others will respond accordingly by sending back again a message on the queue.
Since you are using EJB,you can use JTA to manage transcation,it a standard implementation of two-phased commit protocal,and JMS support JTA too.
Here are my steps:
config the trans-attribute to Required/Mandatory /Supports, depends on you need.
in your client get UserTransaction by lookup jndi from the EJB server.
start the transaction from client.
commit/rollback the transaction at client side
This is the so called "Client owner tranaction design pattern". I suggest you to read the book javatransactionsbook

Message passing from rabbitmq channel to java NIO channel

I am building a chat component(where all discussions are saved) for an application and I planned to have a long-polling server as an interface between the client machines and the rabbitmq server, that will parse format and enqueue messages in a job queue(on rabbitmq) to be handled by celery, which will then check if posting is allowed via checking the db for some information, etc, save the messages to a db, and enqueue them in rabbitmq again, this time to be consumed by the long-polling server to be pushed out to the client machines.
I planned to have one connection from the rabbit server to the long-polling server, containing many channels, that will each correspond to a nio socket channel, where a client machine is listening in on the other end.
The long polling server will be written using the Java Nio libraries. My question is, what would be an efficient way of sending the messages from the AMQP channel to the socketchannel to be pushed out to the clients?
From my understanding of NIO, the only time a selectionkey should be registered for OP_WRITE, is when a previously attempted write() call returned 0. In this case though, I am interested in writing to a socketchannel when information is present on the corresponding AMQP channel. How can I alert the socket channel once data comes in on its corresponding amqp channel so that I may send data through the socketchannel to the client?
Just call write()! No need to 'tell' the SocketChannel anything. Then if write() returns zero, do the OP_WRITE stuff.

Synchronization and time keeping of multiple applications

How would I implement a system that will keep 20 applications running on a closed network to stay synchronized whilst performing various tasks?
Each application will be identical, on an identical machine. These machines will have a socket connection to the master application that will issue TCP commands to the units such as Play:"Video1.mp4". It is vital that these videos are played at the same time and keep time with each other.
The only difference between each unit is that the window will be offset on the desktop, so that each one has a different view port on the application - as this will be used in a multi-projector set up.
any solutions/ideas would be greatly appreciated.
I did it some years ago. 5 computers running 5 instances of the same flash app. Evey app was displaying a "slice" of the same huge app and everything needed to be synchronized at fractions of seconds precision.
I used a simple Python script (running on a 6th machine) that was sending OSC messages on the local network. the flash apps were listening through FLOSC to this packets, and were sending to the Python script message about their status.
The stuff was running at the Withney Museum (NY) and at Palais de Tokyo (Paris), so I'm quite confident about the solution :) I hope it helps you
You have to keep tracking and latest updated data in your master application. you have to broadcast your newly updated data to all connected client to deliver updated data. after any update from any client you have to send updated data to all connected clients.
In FMS remote shared object is used to maintain data centrally across the network connected application via FMS. when any client is sending any updated OnSync Event is fired to all client application and data is sync with FMS Remote Shared Object. So this kind of Flow you have to develop for proper synchronization of data across network.
you can also use the RPC system to sync data between all connected application to the Master application. in that you have to init RPC to the client to Master application to send data update and Master application send RPC to all other client which are connected to the Master application.

Using gmail as SMTP server in Java web app is slow

I was wondering if anyone might be able to explain to me why it's taking nearly 30 seconds each time my Java web app sends an email using Gmail's SMTP server? See the following timestamps:
13/04/2010-22:24:27:281 DEBUG test.service.impl.SynchronousEmailService - Before sending mail.
13/04/2010-22:24:52:625 DEBUG test.service.impl.SynchronousEmailService - After sending mail.
I'm using spring's JavaMailSender class with the following settings:
email.host=smtp.gmail.com
email.username=myaccount#gmail.com
email.password=mypassword
email.port=465
mail.smtp.auth.required=true
Note that the mail is getting sent and I'm receiving it fine, there's just this delay which is resulting in a slow experience for the application user.
If you know how I can diagnose the problem myself that would be good too :)
It might be that gmail uses this delay to prevent spammers from using their SMTP server from the "outside": if the SMTP is called from the actual webmail client it would not use this delay.
In order to test this, you could open a telnet session to port 25 and do a manual SMTP session
(Search the web for SMTP HELO for examples)
GMail uses SSL for connection. To validate SSL certificate properly certain time is needed. Exact time depends on complexity of the certificate chain and use and accessibility of CRLs and OCSP checking. It's very likely that Java checks OCSPs for the certificate(s) presented, and this can be slow.
Try running your application on different system (preferably in other subnet) to exclude influence of firewalls. Maybe some part of communication (either SMTP itself, or CRL retrieval or OCSP checking) is slowed down by the firewall.
Depending on your OS, you should have a proper mail system that takes care of actually sending mails outside your network.
For instance, Postfix can do the job nicely. The configuration of Postfix would be on another thread, but typically Postfix would accept mails from your LAN (accepting to be a relay for your LAN) and would transfer the mails to gmail.
This is a exemple as to how setup postfix to have gmail as relay.
Having a mail service taking care of the relay of Gmail mails allows your Java application to be freed almost instantly (Postfix absorbs the mail, store it in its queue and forward it to Gmail itself).