弹簧反应堆项目的反应流背压(Reactive stream backpressure with spring reactor project)
我有研究和阅读文件,他们不是很容易理解。 我想要实现的是以下功能:
我正在使用Spring Reactor项目并使用eventBus。 我的活动巴士正在向模块A投掷活动
模块A应接收事件并插入到将保存唯一值的热流中。 每250个Milisecons溪流应拉动所有的价值,并在他们身上进行冥想......等等。
例如:eventBus正在抛出事件,其编号为1,2,3,2,3,2
流应该得到并保持唯一值 - > 1,2,3 250毫秒后,流应该打印数字和空值
任何人有一个想法如何开始? 我试过这些例子,但没有任何真正的工作,我想我不明白的东西。 任何人都有一个例子?
TNX
编辑:
当试图做下一个我总是得到异常:
Stream<List<Integer>> s = Streams.wrap(p).buffer(1, TimeUnit.SECONDS); s.consume(i -> System.out.println(Thread.currentThread() + " data=" + i)); for (int i = 0; i < 10000; i++) { p.onNext(i); }
例外情况:
java.lang.IllegalStateException: The environment has not been initialized yet at reactor.Environment.get(Environment.java:156) ~[reactor-core-2.0.7.RELEASE.jar:?] at reactor.Environment.timer(Environment.java:184) ~[reactor-core-2.0.7.RELEASE.jar:?] at reactor.rx.Stream.getTimer(Stream.java:3052) ~[reactor-stream-2.0.7.RELEASE.jar:?] at reactor.rx.Stream.buffer(Stream.java:2246) ~[reactor-stream-2.0.7.RELEASE.jar:?] at com.ta.ng.server.controllers.user.UserController.getUsersByOrgId(UserController.java:70) ~[classes/:?]
正如你所看到的,我不能继续尝试而不通过这个问题。
顺便说一句:这只是当我使用
buffer(1, TimeUnit.SECONDS)
如果我使用buffer(50)
,例如它的工作..虽然这不是最终的解决方案,它的一个开始。I have research and read documents by they are not very understandable. What i am trying to achieve is the following functionality:
I am using Spring Reactor project and using the eventBus. My event bus is throwing event to module A.
Module A should receive the event and insert into Hot Stream that will hold unique values. Every 250 Milisecons the stream should pull all value and make calulcation on them.. and so on.
For example: The eventBus is throwing event with number: 1,2,3,2,3,2
The Stream should get and hold unique values -> 1,2,3 After 250 miliseconds the stream should print the number and empty values
Anyone has an idea how to start? I tried the examples but nothing really works and i guess i don't understand something. Anyone has an example?
Tnx
EDIT:
When trying to do the next i always get exception:
Stream<List<Integer>> s = Streams.wrap(p).buffer(1, TimeUnit.SECONDS); s.consume(i -> System.out.println(Thread.currentThread() + " data=" + i)); for (int i = 0; i < 10000; i++) { p.onNext(i); }
The exception:
java.lang.IllegalStateException: The environment has not been initialized yet at reactor.Environment.get(Environment.java:156) ~[reactor-core-2.0.7.RELEASE.jar:?] at reactor.Environment.timer(Environment.java:184) ~[reactor-core-2.0.7.RELEASE.jar:?] at reactor.rx.Stream.getTimer(Stream.java:3052) ~[reactor-stream-2.0.7.RELEASE.jar:?] at reactor.rx.Stream.buffer(Stream.java:2246) ~[reactor-stream-2.0.7.RELEASE.jar:?] at com.ta.ng.server.controllers.user.UserController.getUsersByOrgId(UserController.java:70) ~[classes/:?]
As you can see i cannot proceed trying without passing this issue.
BY THE WAY: This is happeing only when i use
buffer(1, TimeUnit.SECONDS)
If i usebuffer(50)
for example it works.. Although this is not the final solution its a start.
原文:https://stackoverflow.com/questions/37394746
最满意答案
event
未定义。将
event
注入$(".row2 .glyphicon-remove").click(function(event){
。否则stopPropagation
无用。我认为,Chrome是严格的,并且在
undefined
它会停止对当前函数的评估,即它在遇到undefined
值时会抛出错误并停止针对该特定闭包的JS评估。但是,似乎firefox继续评估并且
click
了DOM树。 因此,在您的情况下,您的函数需要使用单击event
,因此需要通过调用event.stopPropagation()
并将event
注入闭包来手动stopPropagation
,或者您最后也可以return false
你的函数,因为它是一个jquery 事件对象 ,它与调用event.preventDefault()
和event.stopPropagation()
。例如
$(".row2 .glyphicon-remove").click(function(event){ //stop propagation for the event but continue to evaluate current function event.stopPropagation(); var clicked = this; $(this).parent().hide(); $(".row2 iframe").hide(); $(".row2 .text").hide(); $(this).parent().parent().animate({ width: "400px", },function(){ $(".row2 .VideoA").show(); $("img", this).removeClass('offleft'); $(".tag",this).css('cursor','pointer'); $(clicked).parent().parent().siblings().show(); }); return false; //jquery event stop propagation + prevent default });
event
is undefined.Inject
event
as$(".row2 .glyphicon-remove").click(function(event){
. otherwisestopPropagation
is useless.I think, Chrome is strict, and on
undefined
it stops evaluation of the current function i.e. it throws an error when it encounters anundefined
value and stops evaluation JS for that particular closure.However, seems firefox continues evaluation and bubbles the
click
up the DOM tree. So, in your case, theevent
of clicking needs to be consumed by your function, and therefore it is required to manuallystopPropagation
by callingevent.stopPropagation()
and injectingevent
into your closure, or you could simply alsoreturn false
at the end of your function as it is a jquery event object which is the same as callingevent.preventDefault()
andevent.stopPropagation()
.e.g.
$(".row2 .glyphicon-remove").click(function(event){ //stop propagation for the event but continue to evaluate current function event.stopPropagation(); var clicked = this; $(this).parent().hide(); $(".row2 iframe").hide(); $(".row2 .text").hide(); $(this).parent().parent().animate({ width: "400px", },function(){ $(".row2 .VideoA").show(); $("img", this).removeClass('offleft'); $(".tag",this).css('cursor','pointer'); $(clicked).parent().parent().siblings().show(); }); return false; //jquery event stop propagation + prevent default });
相关问答
更多-
event未定义。 将event注入$(".row2 .glyphicon-remove").click(function(event){ 。否则stopPropagation无用。 我认为,Chrome是严格的,并且在undefined它会停止对当前函数的评估,即它在遇到undefined值时会抛出错误并停止针对该特定闭包的JS评估。 但是,似乎firefox继续评估并且click了DOM树。 因此,在您的情况下,您的函数需要使用单击event ,因此需要通过调用event.stopPropagation ...
-
jQuery动画(jQuery animation)[2023-05-01]
我会建议使用CSS阴影,而不是JS 。 过去我已经处理了这个确切的问题,并且我已经完全停止使用JS进行投影。 我从来没有见过JS阴影的动画看起来像纯CSS一样流畅。 另外,使用太多的JS来改变页面元素可能会导致性能问题。 I would suggest using CSS for your drop shadows, and not JS. I have dealt with this exact problem in the past and I have completely stopped using ... -
以与w不同的模式打开。 如果它不存在,将使用'w'创建,否则它将截断文件中的任何内容。 请改用'a' ,默认情况下不会截断。 但请注意,文件光标将位于文件的末尾。 如果没有错误,你实际上想要覆盖,你必须手动f.seek(0)然后f.truncate() 。 编辑 实际上,使用r+可能会更好,它也不会自动截断,并且流位于文件的开头而不是结尾(就像它带有'a' ),所以只有一个简单的f.truncate()将是必要的。 在这里查看您的选项。 基本上,你绝对不希望'w'而是'r+'或'a'任何一个,具体取决于你想 ...
-
您可以使用:eq(1)来匹配匹配集中的第二个元素: $('.onlyContent:eq(1)').remove(); 如果元素的数量超过两个,那么你应该使用:not(:first)或:gt(0) : $('.onlyContent:not(:first)').remove(); 要么 $('.onlyContent:gt(0)').remove(); You can use :eq(1) for targetting second element in matched set: $('.onl ...
-
不要订阅Closing事件,而是尝试重写OnClosing方法。 基本窗口的OnClosing可以与AnimationWindowBase_Closing方法具有相同的代码。 但是在主窗口中你可以这样做: protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); if (!e.Cancel) AppConfigs.SaveAll(); } Instead of subscribing ...
-
动画后关闭WPF窗口(Close WPF window after animation)[2022-02-20]
当然这会发生。 该动画本质上是异步的,关闭函数将在开始动画后直接执行。 最好的方法是在动画的Completed事件上调用close函数。 在这种情况下,你写: ///// { DoubleAnimation anim = new DoubleAnimation(); // init you animation anim.Completed += anim_Completed; } //// void anim_Completed(object sender, Eve ... -
如果绑定失败,但旧实例不再运行,则设置SO_REUSEADDR可能会有所帮助。 If the bind fails, but the old instance is not running any more, setting SO_REUSEADDR is likely to help.
-
因为你要触发两个动画(在html和body上),所以应该调用两次完整的回调。 您可能希望仅在需要时才在html上触发动画 var animateOn = isIE8 ? 'html' : 'body'; $(animateOn).animate(); Since you're triggering two animations (on html and body) the complete callback should be called twice. You might want to on trig ...
-
关闭动画将无法运行(Close Animation will not run)[2022-04-03]
我认为这是因为你在动画期间从superview 中删除了视图。 由于视图消失,因此不会发生动画。 您应该等到动画结束后才能删除查看,您可以通过设置动画完成时调用的委托和选择器来完成。 [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 然后在 -(void)animationDidStop:(NSString *)ani ... -
这个结果是你想要的吗? 我改变了这一行 $('#sauceDet').animate({ right: "-9999px" }, 1500, 'linear'); 至 $('#sauceDet').animate({ right: "-9999px" },'linear'); 问题是从1.5秒开始的时间 Is this result what you want? I change this line $('#sauceDet').animate({ right: "-9999px" }, 1500, ' ...