当我在lambda函数中启动一个新线程并返回时,它似乎停止执行新线程并关闭。
public class Importer implements RequestHandler<Request<ImportJob>, Response> {
@Override
public Response handleRequest(final Request<ImportJob> request, final Context context) {
CompletableFuture.runAsync(() -> uploadOriginalFile(importJob), ioThreadPool)
.thenRunAsync(() -> convert(importJob), importThreadPool)
.thenRun(() -> createThumbnail(importJob))
.handleAsync((r, cause) -> completeJob(importJob, cause), ioThreadPool);
return new Response("Execution started");
}
}
Run Code Online (Sandbox Code Playgroud)
当我等待使用执行所有CompletableFuture时join(),它会按预期运行,但是当我尝试在aysnc中运行它时,立即返回响应并终止。还有其他方法可以异步运行lambda还是我做错了什么?
我正在使用带有 Spring Boot 的 Hazelcast 集群缓存。我使用的是 4.2 版本的 hazelcast。
缓存工作正常,但在 TTL 后不会从缓存映射中逐出数据。始终保留相同的数据。我尝试了很多设置ttl的方法,但没有成功。
这是我的机会配置类
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spring.cache.HazelcastCacheManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableCaching
public class CacheConfig {
@Value("${hazelcast.cluster-name}")
private String hzClusterName;
@Value("${hazelcast.address}")
private String hzAddress;
@Bean
HazelcastInstance hazelcastInstance() {
return HazelcastClient.newHazelcastClient(clientConfig());
}
@Bean
public ClientConfig clientConfig() {
ClientConfig cfg = ClientConfig.load();
cfg.setClusterName(hzClusterName);
cfg.getNetworkConfig().addAddress(hzAddress);
return cfg;
}
@Bean
public CacheManager cacheManager() {
return new HazelcastCacheManager(hazelcastInstance());
}
}
Run Code Online (Sandbox Code Playgroud)
我使用可缓存的缓存类
@Cacheable("items")
public String …Run Code Online (Sandbox Code Playgroud) 我正在使用 Spring Mongo Auditing 和 @CreatedDate @CreatedBy 不起作用,但 @LastModifiedDate 和 @LastModifiedBy 工作正常。
我在配置类上添加了 @EnableMongoAuditing,并定义了 AuditAware。
@Component("securityAuditorAware")
public class SecurityAuditorAware implements AuditorAware<String> {
@Override
public Optional<String> getCurrentAuditor() {
return Optional.ofNullable(SecurityUtils.getUserPrincipal()).map(AuthenticatedUser::getIssuer);
}
}
Run Code Online (Sandbox Code Playgroud)
审核类别为:
@Document
public class Template {
@Id
private UUID id = UUID.randomUUID();
@CreatedDate
private Date createdOn;
@LastModifiedDate
private Date modifiedOn;
@CreatedBy
private String createdBy;
@LastModifiedBy
private String modifiedBy;
}
Run Code Online (Sandbox Code Playgroud)
当我保存文档时,它在createdOn和createdBy中都放入了null,但在modifiedOn和modifiedBy中都放入了正确的值
谢谢您的帮助
我有两个实体用户和帐户。两者都有一对一的映射。这是实体类: 用户:
@Entity
@Table(name = 'docutools_users')
public class DocutoolsUser {
@Id
@Type(type = "pg-uuid")
UUID id = UUID.randomUUID();
@OneToOne(mappedBy = "user", cascade = ALL)
Account account;}
Run Code Online (Sandbox Code Playgroud)
帐户
@Entity
@Table(name = "accounts")
public class Account {
@Id
@Type(type = "pg-uuid")
private UUID id = UUID.randomUUID();
@Column(nullable = false)
private LocalDate activated = LocalDate.now();
@OneToOne
private DocutoolsUser user;
}
Run Code Online (Sandbox Code Playgroud)
询问
@Query("SELECT u FROM DocutoolsUser u WHERE u.account IS NOT NULL")
Page<DocutoolsUser> findByAccountNotNull()
Run Code Online (Sandbox Code Playgroud)
我正在使用 JPA 存储库。即使用户中没有帐户,表达式u.account IS …
我正在使用 libvips 来旋转图像。我正在使用具有 3002 MB Ram 和 512MB 临时存储的 VM。AWS Lambda 机器。
我运行旋转图像的命令是
vips rot original.jpg rotated.jpg d90
Run Code Online (Sandbox Code Playgroud)
它抛出以下错误
Exit Code: 1, Error Output: ERROR: wbuffer_write: write failed unix error: No space left on device
Run Code Online (Sandbox Code Playgroud)
jpg 图像大约为 10Mb。
车型类别车辆
@Column(name="type",nullable=false)
private String type;
@Column(name="last_service_date",nullable=false)
private String lastServiceDate;
@Column(name="seats",nullable=false)
private Long seats;
@Column(name="bags_capacity",nullable=false)
private Long bagsCapacity;
@Column(name="milage",nullable=false)
private Long milage;
//for Franchise object id
private transient Long fId;
@ManyToOne
@JoinColumn(name="franchise_id")
private Franchise fkFranchiseId;
@Repository
public interface VehicleRepository extends JpaRepository<Vehicle,Long>
{
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 spring data jpa 存储库,想要按类型和foreignKey=>(zipcode) 搜索车辆,我怎样才能找到
java ×3
spring ×2
asynchronous ×1
auditing ×1
aws-lambda ×1
hazelcast ×1
java-8 ×1
jpql ×1
postgresql ×1
spring-boot ×1
spring-cache ×1
vips ×1