首页 \ 问答 \ 弹簧反应堆项目的反应流背压(Reactive stream backpressure with spring reactor project)

弹簧反应堆项目的反应流背压(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 use buffer(50) for example it works.. Although this is not the final solution its a start.


原文:https://stackoverflow.com/questions/37394746
更新时间:2022-04-01 17:04

最满意答案

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){. otherwise stopPropagation 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 an undefined 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, the event of clicking needs to be consumed by your function, and therefore it is required to manually stopPropagation by calling event.stopPropagation() and injecting event into your closure, or you could simply also return false at the end of your function as it is a jquery event object which is the same as calling event.preventDefault() and event.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 ...
  • 我会建议使用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 ...
  • 当然这会发生。 该动画本质上是异步的,关闭函数将在开始动画后直接执行。 最好的方法是在动画的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 ...
  • 我认为这是因为你在动画期间从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, ' ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)