mongodb-driver-reactivestreams升级后出现重复的关键问题

时间:2019-01-28 15:17:53

标签: java mongodb spring-boot spring-data-mongodb project-reactor

mongodb-driver-reactivestreams 版本从 1.6.0 升级到 1.9.0 或更高版本后,我在更新文档时遇到问题>

应更新的实体看起来像

onRequest(...)

在收到此类错误后,升级之前一切正常,

ReplayProcessor<Integer> flux = ReplayProcessor.create(Queues.SMALL_BUFFER_SIZE);
FluxSink<Integer> sink = flux.sink();

// ReplayProcessor.getBufferSize() returns unbounded,
// while CAPACITY returns the capacity of the underlying buffer.
int capacity = flux.scan(Scannable.Attr.CAPACITY);

// Add twice as many elements as the underlying buffer can take.
int count = capacity * 2;

for (int i = 0; i < count; i++) {
    sink.next(i);
}

// If `capacity` is 256, this will print value 256 thru to 511.
flux.subscribe(System.out::println);

要保存/覆盖文档,我正在使用 ReactiveMongoRepository#save 方法。我应该如何更改我的应用程序以使其再次运行,或者可能存在某种错误?

这也是我用于连接的配置文件:

import lombok.Data; 
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id; 
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.domain.Persistable;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.time.Instant;

@Data
@Document
@NoArgsConstructor
public class Device implements Serializable, Persistable<String> {

  @Id
  private String id;

  private String deviceId;

  @Indexed
  @LastModifiedDate
  private Instant lastRecorded;

  public void setId(String id) {
  }

  public void setDeviceId(String deviceId) {
    this.deviceId = deviceId;
    this.id = deviceId;
  }

  @Override
  public String getId() {
    return id;
  }

  @Override
  public boolean isNew() {
    return lastRecorded == null;
  }

}

如果我能使用 spring-boot 2.1.1

0 个答案:

没有答案