Email queue on java

Hello, first of all I'm new to Java. We've a service written with PHP which sends a lot of emails to our users. Right now all new email messages added to MongoDB and by cron script(PHP) we send them out. I'm trying to implement a Mail Queue Daemon with Java, so it could process them asynchronous and without cron script. (We need to remove delays with cron, and if we will call php script faster, we will stuck in a concurrency with fetching, sending, removing emails from Mongo)
The question is does Java community have any kind of class I can use or should I write it from scratch? I would appreciate any advices.
Thanks.

Well, sorry for not replying sooner. I wrote a little script, it works as I wanted to and everything good, except the size. I put it on github please take a look maybe i missed something or it can be tune. I tested it with hundreds of emails to be sent, and postfix log showed that for each email my daemon creates new connection. I didn't find how to use persistent connection with JavaMail, but i actually haven't searched it yet &) But what is more important is ps -aux on our freebsd:
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
68094 root 18 44 0 *1208M* 32388K ucond 0 0:01 0.00% java
1G for simple script? this is when it just waiting and not sending mail. How it can be optimized?
2DrClap I prefer to name it daemon because it runs and lives permanent and not using cron. I dunno about threads, but i believe if we will send ~10k and more emails per hour, would be better to use threads, I don't want situation when client registering on site and waiting for five mins when activation email arrives. And as I mention above and as you can see in script we use Mongo, its fast. Really fast. I generate 100k emails for test in ~1 second. So Mongo isn't bottleneck and will never be.

