• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Reactor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中reactor.core.Reactor的典型用法代码示例。如果您正苦于以下问题:Java Reactor类的具体用法?Java Reactor怎么用?Java Reactor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Reactor类属于reactor.core包,在下文中一共展示了Reactor类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: thumbnailImage

import reactor.core.Reactor; //导入依赖的package包/类
/**
 * Accept an image upload via POST and notify a Reactor that the image needs to be thumbnailed. Asynchronously respond
 * to the client when the thumbnailing has completed.
 *
 * @param channel
 *     the channel on which to send an HTTP response
 * @param thumbnail
 *     a reference to the shared thumbnail path
 * @param reactor
 *     the Reactor on which to publish events
 *
 * @return a consumer to handle HTTP requests
 */
public static Consumer<FullHttpRequest> thumbnailImage(NetChannel<FullHttpRequest, FullHttpResponse> channel,
                                                       AtomicReference<Path> thumbnail,
                                                       Reactor reactor) {
  return req -> {
    if (req.getMethod() != HttpMethod.POST) {
      channel.send(badRequest(req.getMethod() + " not supported for this URI"));
      return;
    }

    // write to a temp file
    Path imgIn = null;
    try {
      imgIn = readUpload(req.content());
    } catch (IOException e) {
      throw new IllegalStateException(e.getMessage(), e);
    }

    // Asynchronously thumbnail the image to 250px on the long side
    reactor.sendAndReceive("thumbnail", Event.wrap(imgIn), ev -> {
      thumbnail.set(ev.getData());
      channel.send(redirect());
    });
  };
}
 
开发者ID:danielyinanc,项目名称:spring-guides,代码行数:38,代码来源:ImageThumbnailerRestApi.java


示例2: main

import reactor.core.Reactor; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	Environment env = new Environment();
	Reactor reactor = Reactors.reactor().env(env).dispatcher(Environment.THREAD_POOL).get();

	// topic: parse
	reactor.on($("parse"), App::handleEvent1);
	reactor.on($("parse"), App::handleEvent2);

	// Notify consumers of the 'parse' topic that data is ready
	// by passing a Supplier<Event<T>> in the form of a lambda

	for (long l = 0; true; l++) {
		String obj = "Test-" + l;
		reactor.notify("parse", Event.wrap(new ObjectEvent().setObject(obj)));
		Thread.sleep(1000);
	}

}
 
开发者ID:smallnest,项目名称:DisruptorBootstrap,代码行数:19,代码来源:App.java


示例3: EventResource

import reactor.core.Reactor; //导入依赖的package包/类
/**
 * Ctor.
 * 
 * @param reactor
 *            the instance of reactor to use
 * @param store
 *            the instance of event store to use
 */
public EventResource(Reactor reactor, EventStore store) {
	this.broadcaster = new SseBroadcaster();
	this.store = store;
	this.reactors = reactor;
	this.lastEventId = new AtomicLong(-1);

	this.reactors.on(Selectors.object("out"), (reactor.event.Event<Long> lastEventId) -> {
		broadcast(lastEventId.getData().longValue());
	});
	this.reactors.on(Selectors.object("in"), (reactor.event.Event<Event> e) -> {
		store.use(e.getData());
		broadcast(this.lastEventId.longValue());
	});

	if (Boolean.getBoolean("visactor.demo")) {
		logger.warn("visactor demo mode is enabled.");
		startDemoEvents();
	}
}
 
开发者ID:nobeh,项目名称:visactor,代码行数:28,代码来源:EventResource.java


示例4: main

import reactor.core.Reactor; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    Environment env = new Environment();
    final TradeServer server = new TradeServer();

    // Use a Reactor to dispatch events using the default Dispatcher
    Reactor reactor = Reactors.reactor()
            .env(env)
            .dispatcher("ringBuffer")
            .get();

    String topic = "trade.execute";

    // For each Trade event, execute that on the server
    reactor.on($(topic), new Consumer<Event<Trade>>() {
        @Override
        public void accept(Event<Trade> tradeEvent) {
            server.execute(tradeEvent.getData());

            // Since we're async, for this test, use a latch to tell when we're done
            latch.countDown();
        }
    });

    // Start a throughput timer
    startTimer();

    // Publish one event per trade
    for (int i = 0; i < totalTrades; i++) {
        // Pull next randomly-generated Trade from server
        Trade t = server.nextTrade();

        // Notify the Reactor the event is ready to be handled
        reactor.notify(topic, Event.wrap(t));
    }

    // Stop throughput timer and output metrics
    endTimer();

    server.stop();
}
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:41,代码来源:TradeServerExample.java


