【发布时间】:2018-02-20 14:36:00
【问题描述】:
我在 Vaadin 8 中通过网格实现实现了延迟加载。
我的后端在 AWS Lambda 上运行,响应对象的限制为 6 MB。
延迟加载实现为服务器提供了默认限制(40),这使我的程序崩溃并给出“body too large”错误。
我想更改 Vaadin 中延迟加载的默认限制。
下面是我的代码sn-p:
grid.setDataProvider((sortorder, offset, limit) -> {
try {
return billingClient.getInvoiceListByCriteria(criteria, (long) offset, (long) limit).stream();
} catch (Exception e) {
logger.error("Exception while getInvoiceListByCriteria", e);
return null;
}
}, () -> {
try {
totalInvoices = billingClient.getCountInvoiceListByCriteria(criteria).longValue();
Integer count = totalInvoices.intValue();
if (count == 0)
Notification.show("No Invoices found.", Notification.Type.HUMANIZED_MESSAGE);
return count;
} catch (Exception e) {
logger.error("Error occured while getting count calling getCountInvoiceListByCriteria", e);
Notification.show("Error while getting count", Notification.Type.ERROR_MESSAGE);
return null;
}
});
【问题讨论】:
-
出于好奇(我认为,这 40 件东西不应该破坏东西):您的 billingClient 是否也获得了超出您需要的数量?例如它是否还获取了与发票有关的所有文件,还是忽略了限制?这可能只是通常的 ORM 废话,尝试通过限制来解决这个问题可能只会损害其他东西(例如,更多查询只针对大屏幕的人,您的应用程序和数据库之间的巨大流量)。
-
billingClient 的响应对象是一个嵌套的对象列表,其中包含许多项目和与项目相关的税收。所以它本身就是一个巨大的物体,一切都是必需的。
-
那么这是你真正的问题。如果您只需要在几列中显示一些文本,请不要请求整个对象图。
-
@cfrick 谢谢。我会实施的。也可以通过手动设置限制来解决限制问题。
标签: java aws-lambda vaadin lazy-loading vaadin8