Server push with Javamail: idle() blocks

Hi,
today I tried to implement server push functionality in my mail application via Javamail.
I did this by calling the following method everytime Javamail creates a new Folder instance for me:
private void activateServerPush(Folder f) {
     if (f instanceof IMAPFolder) {
          final IMAPFolder ifo = (IMAPFolder) f;
          ifo.addMessageCountListener(new MessageCountListener() {
               @Override
               public void messagesAdded(MessageCountEvent arg0) {
                    DebugPrinter.print(this, "messagesAdded event called");
                    clear(false, true); // Clear cache
                    onMessageCountChanged();
               @Override
               public void messagesRemoved(MessageCountEvent arg0) {
                    DebugPrinter.print(this, "messagesRemoved event called");
                    clear(false, true); // Clear cache
                    onMessageCountChanged();
          MyThread thread = new MyThread() {
               @Override
               public void run() {
                    while (true) {
                         DebugPrinter.print(this, "Before idle");
                         try {
                              ifo.idle();
                              DebugPrinter.print(this, "After idle");
                         } catch (MessagingException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                         DebugPrinter.print(this, "After idle try");
          // Start thread
          ServletThread.EXECUTOR_SERVICE.submit(thread);
}Now, when I run the code above, I only get "Before idle" as output.
The rest won't be printed so it seems like idle() is blocking.
Also, the event listener messagesAdded(...) are not called. I tried this by sending an email to myself but nothing happens.
What's wrong?

Hi Bill and thanks for your reply.
How does the idle command (line) look line in the debug output?
I simply did a full text search for the word "idle" (ignore case) of everything that got printed to console and only found this:
DEBUG: mail.imap.minidletime: 10
* CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS AUTH=PLAIN AUTH=LOGIN
A2 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in
Also, I noticed that the line "Before idle" (See source code in my initial posting here) gets printed but AFTER that line I can't find anything else that could refer to the idle command.
When I leave Apple Mail (my default native email client on my computer) open, the email that I sent gets correctly (instantly) pushed.

Similar Messages

  • "The server responded with an error. The server is currently unreachable or the connection was blocked"

    Hi, since this morning i receive this message on my Mac Air (10.8.5) when i open iCal (which is synced through iCloud): "The server responded with an error. The server is currently unreachable or the connection was blocked". You know what it can be?
    Thanks for your help!

    Are you behind a firewall at work or elsewhere?  Does you calendar sync with some other system like google (could be the google server is not responding)?  All we know from the message is that your mac cannot reach the server.  Maybe try later.  Are you using wifi or have an ethernet connection to the router?

  • Client/Server API with push?

    I set up a simple Socket client server architecture with the Java socket API. However, my clients sometimes are initiators or requests, and sometimes my server is the initiator of infos. Example: client want to get infos from server but also want to tell the server something. The server tells all registered clients something but also can accept requests from clients. So both sides are client AND server (depending on what they currently want to do).
    The socket API is just a classic client/server API, i.e. a server listens and a client sends requets and get responses. For my server to send requests to all clients, this is not enough. Is the only way to have all clients offering a socket server on their computer, too? so that this 2-way-request-communication works?
    This is basically some kind of "push" technology, but i don't want my clients to "poll" the server just to emulate the feature of sending requests from the server to the client. Is there some other (perhaps non-socket) API that offers this?

    @sjasja: how is the socket api symmetrical?It is, trust me! Connection initiation isn't, but after that it is. (Let's assume connected TCP/IP.)
    The server does bind() and accept(), the client does connect(). After that, the connection is symmetrical: either end can issue any number of read() and write() calls in any order. You write() to a socket, it pops out from read() at the other end (though not necessarily as a single packet; TCP/IP is stream oriented, so write() "packets" can and will be glued together, or fragmented at the whimsy of network routers and friends.)
    - accept() //wait for client to send request
    - socket.getInputStream() //read request
    - socket .getOutputStream() //write responseThose don't read or write; they get streams which you can read from and write to.
    In the server, when accept() returns a new connection, you'd start a reader thread for that client. The thread would read() (or readLine() if you implement a line-oriented protocol) and handle the incoming messages. Whenever you want to write to the client, write to the stream returned by socket.getOutputStream(). You may need to synchronize writes if you have several threads that do sequences of write()s that need to arrive at the client sequentially.
    As to the difficulty of socket programming: I don't think it particularly difficult. But then I've written dozens of socket programs since my first one in '85... The Java Tutorial socket chapter shows a simple client/server pair; not terribly difficult I think. In particular, check out the KKMultiServer at the bottom of the sample server chapter.

  • Server 3 with IP Surveillance/Push Notification

    Has anyone used Server 3 with an IP surveillance camera(s) setup and enabled push notification to their cell phone (iPhone or others) when motion detected and if so, is there any additional software involve and would they share details of the setup?

    Not sure what you're looking for here, but Server.app is probably not relevent here — the push notifications are sent from the triggering source to Apple and then from the Apple servers along to your iOS device.   But whatever is triggering the notifications is almost certainly not going to send the notifications via OS X Server.
    The surveillance cameras and the iPhone probably are aren't all that central either.  It's whether the particular motion-detection software — which could be running on a Mac host or could be embedded in the cameras — you're using actually works reliably, and whether it can send push notifications (via Apple).
    If you're looking, then there are a variety of hits for a Bing or other web search for /surveillance cameras +"push notification"/, which would be a starting point.  Looks like a number of choices are available here, too.
    If you have devices, then the identity of what you're working with would be helpful — this if you're looking to roll your own notifications.   There's information on enrolling and generating Apple Push Notification service (APNs) requests in the Apple Developer documentation — that's probably secondary to whatever software is doing the image capture and movement analysis, and the APNs activity would be triggered from that. 
    OS X Server gets into the push notifications references because some of the software on OS X Server seeks to send notifications.  But it's not usually necessary to use OS X Server as an APNs relay service, which is I'm guessing you're headed with this question, posted here in the OS X Server forums.

  • What's difference push stream with server script and push with flash media live encoder??

    Hi
    I'm multi point push streaming with adobe flash media server 4
    Stream structure like this
    Open Broadcaster Software (or Flash media live encoder) (RTMP) -> Home Flash media server with multi push script (main.asc)
    -> Stream to 2 justintv channels + 1 dailymotion channel (1024x576 , 1750Kbps)
    no problem at all when streaming to justintv
    but some another stream services have speed problem
    ustream can not push with this method
    and dailymotion, vaughnlive push speed slow down than OBS or FMLE Direct stream
    for example
    when direct streaming with OBS or FMLE (Without home server) , no problem at all stream to dailymotion and vaughnlive
    clearly no lag
    but when push with server script, slow down push speed and unstable (it affect only for dailymotion and vaughnlive streams)
    justintv upload speed same as OBS, FMLE's bitrate but dailymotion, vaughnlive bitrate always slower than justintv or OBS, FMLE
    Like this - justintv , OBS, FMLE (1750Kbps~2000Kbps) but dailymotion, vaughnlive (1600Kbps~1800Kbps)
    I don't understand why have push speed difference between server script push and OBS, FMLE push
    Have any reason? and do not have solution???
    (sorry for my bad english)

    First of all let me clarify that we call multi point publish and it has been explained in detail here
    http://help.adobe.com/en_US/flashmediaserver/devguide/WS5b3ccc516d4fbf351e63e3d11a0773d56e -7ffbDev.html
    When you do multi point publish(MPP) you publish from one server to another server, when you use FMLE you do a normal publish of stream(s) from a client/encoder(FMLE in this case) to the Adobe Media server.

  • Using the new Data/Services generation with server push

    Have moved my Flex/BlazeDS app (which uses Blaze AMFChannel for request/response messages and StreamingAMFChannel for server push messaging) from Flex Builder 3 to Flash Builder 4. The new Data/Services works fine to generate service classes and value objects for the request/response messages, question is can it provide any help setting up a messaging consumer and value objects for the pushed data?
    rick holland

    I am so sorry - I meant AirPort Express - not extreme - but it's moot since I missed the point of your post - you want two outputs - and one to not be digital.
    For what it's worth - I still think the express might be your best bet.
    http://www.apple.com/airportexpress/airtunes.html
    It has combined digital/analog out - you plug in one and it switches the output depending on which connection is inserted. I would expect a very short wait until everything accepts digital input - expecially for people who want good sound quality. If you have to go digital to analog outside of the receiver/amp (where it really belongs) - why not let it be the express sitting right next to where you want the second "receiver" to be...

  • When I try entering a new event in iCal on my MacBook Air, I get an error message popping up on my screen that says: The request for account "iCloud" failed.  The server responded with "502" to operation CalDAVSetPropertyQueueableOperation. Help!!??

    When I try entering a new event in iCal on my MacBook Air, I get an error message popping up on my screen that says:
    The server responded with “502”
    The request for account “iCloud” failed. 
    The server responded with “502” to operation CalDAVSetPropertyQueueableOperation.
    The request for account “iCloud” failed.
    I am then given the option of staying Online or going Offline.
    Can anyone help me?
    thanks

    Hello b.krushel,
    Thank you for using Apple Support Communities
    Any number of things could cause this issue, so I would recommend this article named iCloud: Troubleshooting iCloud Calendar found here http://support.apple.com/kb/TS3999.
    These sections in particular:
    General Troubleshooting
    Make sure there are no current issues listed on the System Status that affect iCloud Calendar. The System Status is located on the iCloud Support webpage.
    Make sure you have fully enabled iCloud Calendar for the client you are using (for more setup and troubleshooting information on iOS, OS X, Windows and iCloud.com, see the additional details below).
    Check to see if the issue you are seeing is covered in iCloud Help. To search iCloud Help, visit help.apple.com/icloud.
    Check your settings and preferences as something may not be set up correctly. For example, having incorrect date and time settings can cause issues which are easily resolved by entering the appropriate settings.
    Troubleshooting Calendar on OS X Mountain Lion (iCal on OS X Lion)Note: For instructions on setting up iCloud Calendar with Calendar or iCal on your Mac, see iCloud Setup.If you are having trouble with Calendar or iCal on a Mac and you are using iCloud Calendar, try each of these steps, testing after each to see if the issue is resolved:
    Make sure you are using OS X Lion v10.7.2 or later. Click here for help verifying the version of OS X you are using.
    Make sure your computer is online. Attempt to view www.apple.com and iCloud.com. If you can't connect to the Internet, your iCloud calendars and events will not update in iCal. Click here for more information about troubleshooting your Internet connection.
    Verify that your iCloud member name is entered into the iCloud Preference pane in System Preferences. See iCloud Setup for more information about setting up iCloud on a Mac.
    Make sure you enter and update calendar information in the iCloud section of Calendar or iCal. Only calendars and events in the iCloud section of the Calendar or iCal Calendar list will be pushed to iCloud. Both Calendar and iCal for the Mac support the display of and interaction with multiple accounts and datastores, for example, iCloud, On My Mac, Exchange, Google, and so on. This makes it easy to create or modify events or calendars in a section of  Calendar or iCal that may not be updating iCloud. Learn more about moving local calendars to iCloud.
    In some cases, you may find that you have data duplicated in both the local On My Mac and the iCloud sections of Calendar or iCal. Learn more about resolving this issue.
    You can make the iCloud calendar your default calendar for all new events. In Calendar on OS X Mountain Lion, choose Calendar > Preferences > General, or in OS X Lion, choose iCal > Preferences > Generaland under the Default Calendar heading, select one of the Calendars under the iCloud heading. Close the Preferences window to save this change.
    If recent changes simply don't appear, try forcing Calendar or iCal to refresh by selecting Refresh All from theCalendar menu.
    Make sure your account was successfully created in Calendar on your Mac (or iCal). After upgrading to iCloud Calendar, you may need to quit and reopen Calendar (or iCal). To confirm your account is configured correctly in iCal:
    Open Calendar (or iCal).
    Open Calendar (or iCal) Preferences.
    Click Accounts. You should see an account with your iCloud member name entered.
    Turn iCloud Calendars off and back on
    Quit Calendar (or iCal).
    Choose Apple () menu > System Preferences > iCloud.
    Remove the checkmark in the checkbox next to Calendars.
    Close System Preferences and wait about a minute.
    Open System Preferences and choose iCloud.
    Replace the checkmark next to Calendars.
    Close System Preferences.
    Open Calendar (or iCal) and test to see if the issue has been resolved.
    Restart your computer. This may sound simple, but it does reinitialize your network and application settings and can frequently resolve issues.
    Take care,
    Sterling

  • After enabling iCloud, the calendar on my MacBook shows a window stating "moving calendar to server account. Then a box appears saying "server responded with an error message 403. Then another box shows "couldn't move calendar to iCloud, an error occurrre

    After enabling iCloud, the calendar on my MacBook shows a window stating "moving calendar to server account. Then a box appears saying "server responded with an error message 403. Then another box shows "couldn't move calendar to iCloud, an error occurrre

    iCloud's Calendar is full of errors and problems for me.  The "Couldn't move your calendars to iCloud because an error occurred" is now gone (by itself) but nothing syncs between my Mac's Calendar to iCloud or my iPhone to iCloud.
    I tried creating a new event directly on iCloud.com to see whether it pushes to any of my device and  got this "This event couldn't be created because of a server error; please try again." error.
    Apple, please fix this!!

  • I can not open Calender. The server responded with an error. Access to account "virgin net" is not permitted. The server responded: "403" to operation CalDAVAAccountRefreshQueueableOperation.

    I can not access Calender.
    Keep getting blocked by message.
    The server responded with error.
    Access to account "virgin net" is not permitted.
    The server responded:
    "403"
    to operation.
    CalDAVAaccountRefreshQueueableOperation.

    Please take each of the following steps that you haven't already tried. Stop when the problem is resolved. Back up all data before making any changes.
    Step 1
    In the Internet Accounts preference pane, delete any calendar accounts you don't use.
    If there's no improvement, delete all calendar accounts and add them back. With an iCloud account, all you have to do is uncheck and recheck the box marked Calendars & Reminders in the iCloud preference pane.
    Step 2   
    You may be trying to access an invited event that you declined, or one that was rescheduled after you accepted it. The error message should give you a clue as to what it is. If the calendar is on iCloud, you can bring up the Calendar on the website and select
              Show Declined Events
    from the popup menu with the gear icon in the upper right corner of the page. The declined events will appear in gray, and one of them should match what's shown the error message. [Credit for this solution to ASC member Psi.]
    Step 3
    If you get the error when trying to accept an invitation in an email attachment, it's because the organizer didn't properly create the event.
    Step 4
    Follow the instructions in this support article. Modify as necessary for a calendar that's not on iCloud.

  • Server Error with JMS

    I have installed..WSAD5.1.2 with 5.0 Test Environment and IBM WebSphere MQ 5.3.
    I have created a PointToPoint Messaging Client. with a QueueConnectionFactory n Queue JNDI name.
    I am getting following problems during the server startup...
    *** Starting the server ***
    ************ Start Display Current Environment ************
    WebSphere Platform 5.0 [BASE 5.0.2 ptf2M0325.01] running with process name localhost\localhost\server1 and process id 2088
    Host Operating System is Windows 2000, version 5.0
    Java version = J2RE 1.3.1 IBM Windows 32 build cn131-20030711a (JIT enabled: jitc), Java Compiler = jitc, Java VM name = Classic VM
    was.install.root = C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5
    user.install.root = C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5
    Java Home = C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\java\jre
    ws.ext.dirs = C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/java/lib;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/classes;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/classes;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/lib;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/lib/ext;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/web/help;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime;C:/IBM/WebSphere Studio/Application Developer/v5.1.2/wstools/eclipse/plugins/com.ibm.etools.webservice_5.1.2/runtime/worf.jar
    Classpath = C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/properties;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/properties;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/lib/bootstrap.jar;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/lib/j2ee.jar;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/lib/lmproxy.jar;C:/IBM/WebSphere Studio/Application Developer/v5.1.2/wstools/eclipse/plugins/com.ibm.etools.websphere.tools.common_5.1.1.1/runtime/wteServers.jar;C:/IBM/WebSphere Studio/Application Developer/v5.1.2/wstools/eclipse/plugins/com.ibm.etools.websphere.tools.common_5.1.1.1/runtime/wasToolsCommon.jar
    Java Library path = C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/bin;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/java/bin;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5/java/jre/bin;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\eclipse\jre\bin;.;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\eclipse\jre\bin;C:\IBM\WebSphere MQ\Java\lib;C:\dev\MKS\IntegrityClient\bin;c:\dev\Perl\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\dev\cygwin\bin;C:\dev\4NT302;C:\dev\apache-ant-1.5.4\bin;C:\dev\jdk1.3.1_08\bin;C:\dev\jakarta-tomcat-4.1.30\bin;C:\dev\mksscripts\src;C:\tbs\bin;C:\Program Files\IBM\WebSphere MQ\WEMPS\bin;c:\dev\MQ\bin;C:\IBM\WebSphere MQ\Java\bin;C:\IBM\WebSphere MQ\WEMPS\bin;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\bin;C:\IBM\WebSphere MQ\bin;;C:\IBM\WebSphere MQ\bin;C:\IBM\WebSphere MQ\Java\bin;C:\IBM\WebSphere MQ\WEMPS\bin;C:\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v5\bin;.;C:\dev\NMake;C:\dev\ZipUnzip;
    ************* End Display Current Environment *************
    [6/7/04 11:59:06:000 IST] 4eee356d ManagerAdmin I TRAS0017I: The startup trace state is *=all=disabled.
    [6/7/04 11:59:06:516 IST] 4eee356d AdminInitiali A ADMN0015I: AdminService initialized
    [6/7/04 11:59:07:500 IST] 4eee356d Configuration A SECJ0215I: Successfully set JAAS login provider configuration class to com.ibm.ws.security.auth.login.Configuration.
    [6/7/04 11:59:07:547 IST] 4eee356d SecurityDM I SECJ0231I: The Security component's FFDC Diagnostic Module com.ibm.ws.security.core.SecurityDM registered successfully: true.
    [6/7/04 11:59:07:641 IST] 4eee356d SecurityCompo I SECJ0309I: Java 2 Security is disabled.
    [6/7/04 11:59:07:656 IST] 4eee356d SecurityCompo I SECJ0212I: WCCM JAAS configuration information successfully pushed to login provider class.
    [6/7/04 11:59:07:656 IST] 4eee356d SecurityCompo I SECJ0240I: Security service initialization completed successfully
    [6/7/04 11:59:09:797 IST] 4eee356d JMSEmbeddedPr A MSGS0050I: Starting the Queue Manager
    [6/7/04 11:59:11:125 IST] 4eee356d JMSEmbeddedPr A MSGS0051I: Queue Manager open for business
    [6/7/04 11:59:11:125 IST] 4eee356d JMSEmbeddedPr A MSGS0052I: Starting the Broker
    [6/7/04 11:59:11:297 IST] 4eee356d SystemErr R MQJE001: Completion Code 2, Reason 2085
    [6/7/04 11:59:11:297 IST] 4eee356d BrokerManager E MSGS0255E: Broker Manager unable to attach to Queue Manager - unknown Queue
    [6/7/04 11:59:11:328 IST] 4eee356d JMSService E MSGS0001E: Starting the JMS Server failed with exception: com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2085
    at com.ibm.mq.MQQueueManager.accessQueue(MQQueueManager.java:1527)
    at com.ibm.mq.MQQueueManager.accessQueue(MQQueueManager.java:1579)
    at com.ibm.ws.messaging.BrokerManager.attachToMQ(BrokerManager.java:439)
    at com.ibm.ws.messaging.BrokerManager.startBroker(BrokerManager.java:234)
    at com.ibm.ws.messaging.JMSEmbeddedProviderImpl.start(JMSEmbeddedProviderImpl.java:194)
    at com.ibm.ws.messaging.JMSService.start(JMSService.java:288)
    at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:543)
    at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:418)
    at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
    at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
    at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
    at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)
    Please let me know what is the problem and how to solve it. This is urgent. Tnx

    Did you go into Websphere MQ and set up the queue you are using? Defining the queue in JNDI is not enough.
    Broker Manager unable to attach to Queue Manager - unknown Queue

  • How to send a message with javamail api

    Hi, anybody can tell me how i do to send a message with javamail?
    Thanks.
    Daniele.

    [rossifumi80],
    Here's a simple JavaMail application SendMessage.java that will connect a SMTP host and send a mail message out:
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class SendMessage {
      public static void main (String args[]) throws Exception {
        String host = args[0];
        String from = args[1];
        String to = args[2];
        // Get system properties
        Properties props = System.getProperties();
        // Setup mail server
        props.put("mail.smtp.host", host);
        // Get session
        Session session = Session.getDefaultInstance(props, null);
        // Define message
        MimeMessage message = new MimeMessage(session);
        // Set the from address
        message.setFrom(new InternetAddress(from));
        // Set the to address
        message.addRecipient(Message.RecipientType.TO,
          new InternetAddress(to));
        // Set the subject
        message.setSubject("Hello JavaMail");
        // Set the content
        message.setText("Welcome to JavaMail");
        // Send message
        Transport.send(message);
    }HTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Sending chinese HTML with javamail - is there no definitive answer ?

    I'm using the following code to send a HTML and text e-mail
    (text for people with HTML-challenged email clients). I sent
    2 emails to 2 email addresses which reside on the same server
    - eg. [email protected] and [email protected] - and read the
    emails with the same e-mail client (Eudora) on the same PC.
    The HTML and Chinese displays perfectly when it's sent to one
    of the email addresses ([email protected]) but the HTML and
    Chinese are always corrupt when I send them to the other.
    This is a repeatable error and it has me completely stumped.
         // Example Initial values (drawn from a database) :
         String smtpHost = "mail.mydomain.com";
         String sender = "[email protected]";
         String subject = "Give me strength.... ";
         InternetAddress sender = new InternetAddress("[email protected]");
         InternetAddress receiver = new InternetAddress("[email protected]");
         String txtMsg = "a long text message blah...";
         String htmlMsg = "<h1>Wooo</h1><img src='http://mydomain.com/blink.gif'>";
         String language = "zh-tw" // can also be "en-us" or "zh-cn"
         // CREATE MAIL MESSAGE & HEADERS
         Properties props = System.getProperties();
         props.put("mail.smtp.host", smtpHost);
         Session session = Session.getDefaultInstance(props, null);
         Message msg = new MimeMessage(session);
         msg.setFrom(sender);
         msg.addRecipient(Message.RecipientType.TO, receiver);
         msg.setSubject(subject);
         msg.setSentDate(new Date());
         msg.setHeader("Mime-Version" , "1.0" );
         msg.setHeader("Content-Transfer-Encoding", "quoted-printable");
         // MESSAGE BODY - TEXT & HTML
         MimeMultipart mimeAllContent = new MimeMultipart("alternative");
         MimeBodyPart mimeText = new MimeBodyPart();
         MimeBodyPart mimeHtml = new MimeBodyPart();
         mimeText.setText(textMsg);
         mimeText.setHeader("Mime-Version" , "1.0" );
         mimeText.setHeader("Content-Type" , "text/plain");
         mimeText.addHeader("Content-Type", "charset=UTF-8");
         if (!language.equals("")) {
              mimeText.setHeader("Content-Language", language);
         mimeText.setHeader("Content-Transfer-Encoding", "quoted-printable");
         mimeHtml.setContent(htmlMsg, "text/html");
         mimeHtml.setHeader("Mime-Version" , "1.0" );
         mimeHtml.setHeader("Content-Type" , "text/html");
         mimeHtml.addHeader("Content-Type", "charset=UTF-8");
         if (!language.equals("")) {
              mimeHtml.setHeader("Content-Language", language);
         mimeHtml.setHeader("Content-Transfer-Encoding", "quoted-printable");
         mimeAllContent.addBodyPart(mimeText);
         mimeAllContent.addBodyPart(mimeHtml);
         msg.setContent(mimeAllContent);
         msg.setHeader("Content-Type" , mimeAllContent.getContentType());
         // SEND THE MESSAGE
         msg.saveChanges();
         Transport.send(msg);
         return true;
    Let me repeat - Using the code below, a HTML & Text ("Alternative"
    MimeMultiPart) message is sent, and arrives at the recipient's
    mailbox. When it is sent to one user ([email protected]), it never
    renders properly. When it is sent to another ([email protected]), it's
    OK. The destination server, email client, PC are the same in both
    cases and the only variable is the recipient's email address.
    How can this be ?
    I think I've gone overboard by setting the Content-Transfer-Encoding
    for both the HTML and Text MimeParts as well as the actual Message.
    Could somebody please confirm which parts I should set the Content-
    -Language, Content-Transfer-Encoding and Content-Type b/c I'm
    going in circles at the moment.
    Thanks indeed, to anybody who has experience sending doublebyte
    with Javamail and can help me clear this up once and for all.
    I find it incredible that after 3 years, there is still no
    definitive answer to accomplishing this, and it remains an
    elusive black art.
    Regards,
    chas
    ps. The data being sent is in MySQL not that that matters at all.

    Try adding code to validate submitted email addresses before they go into your database.
    String emailAddress = (from where ever)
    if(emailAddress != null) emailAddress = emailAddress.trim();
    if(emailAddress == null) // skip this address
    // I also check for a list of illegal internet email address characters, as I think the email addresses allowed by Javamail are too lenient.

  • Server-Push

    I read somewhere that Flex Data Services provides Server-Push
    functionality. That is, the server starts a conversation with the
    client. It's obvious that, In order to such thing ocurr, there has
    to be a persistent connection between server and client.
    I've being reading about Data Management Service to learn how
    to implement this Server-Push and all I see is about a method
    called Fill() that is thriggered from the client and syncronizes
    it's data with the server. But it's not server-push
    Does it really exist?

    Hi,
    When you create a DataService and fill your collection. The
    collection becomes managed. You don't have to call fill again if
    there is any change in the data. Server pushs updates to clients
    when the client's dataservice is using rtmp channel. It is a live
    connection between the server and the client. For example,
    you fill(collection, "hqsql", from products where price <
    100). If one of the product's price increases, server push a
    message to your collection to remove it. If a product's product's
    price decrease, it will be added to the collection. The push is
    happened based on your fill method.
    William Chan

  • Migrating CMP EJB mapped to SQL Server table with identity column from WL

    Hi,
        I want to migrate an application from Weblogic to SAP Netweaver 2004s (7.0). We had successfully migrated this application to an earlier version of Netweaver. I have a number of CMP EJBs which are mapped to SQL Server tables with the PK as identity columns(autogenerated by SQL Server). I am having difficulty mapping the same in persistant.xml. This scenario works perfectly well in Weblogic and worked by using ejb-pk in an earlier version of Netweaver.
       Please let me know how to proceed.
    -Sekhar

    I suspect it is the security as specified in the message. E.g .your DBA set the ID columns so no user can override values in it.
    And I suggest you 1st put the data into a staging table, then push it to the destination, this does not resolve the issue, but ensures better processing.
    Arthur
    MyBlog
    Twitter

  • Implementing Server Push using LCDS 2.6

    Hi All,
    We have created an application where we are using polling to get certain constant updates. Now this polling is client polling wherein the client polls the server at regular intervals to get the fresh data for certain actions.
    Now we wish to take this to another level and implement Server Data Push so that the client does not keep polling unnecessarily and the server notifies the client as and when the data gets updated with the server. For this we have the DataService Transaction class that needs to be implemented.
    But there are a couple of questions that are in my mind regarding this technology. It would be great if someone could answer them.
    My questions are:
    1) Does the LCDS server know which client to push data to in case of multiple clients looking at the same data scenario. e.g. Two clients A and B are looking at the same data. A performs an action and that action needs some time to get completed at the server. Now in case we use Server Data Push, will the LCDS be intelligent enough to send the message on completion of the requested activity to only A and not B.
    2) In order to push data to the client, the server will invoke some method which will return the desired data to te client. How do we keep the parameters registered with the server that this method would need while getting invoked. SInce, the call to the method will not be client initiated, how does the server know what parameters to be passed to the method in order to invoke it. How will this work in a multi-user looking at the same data/screen scenario.
    The answers to these questions will really help us. In case anyone is well versed with this technology, please pitch in to give your inputs.
    Many Thanks.
    Regards,
    Shally

    Hi,
    As also, suggested by you, we were thinking of using an RTMP channel only for this since its a two way socket that establishes a communication channel between the client and the server and then helps keep messages moving to and fro.
    We have successfully implemented RTMP channel and achieved the following functionalities.
    1) A client initiated change which gets propagated to the server and then to all the clients.
    2) Server push to all the clients.
    Now our last step is to implement data push to a particular client. As told by you, we will use the client id but we have some doubts and questions regarding this since we do not have the code examples or anything that could help us in implementing the same.
    I would therefore request you to kindly lead us on the following fronts:
    1) Is the client id the one that is part of the request- response thread, I saw a client id being printed in the logs when a request is made and the response comes.
    2) What code needs to be written on the server side to extract this client id once a call is made so that it can keep this client id with itself to push a message later on.
    3) What methods or API are available to be used to push this message to a particular client? Do we need to call the fill method of a particular client using the client id parameter and inform the client that its requested job has been done.
    For (3) is the Messaging(Publish and Subscribe model) the right way to go??
    It would be great if you could provide us some code snippets just to give us an idea from where we can take it up ourselves.
    Looking forward to hear from you.
    Many Thanks,
    Shally
    Message was edited by: testing34

Maybe you are looking for

  • ICal alarm malfunction

    My alarms work fine if I happen to have the computer on when the alarms go off. But, if an alarm is scheduled to go off at 4pm, for example, for an evening event, and I turn the computer on at 4:30, the alarm does not go off. This has caused me a few

  • BDC or LSMW program for AS91 transaction

    HI gurus, i need a BDC or lsmw program for tran:AS91 ie.create legacy data for two inter company data transfer.can anyone please help me bkz it's very urgent for me... i promise that if i get the ans i reward u.

  • Generating a PDF document within a servlet

    I am looking to create a servlet that generates an XML file using the XML SQL utility and then presents the user with a PDF file (report) of the results. I have a style sheet that works with FOP 0.17 and have used the command line to generate a PDF b

  • Querying a Worksheet from PL/SQL Dynamic Page in Oracle Portal

    Is there a way to actually ask Discoverer to give me a list of values for a report property from outside Discoverer? In my case, I am trying to add reports to Oracle Portal via the Worksheet Portlet but I want to build a select list that contains val

  • JRE and EBS 12.1.2/3

    APPS - 12.1.2 (upgrade to 12.1.3 in QA testing) APPS Tier hardware - Linux x86_64 - SLES 10 SP2 DB - 11.2.0.3 - zLinux - s390 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ My next question is about JRE and the recent updates/vulnerabilities published by Oracl