Send Single Message to Client
What is the best way to send a single message from the server to a client using flex/blazeds? The one caveat is that the message could take several minutes before it is sent. Think of a long calculation that is done on the server that the client waits for. I've thought of the following options:
1) Just use a RemoteObject and call a method. Would there be any problems with the response taking several minutes to come back? I would also ideally like to have a single thread which sends all the responses to the clients in a batch, rather than the standard route of each client's remote method call spawning a thread which returns the result; anyone know where to get started here?
2) Create a new destination and consume that destination on each client. The destination and consumer could be closed on each client after the first message is received.
Which is the best option?
Thanks,
Gordon
Hi Gordon,
I would suggest trying to use a messaging destination for this. Seems like
an RPC that takes minutes isn't so great given all the things that could
happen (network wise and even client application wise) in that time. And
having the client poll for the result (using a polling HTTP channel) seems
reasonable.
Just an opinion. I would try both if you have the time (the RemoteObject
should be pretty quick to prototype).
Tom Jordahl
Similar Messages
-
How can Webservice manage client sections and send back messages to clients
Hi all.
I am starting working with Webservice (jax-ws). Now i can make a good server side and on client side i can use method interface on webservice server side.
But i want to make a advance feature as Server side manage client section and can send back message to client when Server change status...
I know RMI and Corba can seems to support to send back messages to sections of cliens right ?
So Webservice can do it ? Please help me !
Thanks
Diego
Edited by: ThuCT on Sep 14, 2010 1:57 AMHi all.
I am starting working with Webservice (jax-ws). Now i can make a good server side and on client side i can use method interface on webservice server side.
But i want to make a advance feature as Server side manage client section and can send back message to client when Server change status...
I know RMI and Corba can seems to support to send back messages to sections of cliens right ?
So Webservice can do it ? Please help me !
Thanks
Diego
Edited by: ThuCT on Sep 14, 2010 1:57 AM -
How to send a message from server to a particular client
Hi all,
I need to send a message from one host to another host which are connected in local domain. Now I'm able to send a message from client to server and vice versa but what I need is the server should route that message which I send through one client to another host(client) .
How can I do that ?
Please give me some ideas how to do that .
Thanks in advance
Edited by: m.parthiban on Mar 5, 2008 1:20 PMejp, thanks for your reply . can you please explain me bit more by providing code snippet ?
This is what I have done till now :
MyServer:
package connection;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class MyServer {
* @param args
public static void main(String[] args) {
String ss ="",temp ="";
Socket clientLink=null;
try {
ServerSocket sockServer = new ServerSocket(6000);
while(true) {
clientLink = sockServer.accept();
System.out.println("Connection Established");
InputStreamReader isr = new InputStreamReader(clientLink.getInputStream());
BufferedReader bufReader = new BufferedReader(isr);
// System.out.println("buf "+bufReader.readLine());
try {
while ((temp=bufReader.readLine())!=null) {
ss+=temp;
System.out.println("ss "+ss+"Temp "+temp );
System.out.println("Client > "+ss);
} catch (IOException e) {
System.out.println("while reading");
e.printStackTrace();
OutputStreamWriter osw = new OutputStreamWriter(clientLink.getOutputStream());
PrintWriter pw = new PrintWriter(osw,true);
pw.write("Welcome -by Server !!!");
pw.flush();
clientLink.shutdownOutput();
clientLink.close();
} catch (IOException e) {
System.out.println("Can't able to connect");
e.printStackTrace();
}MyClient:
package connection;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import javax.swing.JOptionPane;
public class MyClient {
* @param args
public static void main(String[] args) {
try {
String serverMsg="",temp="";
Socket client = new Socket("127.0.0.1",6000);
PrintWriter pw = new PrintWriter(client.getOutputStream(),true);
pw.write("Hi ,Accecpt me");
pw.flush();
// pw.close();
client.shutdownOutput();
InputStreamReader isr = new InputStreamReader(client.getInputStream());
BufferedReader bufRead = new BufferedReader(isr);
while ((temp=bufRead.readLine())!=null) {
serverMsg +=temp;
System.out.println("Server > "+serverMsg);
JOptionPane.showMessageDialog(null, serverMsg);
client.shutdownInput();
client.close();
} catch (IOException e) {
System.out.println("Failed to connect");
e.printStackTrace();
}Once again thanks for the time you spend to reply me. -
Send message to client before session invalidated
i am using jsp and java servlet tech. for my web application.
my problem is :
i want to send a message to client before session invalidated.
please help me to find the best way to solve my problem.You can detect session termination by putting an object in the session attributes which implements HttpSessionBindingListener. What you can't do is send a message to a client, basically because all http transactions are initiated by the client. The only way I can see you could do this is to put an applet on your web pages which periodically consults the server concerning the session state.
Then the problem is that there's no obvious way of determining if the session is about to timeout, only whether it has or not. Your applet couldn't return the session cookie (as such) because that would reset the session timeout and the session would never expire. If you could obtain the session without reseting the expiry (perhaps from SessionContext though that's depracated) you could look at getLastAccessedTime() and getMaxInactiveInterval, but I don't know that this can be done. You can't even count, on some systems, on the session remaining in memory.
If you really need to do this you may need to consider implementing sessions for yourself. I've done this for non-webapp based logins and it's not too hard. -
Send a message from a list of emails in lightswitch 2013.4 HTML screen using ajax
Hi There,
any idea how to make a button to send a message from a list of emails in lightswitch 2013.4 HTML.
my idea is to send message to all emails in the details picker (or the drop down menu or a choice list) tat is filled by SQL query (as a data source in lightswitch)
i have read many articles, most of them were written in PHP or VB !
for example:
http://www.devarticles.com/c/a/HTML/Sending-email-with-AJAX-building-a-small-application/1/
http://stackoverflow.com/questions/22442074/how-to-send-email-to-a-list-of-addresses-from-lightswitch
http://lightswitchhelpwebsite.com/Forum/tabid/63/aft/75/Default.aspx
http://maxslabyak.com/c-sharp/using-jquery-to-send-email-with-web-services/
http://www.paulspatterson.com/microsoft-lightswitch-sending-emails-from-the-client/
http://www.quercussolutions.com/blog/index.php/microsoft-lightswitch-sending-emails/
http://www.lightswitchspecial.com/2013/01/7-most-easiest-way-to-send-email-from.html
as far as i know, the HTML screens in lightswitch 2013 can be encoded with ajax only, not vb or C# any more!
my project contains only HTML screens, no desktop screens. i know that i can do the VB programming in the tables actions, but i am looking to have this code in the Browse screen to give me more flexibility depending on my decision to
send or not..
help please :)Hello Hasan,
I do this using a generic handler(e.g. sendmail.ashx). In the ashx file i use this code:
Imports System.Net.Mail
Imports System.Web
Imports System.Web.Services
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim str As String = "there was no error "
Dim Recipient As String = Convert.ToString(context.Request.Params("pRecipient"))
Dim strsub As String = Convert.ToString(context.Request.Params("pSubject"))
Dim strmsg As String = Convert.ToString(context.Request.Params("pMessage"))
Dim msg As New MailMessage
Try
' Your mail address and display name.
' This what will appear on the From field.
' If you used another credentials to access
' the SMTP server, the mail message would be
' sent from the mail specified in the From
' field on behalf of the real sender.
msg.From = New MailAddress("[email protected]", "Displayname")
' To addresses
msg.To.Add("[email protected]")
'msg.To.Add(New MailAddress("[email protected]", "Friend B"))
' You can specify CC and BCC addresses also
' Set to high priority
msg.Priority = MailPriority.High
msg.Subject = strsub
' You can specify a plain text or HTML contents
msg.IsBodyHtml = True
msg.Body = strmsg
'msg.Body = _
' "Hello everybody,<br /><br />" & _
' "I found an interesting site called <a href=""http:'JustLikeAMagic.WordPress.com"">" & _
' "Just Like a Magic</a>. Be sure to visit it soon."
' In order for the mail client to interpret message
' body correctly, we mark the body as HTML
' because we set the body to HTML contents.
' Attaching some data
' msg.Attachments.Add(New Attachment("D:\Site.lnk"))
' Connecting to the server and configuring it
Dim client As New SmtpClient()
client.Host = "mail.gmx.com"
client.Port = 25
client.EnableSsl = True
' The server requires user's credentials
' not the default credentials
client.UseDefaultCredentials = False
' Provide your credentials
client.Credentials = New System.Net.NetworkCredential("yourcredentias", "f2f081639ad")
client.DeliveryMethod = SmtpDeliveryMethod.Network
' Use SendAsync to send the message asynchronously
client.Send(msg)
Catch ex As Exception
str = ex.Message
Finally
msg.Dispose()
End Try
context.Response.ContentType = "text/plain"
context.Response.Write(str)
End Sub
When you create the ASHX then replace the ProcessRequest with the above function.
In LS HTML Screen create the function for pressing a button an appen the following text:
$.ajax({
type: 'post',
data: {
pRecipient: Screen.yourdata,
pSubject: Screen.yourdata,
pMessage: Screen.yourdata,
url: '../sendmail.ashx',
success: function success(result) {
alert(result);
This is a way you can do that. In VB and out of your browse Screen.
Hope this helps
Thomas -
Can anyone post sample code to send heartbeat messages from client to server. Need urgenltly.
thanks in advanceMost of the code is here. There are parts before and after the snipits - but this should be enough to get the point. I have not included the class that is getting serialized. However, it could be whatever you want it to be (doesn't matter what the contents of the class/object is).
source system:
try {
| NON-SSL connection |
if (!sslConnection) {
mySocket = new Socket(serverName, communicationPort);
oout = new ObjectOutputStream(mySocket.getOutputStream());
oin = new ObjectInputStream(mySocket.getInputStream());
| SSL connection |
else {
sslFact = (SSLSocketFactory) SSLSocketFactory.getDefault();
mySSLSocket = (SSLSocket) sslFact.createSocket(serverName, communicationPort);
oout = new ObjectOutputStream(mySSLSocket.getOutputStream());
oin = new ObjectInputStream(mySSLSocket.getInputStream());
heartBeatMessage = new DmiHeartBeatMessage(destinationName, serverName);
myMessage = new CommunicationMessage(heartBeatMessage);
oout.writeObject(myMessage);
oout.flush();
while (true) {
incomingMessage = (CommunicationMessage)oin.readObject();
if (incomingMessage.getMessageText().equals("Request Complete"))
connectionClosed = true;
catch (Exception e) {
if (connectionClosed)
executerLogger.writeToLog("Remote agent available.", true, true);
else
executerLogger.writeToLog("Remote agent not available.", true, true);
target:
| Non-SSL connection |
if (communicationSocket != null) {
agentInfo.getAgentLogger().writeToLog("Received a NON-SSL connection request...", true, true);
socketInput = communicationSocket.getInputStream();
socketOutput = communicationSocket.getOutputStream();
| SSL connection |
else {
agentInfo.getAgentLogger().writeToLog("Received a SSL connection request...", true, true);
socketInput = sslCommunicationSocket.getInputStream();
socketOutput = sslCommunicationSocket.getOutputStream();
oout = new ObjectOutputStream(socketOutput);
oin = new ObjectInputStream(socketInput);
| Continue to read messages until the client disconnects. |
incomingMessage = (CommunicationMessage)oin.readObject();
| Someone has requested to tail the agent log file. |
if (incomingMessage.getObject() instanceof DmiHeartBeatMessage)
agentInfo.getAgentLogger().writeToLog("Heartbeat received from Deployment Executer: " +
((DmiHeartBeatMessage)incomingMessage.getObject()).getDestinationName() + ", " +
((DmiHeartBeatMessage)incomingMessage.getObject()).getServerName() + ".", true, true);
sendMessageToClient("Request Complete", false);
... -
Send a Single Message to a Client
What is the best way to send a single message from the server to a client using flex/blazeds? The one caveat is that the message could take several minutes before it is sent. Think of a long calculation that is done on the server that the client waits for. I've thought of the following options:
1) Just use a RemoteObject and call a method. Would there be any problems with the response taking several minutes to come back? I would also ideally like to have a single thread which sends all the responses to the clients in a batch, rather than the standard route of each client's remote method call spawning a thread which returns the result; anyone know where to get started here?
2) Create a new destination and consume that destination on each client. The destination and consumer could be closed on each client after the first message is received.
Which is the best option?
Thanks,
GordonIt looks like you need a mechanism where the client registers with the server, then server does some long calculation, and then when the result is available, server sends the result back to the client. Messaging (option #2) sounds like a good fit for this.
Some thing to note:
- You can use subtopics so each client is subscribed to the same destination but has its own subtopic to receive updates from.
- You need to use a realtime channel (polling, long-polling, or streaming) so that the consumer can receive updates. I suggest long-polling with a really long wait time. -
Sending large messages via ABAP client proxy
Dear All,
my scenario is the following. I have an ABAP report which creates files. These files are currently moved by an FTP auto job, to a target folder and are finally imported into an 3rd party programm.
The CSV-files created consist of approx. 3000 records, each with a length of 1000. So the total size is about 3 MB. The files are send at night, once a day.
We want to distribute these files via SAP PI. My question is the following:
Is a client proxy able to send the whole (3MB) message to PI (which will just write the message to the target FTP destination) or do I have to send each record with the client proxy to PI (and append the record to the file).
If both solutions are feasible,what would be preferable? The solution of sending single records to PI, would be more generic in my opinion, because I could define a message type for the records in PI. So in future i could add also some mapping stuff. If I would want to send the whole file content with one client proxy call, i would basically have one big string.
How do both options compare in regard to performance? Sending 3000 small messages oder one big message?
What about the file adapter? Is it an option to append 3000 records to a file?
Does anyone have another solution for that scenario?
Best regards and thank you for your help!
FlorianHi,
Is a client proxy able to send the whole (3MB) message to PI
yes it is capable.
If both solutions are feasible,what would be preferable?
yes both solutions are feasible ,but preferable is to send the whole message rather than one by one.
How do both options compare in regard to performance?
sending whole message is far more better than sending record by record.
regards,
pradeep A. -
Send a message to IBM webspeare MQ from ASE PC Client 12.5.4
Hi Team,
we need to send a message(IBM WebSpeare MQ) through either Stored Procedure or Triggers from our sybase DB(ASE PC Client 12.5.4 is installed in my machine and the same available in the server). Is it possible to send a message from ASE? if so can you please tell me the way of coding?
Thanks
NareshHave you looked at the Active Messaging Users Guide?
-bret -
Send state message to SCCM after uninstall of SCCM client
Hi Everyone,
I have a batch file to uninstall the client from PC's, how would I could I send a state message back to SCCM to say the uninstall was successful? Asking because the console doesn't come back with success info, just waiting, and accepted on the program.....as
the client is uninstalled etc.
Currently running a simple ccmsetup.exe /uninstall as below, thanks for any help in advance.
I know there's a Vb script to force any existing messages to be sent, but as the CCM WMI will not exist, there would be nothing to send, right?
And I have to do this for a POF......Is this even possible??I could write to a log file with the name of the computer that just uninstalled, but really wanted to use a report.....or if there's another way to uninstall client and get the info in SCCM then
please let me know, it's been a very long few days..... cheers :)
@echo off
echo Please Wait while the system is uninstalling Microsoft's SMS/SCCM Client.
REM 'echo Checking for SCCM 2007 client...
REM 'IF EXIST %windir%\System32\ccmsetup\ccmsetup.exe GOTO DEL07
REM 'echo No SCCM 2007 client found.
echo Checking for SCCM 2012 client...
IF EXIST %windir%\ccmsetup\ccmsetup.exe GOTO DEL12
echo No SCCM 2012 client found.
echo Checking for SMSCFG file...
IF EXIST %windir%\SMSCFG.INI GOTO DELINI
echo No SMSCFG file found.
echo All software already removed or no client installed.
GOTO END
REM :DEL07
REM echo Found SCCM Client v2007. Removing...
REM %windir%\System32\ccmsetup\ccmsetup.exe /uninstall
REM RD /S /Q %windir%\System32\ccmsetup
REM RD /S /Q %windir%\System32\ccm
REM RD /S /Q %windir%\System32\ccmcache
REM echo SCCM Client 2007 removed.
REM IF EXIST %windir%\ccmsetup\ccmsetup.exe GOTO DEL12
REM IF EXIST %windir%\SMSCFG.INI GOTO DELINI
REM GOTO END
:DEL12
echo Found SCCM client v2012. Removing.
%windir%\ccmsetup\ccmsetup.exe /uninstall
REM RD /S /Q %windir%\ccmsetup
REM RD /S /Q %windir%\ccm
RD /S /Q %windir%\ccmcache
echo SCCM Client 2012 removed.
IF EXIST %windir%\SMSCFG.INI GOTO DELINI
GOTO END
:DELINI
echo SMSCFG file found. Removing...
del /F %windir%\SMSCFG.INI
echo SMSCFG file removed.
GOTO END
:END
echo Done!
rem pause
exit
many thanksDon't you think this is a bit of a silly question? The client is what sends state messages therefore what would you expect to "send" the message that the client was removed? Seems about as effective as putting the address on the inside of an
envelope and expecting the post office to just know where to send the mail.
John Marcum | Microsoft MVP - Enterprise Client Management
My blog: System Center Admin | Twitter:
@SCCM_Marcum | Linkedin:
John Marcum -
Sending message across clients
Hello,
wanted to know how to send message across clients. Suppose I have 2 XI servers : one is XI other is PI. I want to send message from PI to XI. how will we configure this scenario? what adapters will be used and what is the message flow ?
Thank you.Hi,
Check my thread it may be helpful
XI adapter
Regards,
Prakash -
How to send Subtopic Message From Server-Side to Client ?
I’m new at flex and i have a new question about Flex
Message Service.
How to send messages from Server-Side Java Code with
Subtopic?
For example.
I customed a Flex Message Adapter in Tomcat Server , with
this Adapter , i can send message to Client with following code .
---------------------Send message to Client------------
MessageBroker msgBroker =
MessageBroker.getMessageBroker(null);
String clientID = UUIDUtils.createUUID(false);
AsyncMessage msg = new AsyncMessage();
msg.setDestination("CustomMsgServiceDes");
msg.setClientId(clientID);
msg.setMessageId(UUIDUtils.createUUID(false));
msg.setTimestamp(System.currentTimeMillis());
msg.setBody(clientID + "this is my message from server! \n");
msgBroker.routeMessageToService(msg, null);
---------------------Send message to Client------------
But i want send a message that have Subtopic to the Client ,
How to do ?
Thank you for reply.There's a white paper that talks about this subject -
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=8f1eb6ea -
How to send "close" message to server when client directly close computer?
hi~~
I now have a 9 ppl multiplay game with Socket connection. The clients can sucessfully send a message to server whey they close the game down through pressing X button,but they cant send message when they directly close computer.
I want to know how to make so available?
thankWhenever we put our computer off directly(like power
failure), there is no way to inform other computer
about this mishap. Now it's responsibility of server
to judge this scenario. In case of sockets, whenever
we try to write or read from socket whose connection
is broken, exception is thrown. No. TCP does not work like that.
If you read from a socket and the other computer aborted the connection, then either the read will timeout (if a read timeout is set) or block forever. -
Sending messages between clients
hi,
I want to make small instant messenger,like yahoo.I have made a server which accept connection from different client & send online user list to each and every client connected to the server.
But now i have to send messages between the clients(chatting).
This can be do either through server or allow server establishing connection betwwen two client & allow them to continue chatting session.But i am not able to figure out how i do either of the things using socket programming.
Please help me ,to establish chatting session between the clients.
Thank you for replies
alokYes, It should be Non public to Other client but not to server.
Suppose client1 want to send message to client2 then it send message to server,then server passes this message to client2.
Now as client2 got the it send some reply to client1 which
is also reach to client1 through server.But I have problem ,as how
does client2 knows to which client he has send message as no of clients are connected to the server & more then one client has send message to client2.
Basically I have problem in sending reply to a message send by the different client connected to the server.
Thank You for reply -
Sending XML messages from server to client using POST method
Dear everyone,
I have a simple client server system - using Socket
class on the server side and URLConnection class on
the client side. The client sends requests to the
server in the form of an XML message using POST method.
The server processes the request and responds with
another XML message through the same connection.
That's the basic idea.
I have a few questions about headers and formats
especially with respect to POST.
1. In what format should the response messages from the
server be, for the client? Does the server need to
send the HTTP headers - for the POST type requests?
Is this correct?:
out.println("HTTP/1.1 200 My Server\r");
out.println("Content-type: text/xml\r");
out.println("Content-length: 1024\r");
out.println("\r");
out.println("My XML response goes here...");2. How do I read these headers and the actual message
in the client side? I figured my actual message was
immediately after the blank line. So I wrote
something like this:
String inMsg;
// loop until the blank line is through.
while (!"".equals(inMsg = reader.readLine()))
System.out.println(inMsg);
// get the actual message and process it.
inMsg = reader.readLine();
processMessage(inMsg);But the above did not work for me. Because I seem to
be receiving a blank line after each header! (I suppose
that was because of the "\r".) So what should I do?
3. What are the different headers I must pass from
server to the client to safeguard against every
possible problem?
4. What are the different exceptions I must be prepared
for this situation? How could I cope with them? For
example, time outs, IOExceptions, etc.
Thanks a lot! I appreciate all your help!
Georgehello,
1) if you want to develop a distributed application with XML messages, you can look in SOAP.
it's a solution to communicate objects distributed java (or COM or other) and it constructs XML flux to communicate between them.
2) if it can help you, I have developed a chat in TCP/IP and, to my mind, when you send datas it's only text, so the format isn't important, the important is your traitement behind.
examples :
a client method to send a message to the server :
public void send(String message)
fluxOut.println(message);
fluxOut.flush();
whith
connexionCourante = new Socket(lAdresServeur, noPort);
fluxOut= new PrintWriter( new OutputStreamWriter(connexionCourante.getOutputStream()) );
a server method in a thread to receive and print the message :
while(true)
if (laThread == null)
break;
texte = fluxIn.readLine();
System.out.println(texte);
that's all ! :)
If you want to use it for your XML communication, it could be a good idea to use a special message, for example "@end", to finish the server
ex :
while(true)
if (laThread == null)
break;
texte = fluxIn.readLine();
// to stop
if (texte.equals("@end"))
{break;}
processMessage(texte );
hope it will help you
David
Maybe you are looking for
-
Multiple Samsung Stratosphere problems after FF1 update
There have been multiple posts on various issues users have found after the recent Stratopshere FF1 update. Some were replys to older posts and some only touched on a single issue. I wanted to consolodate into one thread, and hopefully get teh atte
-
At 96% completion of Reader install Windows gives above error msg. I close that window, then new window says "Installation complete." I click finish. New window opens with "Installation successful - you are now running Adobe Reader." Yet Reader does
-
Is this a sign that hard-drive is failing?
Hi all, My SnowLeopard started to NOT show icons under icon view in the documents, desktop, applications windows; only the name will be shown in white color font against a black backdrop. (This has happened before but it returned to the normal state
-
Hiding Payment / Receipt Tab in Cash Journal
HI Experts Please tell me how i can Hide Payment / Receipt Tab in Cash Journal Full point will awards... MAZ
-
Billing pricing not getting picked up
I created a sales invoice with reference a sales order. In the sales order the price was getting picked up and was displayed. Delivery was also created. But when the invoice was created and saved the net value is shown as 0. Price is not getting pick