有没有办法在 Spring 5 中缓存来自 WebClient 的 Flux?我试过这个,但没有缓存任何东西。
@RestController
@SpringBootApplication
@EnableCaching
public class GatewayApplication {
@PostMapping(value ="/test", produces = "application/json")
public Flux<String> handleRequest(@RequestBody String body) {
return getHspadQuery(body);
}
@Cacheable("testCache")
private Flux<String> getData (String body) {
return WebClient.create().post()
.uri("http://myurl")
.body(BodyInserters.fromObject(body))
.retrieve().bodyToFlux(String.class).cache();
}
}
Run Code Online (Sandbox Code Playgroud)
当我提出第三个请求时,它永远不会完成。然后在随后的请求中我得到响应,但服务器抛出以下内容:
2018-04-09 12:36:23.920 ERROR 11488 --- [ctor-http-nio-4] r.ipc.netty.channel.ChannelOperations : [HttpServer] Error processing connection. Requesting close the channel
reactor.core.Exceptions$OverflowException: Could not emit buffer due to lack of requests
at reactor.core.Exceptions.failWithOverflow(Exceptions.java:215) ~[reactor-core-3.1.5.RELEASE.jar:3.1.5.RELEASE]
at reactor.core.publisher.FluxBufferPredicate$BufferPredicateSubscriber.emit(FluxBufferPredicate.java:292) ~[reactor-core-3.1.5.RELEASE.jar:3.1.5.RELEASE]
at reactor.core.publisher.FluxBufferPredicate$BufferPredicateSubscriber.onNextNewBuffer(FluxBufferPredicate.java:251) ~[reactor-core-3.1.5.RELEASE.jar:3.1.5.RELEASE]
at reactor.core.publisher.FluxBufferPredicate$BufferPredicateSubscriber.tryOnNext(FluxBufferPredicate.java:205) …Run Code Online (Sandbox Code Playgroud) 您好我是Wordpress和PHP的新手,我正在尝试删除插件中的函数中的用户.
wp_delete_user( $user->ID );
Run Code Online (Sandbox Code Playgroud)
一切都运行良好,但当我尝试使用wp_delete_user时,我收到以下错误:
Call to undefined function wp_delete_user() in /homepages/6/d480314532/htdocs/wsb7416187601/zisteau_web/wp-content/plugins/patreon-wordpress-master/classes/patreon_wordpress.php on line 135
Run Code Online (Sandbox Code Playgroud)
此函数位于wp-includes/user.php中.有没有办法导入这个功能在那里使用它?
谢谢.
我想问一下从java servlet运行一个长进程的最佳方法是什么.我有一个webapp,当客户端发出请求时,它运行一个servlet.该servlet应从请求中获取一些参数,然后运行一个进程.此过程可能需要很长时间,因此我需要单独运行它.执行此过程后,它会发送一封包含结果的电子邮件.
提前致谢.
Java最佳实践建议将属性作为常量读取.那么,您认为达到目标的最佳方法是什么?我的方法是:一个Configuration类只读取一次属性文件(单例模式),并使用此类在需要时读取属性作为常量.并存储一个Constants类:
public final class Configurations {
private Properties properties = null;
private static Configurations instance = null;
/** Private constructor */
private Configurations (){
this.properties = new Properties();
try{
properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(Constants.PATH_CONFFILE));
}catch(Exception ex){
ex.printStackTrace();
}
}
/** Creates the instance is synchronized to avoid multithreads problems */
private synchronized static void createInstance () {
if (instance == null) {
instance = new Configurations ();
}
}
/** Get the properties instance. Uses singleton pattern */
public static Configurations …Run Code Online (Sandbox Code Playgroud) 我想使用QueryDSL返回最大值.
使用此查询,我返回eventid等于id的间隔,它正常工作.
QInterval interval = QInterval.interval;
JPAQuery query = new JPAQuery(em);
BooleanExpression checkId = interval.event.eventid.eq(id);
Interval interv = query.from(interval).where(checkId).uniqueResult(interval);
Run Code Online (Sandbox Code Playgroud)
但是如果我这样做并添加这个谓词我会得到一个错误(我想返回具有最大时间时间戳的类End的对象和End的对象:
BooleanExpression getMax = interval.end.timestamp.eq(interval.end.timestamp.max());
Interval interv = query.from(interval).where(getMax).uniqueResult(interval);
Run Code Online (Sandbox Code Playgroud)
我认为问题可能与interval.end.timestamp.max()有关,因为它是一个DateTimeExpression.
错误是 Caused by: java.sql.SQLException: Invalid use of group function:
org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:314)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:131)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) …Run Code Online (Sandbox Code Playgroud) 我正在使用Wordpress开发应用程序。我想在使用Twitch TV使用OAuth登录后检查用户是否是分配角色的频道的订户。我认为可以使用Twitch API与用户调用对象,然后检查该用户是否为具有另一个GET的脚本,但是如果我打印$ twitchuser且$ suscript为无效,则可以完成此操作。我是PHP新手,您知道错误在哪里,或者是否有其他解决方法?我的函数包含在wp-includes/user.php文件末尾:
function your_function() {
// Check if the user is Twitch suscriptor
if ( !is_super_admin() ) {
$twitchuser = $_GET["https://api.twitch.tv/kraken/user"];
$twitchname = $twitchuser['name'];
$suscript = $_GET["https://api.twitch.tv/kraken/channels/mychannel/subscriptions/{$twitchname}"];
if ($suscript == "404 Not Found") {
$current_user = wp_get_current_user();
// Remove role
$u->remove_role( 'subscriber' );
// Add role
$u->add_role( 'nomember' );
}
}
}
add_action('wp_login', 'your_function');
Run Code Online (Sandbox Code Playgroud) 如何处理 REST API 中耗时操作的超时。假设我们有以下场景作为示例:
我可以认为我是一个带有消息代理的解决方案,可以将订单发送到队列并等待它们解决。
还有其他解决方法吗?
编辑 1:
是否可以在 Flask Admin 的编辑视图中使用column_formatters ?当我添加以下代码时,它在列表表单视图中呈现“随机”。但是当它呈现编辑视图时,该字段是原始的,不使用column_formatters。我对其进行了调试,确实正在使用 _user_formatter 方法仅用于列表视图。
self.column_formatters = {'model': self._user_formatter,}
def _user_formatter(self,view, context, model, name):
return "random"
Run Code Online (Sandbox Code Playgroud) 我想在PostGIS中将EPSG:4326转换为UTM(30N/EPSG:32630或29N/EPSG:32629).我做了以下查询,但结果错误:
SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT(36.5277099609375 -5.86424016952515)',4326),32630)) As check;
Run Code Online (Sandbox Code Playgroud)
我知道"POINT(5262418.33128724 -839958.963432011)"它应该是243625.00,4046330.00UTM 30N中的近似值.如果我从4326转换为UTM,我得到了正确的结果,但不是从UTM到4326.