示例5: GroupMessageListener

import reactor.core.Reactor; //导入依赖的package包/类
@Autowired
public GroupMessageListener(final List<CommandPlugin> commandPlugins, final GroupService groupService, final Reactor reactor,
		final CounterService counterService) {
	this.commandPlugins = commandPlugins;
	this.groupService = groupService;
	this.reactor = reactor;
	this.counterService = counterService;
}
 
开发者ID:learning-spring-boot,项目名称:contest-votesapp,代码行数:9,代码来源:GroupMessageListener.java


示例6: reactor

import reactor.core.Reactor; //导入依赖的package包/类
@Bean
public Reactor reactor(Environment env, MailServer mailServer) {
    Logger log = LoggerFactory.getLogger("mail.server");
    Reactor r = Reactors.reactor(env);

    // Wire an event handler to execute messages
    r.on($("mail.execute"), (Event<MessageDescriptor> ev) -> {
        mailServer.execute(ev.getData());
        log.info("Executed message: {}", ev.getData());
    });

    return r;
}
 
开发者ID:mdarapour,项目名称:microservice-workshop,代码行数:14,代码来源:BootMailServer.java


示例7: getDefaultReactor

import reactor.core.Reactor; //导入依赖的package包/类
public Reactor getDefaultReactor() {
	return defaultReactor;
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:4,代码来源:SingletonEnvironment.java


示例8: WhatsAppClientToReactorBridge

import reactor.core.Reactor; //导入依赖的package包/类
@Autowired
public WhatsAppClientToReactorBridge(final WhatsAppClient whatsAppClient, final Reactor rootReactor, final CounterService counterService) {
	this.whatsAppClient = whatsAppClient;
	this.rootReactor = rootReactor;
	this.counterService = counterService;
}
 
开发者ID:learning-spring-boot,项目名称:contest-votesapp,代码行数:7,代码来源:WhatsAppClientToReactorBridge.java


示例9: rootReactor

import reactor.core.Reactor; //导入依赖的package包/类
@Bean
public Reactor rootReactor(final Environment env) {
	return Reactors.reactor().env(env).get();
}
 
开发者ID:learning-spring-boot,项目名称:contest-votesapp,代码行数:5,代码来源:VotesAppApplication.java


示例10: MailController

import reactor.core.Reactor; //导入依赖的package包/类
@Autowired
public MailController(UserRepository users,
                      Reactor reactor) {
    this.users = users;
    this.reactor = reactor;
}
 
开发者ID:mdarapour,项目名称:microservice-workshop,代码行数:7,代码来源:MailController.java


示例11: Subscription

import reactor.core.Reactor; //导入依赖的package包/类
/**
 * Creates a new Subscription
 * @param reactor The reactor for event listening and async dispatch
 * @param pattern The subscription pattern
 * @param expectedInsertions The number of expected insertions
 * @param types The TSDBEvent types to subscribe to
 */
public Subscription(final Reactor reactor, final ObjectName pattern, final int expectedInsertions, final TSDBEventType...types) {
	this(reactor, pattern.toString(), expectedInsertions);
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:11,代码来源:Subscription.java


示例12: VisactorResource

import reactor.core.Reactor; //导入依赖的package包/类
/**
 * Ctor.
 * 
 * @param reactor
 *            the instance of {@link Reactor} to use.
 * @param store
 *            the event store instance.
 */
public VisactorResource(Reactor reactor, EventStore store) {
	this.eventResource = new EventResource(reactor, store);
}
 
开发者ID:nobeh,项目名称:visactor,代码行数:12,代码来源:VisactorResource.java


示例13: invoke

import reactor.core.Reactor; //导入依赖的package包/类
public abstract void invoke(final Group group, final Reactor reactor, final GroupMessage message); 
开发者ID:learning-spring-boot,项目名称:contest-votesapp,代码行数:2,代码来源:Answer.java



注:本文中的reactor.core.Reactor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ShutdownHookProcessDestroyer类代码示例发布时间:2022-05-22
下一篇:
Java PhysicsCollisionObject类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap