com.amazonaws.services.sqs.model.Message.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中com.amazonaws.services.sqs.model.Message.<init>()方法的一些代码示例,展示了Message.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.<init>()方法的具体详情如下:
包路径:com.amazonaws.services.sqs.model.Message
类名称:Message
方法名:<init>

Message.<init>介绍

暂无

代码示例

代码示例来源:origin: Netflix/conductor

@Test
  public void testException() {
    com.amazonaws.services.sqs.model.Message message = new com.amazonaws.services.sqs.model.Message().withMessageId("test")
        .withBody("")
        .withReceiptHandle("receiptHandle");
    Answer<?> answer = (Answer<ReceiveMessageResult>) invocation -> new ReceiveMessageResult();

    AmazonSQSClient client = mock(AmazonSQSClient.class);
    when(client.listQueues(any(ListQueuesRequest.class))).thenReturn(new ListQueuesResult().withQueueUrls("junit_queue_url"));
    when(client.receiveMessage(any(ReceiveMessageRequest.class))).thenThrow(new RuntimeException("Error in SQS communication"))
        .thenReturn(new ReceiveMessageResult().withMessages(message))
        .thenAnswer(answer);

    SQSObservableQueue queue = new SQSObservableQueue.Builder()
        .withQueueName("junit")
        .withClient(client).build();

    List<Message> found = new LinkedList<>();
    Observable<Message> observable = queue.observe();
    assertNotNull(observable);
    observable.subscribe(found::add);

    Uninterruptibles.sleepUninterruptibly(1000, TimeUnit.MILLISECONDS);

    assertEquals(1, found.size());

  }
}

代码示例来源:origin: aws/aws-sdk-java

public Message unmarshall(StaxUnmarshallerContext context) throws Exception {
  Message message = new Message();
  int originalDepth = context.getCurrentDepth();
  int targetDepth = originalDepth + 1;

代码示例来源:origin: aws-amplify/aws-sdk-android

public Message unmarshall(StaxUnmarshallerContext context) throws Exception {
  Message message = new Message();

代码示例来源:origin: com.amazonaws/aws-java-sdk-sqs

public Message unmarshall(StaxUnmarshallerContext context) throws Exception {
  Message message = new Message();
  int originalDepth = context.getCurrentDepth();
  int targetDepth = originalDepth + 1;

代码示例来源:origin: com.amazonaws/aws-android-sdk-sqs

public Message unmarshall(StaxUnmarshallerContext context) throws Exception {
  Message message = new Message();

代码示例来源:origin: spring-projects/spring-integration-aws

@Bean
public AmazonSQSAsync amazonSqs() {
  AmazonSQSAsync sqs = mock(AmazonSQSAsync.class);
  given(sqs.getQueueUrl(new GetQueueUrlRequest("testQueue")))
      .willReturn(new GetQueueUrlResult().withQueueUrl("http://testQueue.amazonaws.com"));
  given(sqs.receiveMessage(new ReceiveMessageRequest("http://testQueue.amazonaws.com")
      .withAttributeNames("All")
      .withMessageAttributeNames("All")
      .withMaxNumberOfMessages(10)
      .withWaitTimeSeconds(20)))
      .willReturn(new ReceiveMessageResult()
          .withMessages(new Message().withBody("messageContent"),
              new Message().withBody("messageContent2")))
      .willReturn(new ReceiveMessageResult());
  given(sqs.getQueueAttributes(any(GetQueueAttributesRequest.class)))
      .willReturn(new GetQueueAttributesResult());
  return sqs;
}

相关文章