Similar Messages

  • UCCX email queue stuck in "loading"

    I just created a new email queue and added it to a test agent and when the agent logs in to CAD the tab for the email queue says "Loading" but it never loads. The phone queue for the test user works normally. IMAP is enabled on Exchange and the service has been restarted.
    Using:
    Exchange 2013
    UCCX version: 10.5.1.10000-24
    CUCM version: 10.5.2.10000-5
    I am able to telnet to the Exchange server on port 143 with the username/password configured on CDA.
    Using Windows 7 and Java 7u51. Tried deleting Java and opened the client and had CAD download the Java version it needed.
    Any suggestions would be appreciated.
    Thanks

    The Cisco CAD Troubleshooting Guide for Cisco Unified Contact Center Express, Release 10.5 covers this on page 101.
    Problem Agent E-Mail does not work. The Agent E-Mail applet displays a “Loading...” animation that never completes. If you turn on the Java Console with Tracing, Logging, and Applet life cycle exceptions enabled, you can see the following message during Agent E-Mail start up:
    security: LiveConnect (JavaScript) blocked due to security settings.
    Cause. With Java 7 Update 25, Oracle introduced a feature that blocks LiveConnect when the user’s JRE does not meet the JRE security baseline. The security baseline is published by Oracle and updated as security vulnerabilities are fixed in newer JRE updates. When the Agent E-Mail applet starts, the JRE checks this security baseline. If the required JRE is higher than the JRE version the user is currently running, or if the security baseline cannot be found and the current JRE is expired, Agent E-Mail no longer works.
    Solution JRE 1.7 Update 45 is no longer supported due to Oracle changing the security baseline. You must update to JRE 1.7 Update 51 or later. Future JRE updates might render Agent E-Mail unusable due to the LiveConnect blocking feature and the security baseline. If this is the case, you must perform one of the following workarounds:
    ■ Update each user’s JRE version to meet the security baseline.
    ■ Move the security slider of each user’s Java Control Panel to a
    setting lower than High
    ■ Add Cisco Agent Desktop to the Exception Site List. For more information, refer to the following Oracle documentation:
    http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/ex ception_site_list.html
    ■ Create a Deployment Rule Set (DRS) and distribute it throughout the contact center. For more information on how to create and distribute your own DRS, refer to the following Oracle documentation:
    http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/de ployment_flow.html#rules

  • UCCX email queues

    Hi,
    We have been in the process of configuring email queues for our CCX 8.5 environment with exchange 2010, all configurations look good now and we are posed with the issue of users being stuck in either email not ready state or email logout state.
    The agent email tab in desktop administrator is stuck on loading.
    anyone come across issues similar to this?
    Regards,
    Scott

    Hi Scott,
    Wanted to verify where the issue is, you wote the following
    Scott Brien wrote:The agent email tab in desktop administrator is stuck on loading.
    Do you mean when you login to Cisco Desktop Administrator and try to configure the Global Settings? Or do you mean the actual CAD client is stuck loading the Agent Email Applet and no emails are being sent to the agents?
    Depending on the exact problem you may want to try a couple of things out;
    Be sure that the correct version of Java is installed on the agent PC, the best way to complete this is to uninstall all Java versions from the agent PC, then load CAD and allow CAD to download the version it needs to work correctly, Java 1.6.0 update 17. Then configure Java for CAD per the following guide, page 76
    http://www.cisco.com/en/US/docs/voice_ip_comm/cust_contact/contact_center/crs/express_8_5/installation/guide/cad85ccxig-cm.pdf
    If agents are still not able to receive emails, you may need to add "send as" permissions for the user that is configured in CDA under the Global Settings on Exchange, see page 93
    http://www.cisco.com/en/US/docs/voice_ip_comm/cust_contact/contact_center/crs/express_8_5/troubleshooting/guide/cad85ccxtg-cm.pdf
    Regards
    Joe

  • I want to send an email  from my java application

    i want to send an email from my java application

    Then do so...
    You'll probably want to use the JavaMail API (http://java.sun.com/products/javamail) to do that.

  • Monitor Unix Mail Queue using java

    Hi! ,
    I want to monitor unix mail queue using java. how can i proceed..
    Please advice..
    Thanks..
    Ganesh

    Google and see if there is an API which lets you monitor it.
    Kaj

  • HTML tags  in emails sent through java

    Hi all,
    I am trying to send an email through my java code. I have set the content type of email to html. It is working fine for the html tags like <tm>,<head>,<table>,<td> etc but it is not working for the tabs whic set color ,border etc. <font color=#fffd"dd> ,<table border ="10"> etc
    How to enable this tags in java. What kind of API's i need to use for it.
    Hope my question is clear to all of you.
    Any pointers in this regard will be very helpful.
    Thanks,
    Abhishek chowdhury

    I am trying to send an email through my java code.No problem. As long as you construct the message correctly it should work.
    I have set the content type of email to html. It is working fine for the html tags like <tm>,<head>,<table>,<td> etc but it is not working for the tabs whic set color ,border etc. <font color=#fffd"dd> ,<table border ="10"> etcSo you haven't constructed them correctly.
    How to enable this tags in java.Java neither knows nor cares what is in a message body that it is sending. It is up to you.
    What kind of API's i need to use for it.I doubt that you need any APIs. Just construct the HTML correctly.
    Hope my question is clear to all of you.It's not, because the problem has nothing to do with Java and everything to do with your programming.

  • Unable to send messag to JMS Queue using Java

    Hi all,
    I am trying to send a string to the JMS queue using java. I am unable to send the message. It is getting failed at the look up for connection factory. I am using the below code for this purpose.
    public static void messageEnqueue(String payload) throws JMSException,
    NamingException,
    IOException {
    Session session = null;
    MessageProducer publisher = null;
    TextMessage message = null;
    Context context = new InitialContext();
    QueueConnectionFactory connectionFactory =
    (QueueConnectionFactory)context.lookup("*java:comp/env/XAConnectionFactoryJNDIName*");
    Connection connection = connectionFactory.createConnection();
    Queue Queue1 =
    (Queue)context.lookup("*java:comp/env/QueueName*");
    session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
    publisher = session.createProducer(Queue1);
    message = session.createTextMessage(Payload);
    connection.start();
    publisher.send(message);
    connection.stop();
    connection.close();
    kindly help on this.
    Thanks
    Edited by: 887737 on Jun 28, 2012 9:47 PM

    887737 wrote:
    Hi EJP,
    This is the Exception I got when I ran the java class directly from Jdeveloper. Can't I run the standalone class directly from Jdeveloper to insert the message into remote queue?
    Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
         at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
         at javax.naming.InitialContext.lookup(InitialContext.java:392)
         at javamail.MessageEnqueue.messageEnqueue(MessageEnqueue.java:30)
         at javamail.MessageEnqueue.main(MessageEnqueue.java:51)Hmm. The stack trace doesn't involve any JMS code. Is javamail.MessageEnqueue.messageEnqueue your application? It seems to be doing a JNDI lookup, and you haven't configured JNDI properly. Exactly how to do this depends on what JNDI provider you are using. Earlier in the thread you mentioned you were using WebLogic, so the answer may lie in the WebLogic documentation.
    Nigel

  • New iPad cannot get email to work java errors?

    New iPad cannot get email to work java errors?

    "Javascript" is not "java", two completely separate and different programming languages. So you are not getting "java errors". If you are using a browser to get your email then likely there is broken javascript code at the server.

  • Email going into email queue and not being sent out.

    All i have the following code
    declare
    appuseremail varchar(90);
    pospectname varchar(90);
    salescontact varchar(90);
    salescontactemail varchar(90);
    createdon varchar(90);
    targetdate varchar(90);
    posstatus varchar(90);
    statusmsg varchar(500);
    bususeremail varchar(100);
    sendtolist varchar(4000);
    sendtocclist varchar(4000);
    begin
    -- store the current users email address, so we can send him/her a copy
    select email into appuseremail from app_users where user_name = :APP_USER;
    select (firstname ||' '|| lastname)into salescontact from app_users where user_id = :P2_SALES_CONTACT;
    select email into salescontactemail from app_users where user_id = :P2_SALES_CONTACT;
    select email into bususeremail from app_users where user_name = :APP_USER;
    -- store the number of users that have been recerted
    pospectname := :P2_COM_NAME ;
    createdon := :P2_CREATE_DATE;
    targetdate := :P2_TARGET_DATE;
    posstatus := :P2_COM_STATUS;
    -- Build status message on status variable
    if posstatus = 'Accepted' THEN
      statusmsg := 'The commissions request for customer "'||pospectname||'" has been accepted by '||bususeremail||', and requires your input.</font><br><br> The commission request details are.';
      FOR c1 IN (SELECT email from app_users where roleid = (select role_id from app_roles where role_name = 'OPS')) LOOP
       -- Add each user to the email list.
        sendtolist := sendtolist||c1.email||',';
      END LOOP;
    FOR c2 IN (SELECT email from app_users where roleid = (select role_id from app_roles where role_name = 'BUSINESS')) LOOP
       -- Add each user to the email list.
      sendtocclist := sendtocclist||c2.email||',';
    END LOOP;
      sendtolist := sendtolist||salescontactemail;
      sendtocclist := sendtocclist||salescontactemail;
    end if;
    end;When i run this the first loop gets update and then the second list gets update, but when i go into the admin panel i see the messages are held in the email queue , why is this ?

    Hi Ben,
    I had the same problem. If you go into the INTERNAL workspace, mail settings, make sure it is pointing to your mail server there and not "localhost". Here is my post:
    Send Email Apex 2.2
    Thanks
    VC

  • UCCX finesse email queuing without deploying Socialminer

    we had a question as part of a UCCX upgrade to 10.5.
    Is it possible for us to use Finesse as an Agent to do Email queuing, without needing to setup Socialminer ?
    In that case, how would email integration/relay work ? how would Finesse connect with Exchange 2012 ?
    Thanks

    Hi
    No - if you are using Finesse, you need SocialMiner to add all multi-channel capabilities (e.g. chat, email)
    If you are using CAD you don't need SM as it uses the legacy service for CAD. 
    http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cust_contact/contact_center/crs/express_10_6/design/guide/UCCX_BK_CBB99111_00_cisco-unified-contact-center-express/UCCX_BK_CBB99111_00_cisco-unified-contact-center-express_chapter_011.html#UCCX_CN_FD9A570C_00
    Aaron

  • Cannot send email from WD Java

    hi Experts,
    I have created an email WD Java Application, this application sends an email to the users on click of a button.
    My Problem is this application runs well on SP11, but we have upgraded our dev portal to SP14.
    On SP14 mail is not send. Please help its really very urgent.
    I am pasting the code used for sending email.
    wdContext.currentEmailElement().setFrom(wdContext.currentContextElement().getEmpMailID());
           wdContext.currentEmailElement().setCc("");
           wdContext.currentEmailElement().setBcc("");
           wdContext.currentEmailElement().setSubject("Personal Travel Request.");
           wdContext.currentEmailElement().setTo("[email protected]");
           Properties props = new Properties();
           String host = "rmail070.zmail.ril.com";
           props.put("rmail070.zmail.ril.com", host);
           Session session = Session.getInstance(props, null);
           MimeMessage message = new MimeMessage(session);
           Address toAddress = new InternetAddress();
           Address fromAddress = new InternetAddress();
           Address ccAddress = new InternetAddress();
           Address bccAddress = new InternetAddress();
           try
           /* Creates an email object with different parts, one for the
           text and another for the attached file */
           MimeMultipart multipart = new MimeMultipart();
           BodyPart messageBodyPart = new MimeBodyPart();
           /* the following statements build up the email */
           if (! wdContext.currentEmailElement().getFrom().equals(""))
           fromAddress = new InternetAddress(wdContext.currentEmailElement().getFrom());
           message.setFrom(fromAddress);
           } if (! wdContext.currentEmailElement().getTo().equals(""))
           toAddress = new InternetAddress(wdContext.currentEmailElement().getTo());
           message.setRecipient(Message.RecipientType.TO,toAddress);
           if (! wdContext.currentEmailElement().getCc().equals(""))
           ccAddress = new InternetAddress(wdContext.currentEmailElement().getCc());
           message.setRecipient(Message.RecipientType.CC,ccAddress);
           if (! wdContext.currentEmailElement().getBcc().equals(""))
           bccAddress = new InternetAddress(wdContext.currentEmailElement().getBcc());
           message.setRecipient(Message.RecipientType.BCC,bccAddress);
           if (!wdContext.currentEmailElement().getSubject().equals(""))
           message.setSubject(wdContext.currentEmailElement().getSubject());
           if (! wdContext.currentEmailElement().getBody().equals(""))
           messageBodyPart.setText(wdContext.currentEmailElement().getBody());
           multipart.addBodyPart(messageBodyPart);
                /* a new part will be added, in the complete email this will
                be the attachment */
                messageBodyPart = new MimeBodyPart();
    //            try{
    //            String filename =WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(),"test.pdf");
    //            DataSource source = new FileDataSource(filename);
    //            messageBodyPart.setDataHandler(new DataHandler(source));
    //            messageBodyPart.setFileName(source.getName());
    //            messageBodyPart.setHeader("Content-Type","application/pdf");
    //            multipart.addBodyPart(messageBodyPart);
                message.setContent(multipart);
                Transport.send(message);
    //            catch(WDAliasResolvingException e)
    //                          e.getMessage();
                catch (AddressException e)
                wdComponentAPI.getMessageManager().reportWarning(e.
                getLocalizedMessage());
                e.printStackTrace();
                catch (SendFailedException e)
                wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());
                e.printStackTrace();
                catch (MessagingException e)
                wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());
                e.printStackTrace();
    Points will be rewarded to helpful answers.
    Regards,
    Sanjyoti.

    Hi,
    see this link it will be helpful for u
    [http://help.sap.com/saphelp_nw04/helpdata/en/f7/f289c67c759a41b570890c62a03519/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/f7/f289c67c759a41b570890c62a03519/content.htm]
    regards
    Hazrath

  • Need special encoded characters in an Email subject with java 1.3.1_02

    I need to find a way to construct an Email through java with Subject lines built using characters from various Asian encodings. Such as Shift-JIS, Chinese Big5, etc.
    These encodings cannot be in UTF-8 format and must remain in the native character set.
    For testing I have an HTML file constructed using a single line of text with Shift-JIS characters. This file shows properly in web browsers under the Shift-JIS encoding view, and when used to create the body of an email it works perfectly through the DataHandler. However, I cannot get any java Reader to pull the same stream of characters into the Subject of the email. The Subject is always garbage no matter what I do.
    Here is a small code sample with the relevant lines:
    Session session = Session.getDefaultInstance(System.getProperties(), null);
    MimeMessage reSend = new MimeMessage(session);
    Transport ship = session.getTransport();
    BufferedReader s = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\JavaPrograms\\Converted\\JISConv.html"), "SJIS"));
    String resub = s.readLine();
    s.close();
    reSend.setSubject(resub);
    DataHandler collect = new DataHandler(new FileDataSource("C:\\JavaPrograms\\Converted\\JISConv.html"));
    reSend.setDataHandler(collect);
    ship.send(reSend);If I use the "SJIS" encoding in the InputStreamReader above, all characters are shown as "?". If I delete it entirely and use the system default, I get half of the characters and the rest are garbage. I can generate either of those results using various other Japanese and Western encoding definitions.
    I have tried using the above code, also DataHandlers for the Subject, FileReader directly to a String, ByteArrayInputStreams, and StringBuffers. So far everything I try ends up at the same result.
    Can anyone help me out? I really need this to work. If I can get this one encoding to work, then I should be able to program case switches for the other encodings.
    Thanks kindly!
    Kurt Jackson

    First this is an issue with javamail and not with java.
    What makes you think that the mime standard allows what you want to do?
    Both of your 'tests' have been done using alternatives which do support alternative encodings.
    These encodings cannot be in UTF-8 format and must remain in the native character set.That seems rather unlikely to me. Email is transported using one encoding. Certainly SMTP uses only ascii. So what ever you put in there is going to be ASCII no matter what you do to it. I suppose something at the end might try to read it using an alternative encoding but then what happens when someone really wants to send those ASCII characters?
    Mime, I believe, is built on SMTP. And the subject line is still SMTP and thus ASCII.
    Here is one link that covers mime (you might want to check the backing references though.)
    http://www.mindspring.com/~mgrand/mime.html
    I believe there is some sort of official or unofficial standard for doing what you want. I would suggest that you start by getting that first. I would suspect JavaMail doesn't support it.
    Once you have a standard to follow you have the following choices..
    - Modify JavaMail directly to support this (this then becomes a non-distributable solution.)
    - Extend JavaMail do support this. This might or might not be possible.
    - Write your own implementation (don't use JavaMail.)
    - Find another solution from another source that already implements this.

  • Need to publish message from database to a JMS Queue using Java

    I need to publish messages to a Websphere JMS Queue whenever any changes happen on a particular column of a table in oracle 11g. For that I have written a trigger on that particular table which in turn will invoke one java procedure. I have written the java procedure using a standalone java class and uploaded the java class as a schema object. While executing the procedure it is throwing error as it is not able to instantiate some of the java classes. I don't know how to provide the reference of different jar files while executing the java class. Can anyone help me on this.

    Welcome to the forum!
    >
    I have written the java procedure using a standalone java class and uploaded the java class as a schema object. While executing the procedure it is throwing error as it is not able to instantiate some of the java classes. I don't know how to provide the reference of different jar files while executing the java class.
    >
    Clarify your statement. First you say 'standalone java class' but then you talk about instantiating java 'classes' and referencing 'different jar files'. If you are executing your Java class inside Oracle then any Java classes that your java class is referencing also have to be loaded into Oracle or it won't be able to reference or execute them.
    How do you plan to ' publish messages to a Websphere JMS Queue '? Where is this queue you are talking about?
    Why are you using a Java procedure and class instead of PL/SQL?
    What is your 4 digit Oracle version (result of SELECT * FROM V$VERSION)?

  • Monitor Print Queue with java program

    I'm plan to write a client/server based application which control the printing for every user. I've no idea how to start on the application.
    1. Is it possible to monitor the print queue or print job using java application?
    2. How does the server react if the client sending the print job to there? How's the client can trigger the signal during printing and send to the server?
    Thank you!

    I'm plan to write a client/server based application
    which control the printing for every user. I've no
    idea how to start on the application.You should establish feasibility first, before planning to write anything
    1. Is it possible to monitor the print queue or print
    job using java application?Not really. Print queues are highly system-dependent things and some e.g. Windows can really only be accessed via system calls in a native language.
    2. How does the server react if the client sending
    the print job to there?Err, it prints the file?
    How's the client can trigger the signal during printing and send to the server? What signal?
    But I suspect the answer to the first question makes the others irrelevant.

  • Purge a queue with JAVA API

    Hi,
    Is it possible to purge a queue with the JAVA API ?
    I have not found anything ...
    I am also trying to browse archived messages (state 2), the "browseQueue" method does only browse the ready messages (state 0).
    Is it possible to browse archived messages ?? (in java)
    Thanks in advance.

    found it, I had to write
    "ormi://<some-ip>:12401/orabpel" for java.naming.provider.url

Maybe you are looking for

  • Premiere Pro/Media Encoder fail when exporting something with AE linked?

    Hey all, I do some video production work for a university, and we're running into some problems when trying to export all the videos from a particularly large course.  We haven't run into this issue before so I'm hoping someone might have knowledge o

  • Change order quantity in sales order

    Hi, I have a sales order created. Now i want to change the Order qty depending on certain conditions through  an ABAP Program. Can any one tell me how to change it? I tried bapi SD_SALESDOCUMENT_CHANGE ..but couldn't succeed. I tried passing field to

  • Font problem in photoshop

    I have purchased Adobe Woodtype ornaments font package. The font will function in In Ddesign CS 3, but will not in Photoshop CS 3 even though the font is listed in the font directory in photoshop. Will this font function in Photoshop and Illustrator,

  • Can any one tell me how to work with call stacks

    i am working with user-exits and facing problem with call stacks  , i want to keep a error message .

  • Different Database structure migartion

    In second version of our software we change the database structure. Now we need to migrate data from version 1 to version 2 that have different database structure. Is Streaming or any other oracle feature provides possibility or I should write code b