Package com.amazonaws.services.sqs.model

Examples of com.amazonaws.services.sqs.model.SendMessageRequest


    private class MessageSender extends Thread {
      public void run() {
        try {
        logger.info("sender sleeping for 5 sec");
          sleep(5000);
              cqs1.sendMessage(new SendMessageRequest(queueUrl, "test message"));
              logger.info("test message sent");
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      }
View Full Code Here


     
      public void run() {
        try {
          Thread.sleep(delay);
          for (int i=0; i<count; i++) {
            cqs1.sendMessage(new SendMessageRequest(queueUrl, "test message " + i));
          }
      } catch (Exception ex) {
        logger.error("error", ex);
      }
      }
View Full Code Here

        cqs1.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, attributeParams));

        logger.info("Send a message with empty message body");
       
        try {
            SendMessageRequest sendMessageRequest = new SendMessageRequest();
            sendMessageRequest.setQueueUrl(queueUrl);
            cqs1.sendMessage(sendMessageRequest);
          fail("missing expected exception");
        } catch (AmazonServiceException ase) {
            assertTrue("Did not get missing parameter exception", ase.getErrorCode().equals(CQSErrorCodes.MissingParameter.getCMBCode()));
        }

        logger.info("Send a message with invalid DelaySeconds");
       
        try {
            SendMessageRequest sendMessageRequest = new SendMessageRequest();
            sendMessageRequest.setQueueUrl(queueUrl);
            String msg = "This is a message to test invalid delay seconds;";
            sendMessageRequest.setMessageBody(msg);
            sendMessageRequest.setDelaySeconds(1000);
            cqs1.sendMessage(sendMessageRequest);
          fail("missing expected exception");
        } catch (AmazonServiceException ase) {
            assertTrue("Did not get invalid parameter exception", ase.getErrorCode().contains(CQSErrorCodes.InvalidParameterValue.getCMBCode()));
        }

        logger.info("Send a very long message");
       
        try {
           
          SendMessageRequest sendMessageRequest = new SendMessageRequest();
            sendMessageRequest.setQueueUrl(queueUrl);
            StringBuffer msg = new StringBuffer("");
           
            for  (int i=0; i<300*1024; i++) {
                msg.append("M");
            }
           
            sendMessageRequest.setMessageBody(msg.toString());
            cqs1.sendMessage(sendMessageRequest);
          fail("missing expected exception");
       
        } catch (AmazonServiceException ase) {
            assertTrue("Did not get an invalid value exception", ase.getErrorCode().equals(CQSErrorCodes.InvalidParameterValue.getCMBCode()));
View Full Code Here

 
          // Send a message
         
          logger.info("Sending messages to " + queueUrl1);
         
          cqs1.sendMessage(new SendMessageRequest(queueUrl1, "This is my message text 1. " + (new Random()).nextInt()));
          cqs1.sendMessage(new SendMessageRequest(queueUrl1, "This is my message text 2. " + (new Random()).nextInt()));
          cqs1.sendMessage(new SendMessageRequest(queueUrl1, "This is my message text 3. " + (new Random()).nextInt()));
  
          logger.info("Receiving messages from " + queueUrl1);
         
          ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl1);
 
View Full Code Here

           
            // send message
           
            logger.info("Sending a message to " + queueUrl);
           
            cqs1.sendMessage(new SendMessageRequest(queueUrl, "This is my message text. " + (new Random()).nextInt()));
           
            // receive message
           
            logger.info("Receiving messages from " + queueUrl);
           
View Full Code Here

           
            // send message
           
            logger.info("Sending a message to " + queueUrl);
           
            cqs1.sendMessage(new SendMessageRequest(queueUrl, "This is my message text. " + (new Random()).nextInt()));
           
            // receive message
           
            logger.info("Receiving messages from " + queueUrl);
           
View Full Code Here

            Thread.sleep(100);          
           
            // send message
            logger.info("event=send_message queue_url=" + queueUrl);
            cqs1.sendMessage(new SendMessageRequest(queueUrl, "This is my message text. " + (new Random()).nextInt()));
            Thread.sleep(100);

            // receive message
           
            // message should be invisible now
View Full Code Here

            for (int i=0; i<256000; i++) {
              msg256k.append("X");
            }

            logger.info("Sending large message to " + queueUrl);
            SendMessageRequest sendMessageRequest = new SendMessageRequest(queueUrl, msg256k.toString());
            SendMessageResult sendResult = cqs1.sendMessage(sendMessageRequest);
           
            assertNotNull("Message id is null", sendResult.getMessageId());

            StringBuffer msg280k = new StringBuffer("");
           
            // 280k msg
           
            for (int i=0; i<280000; i++) {
              msg280k.append("X");
            }

            try {
              logger.info("Sending too large message to " + queueUrl);
              sendMessageRequest = new SendMessageRequest(queueUrl, msg280k.toString());
              sendResult = cqs1.sendMessage(sendMessageRequest);
              fail("should not accept messages > 256k");
            } catch (Exception ex) {
              assertTrue("wrong error, expected message too long", ex.getMessage().contains("body must be shorter than"));
            }
View Full Code Here

            cqs1.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, attributeParams));

            // send a batch of messages
           
            logger.info("Sending message to " + queueUrl);
            SendMessageRequest sendMessageRequest = new SendMessageRequest(queueUrl, "This is a test message");
            SendMessageResult sendResult = cqs1.sendMessage(sendMessageRequest);
           
            assertNotNull("Message id is null", sendResult.getMessageId());

            // receive messages
View Full Code Here

      String queueUrl = getQueueUrl(1, USR.USER1);
      //String message = "hello world!!!";
     
      String message = text;
           
      cqs1.sendMessage(new SendMessageRequest(queueUrl, message));
     
      ReceiveMessageResult result = cqs1.receiveMessage(new ReceiveMessageRequest(queueUrl));
     
      if (result != null && result.getMessages().size() == 1) {
        assertTrue("wrong message content: " + result.getMessages().get(0).getBody(), message.equals(result.getMessages().get(0).getBody()));
View Full Code Here

TOP

Related Classes of com.amazonaws.services.sqs.model.SendMessageRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.