这是我的OrderDTO pojo课
public class OrderDTO implements Serializable {
private static final long serialVersionUID = -4500200949047532187L;
@JsonProperty("id")
private Long id;
@JsonProperty("tin")
private String tin;
@JsonProperty("amount")
private BigDecimal amount;
@JsonProperty("status")
private TicketStatus status;
@JsonProperty("customerInfo")
private CustomerDTO customerDTO;
@JsonProperty("oldTicketIdReference")
private String oldTicketIdReference;
@JsonProperty("newTicketIdReference")
private String newTicketIdReference;
@JsonProperty("cancellationTermsInfo")
private CancellationTermsDTO cancellationTermsDTO;
@JsonProperty("cartId")
private Long cartId;
@JsonProperty("transactionNumber")
private Long transactionNumber;
@JsonProperty("umsUserId")
private Integer umsUserId;
}
如果我有如下所示的orderDTO列表,并且想一次获得客户端连接,然后只想流式传输orderDTO列表,该怎么办?你能告诉我吗。 目前,我的代码是这样的
final Client client = new Client();
List<OrderDTO> listOrderDto = getListOfOrders(cartId);
listOrderDto.parallelStream().forEach(orderDto->{
client.target(
"http://localhost:8080/orders/writeAndIncrementOrder").
header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).
request.post(Entity.json(orderDto));
});
但是我不想多次休息,我只想获得一次客户端连接,然后将listOrderDto作为输出流发布到客户端。