@Override public void run() { while (!closed.get()) { ConsumerRecords<String, String> records = consumer.poll(1000); for (ConsumerRecord<String, String> record : records) { broadcastReceivedMessage(record.value()); } } consumer.close(); ((Set<String>)config.properties().get("topics")).remove(topic); } });
protected void mapAnnotatedService(boolean reMap, String path, AtmosphereRequest request, AtmosphereFramework.AtmosphereHandlerWrapper w) { synchronized (config.handlers()) { String servletPath = (String) config.properties().get("servletPath"); if (path.startsWith(servletPath)) { path = path.substring(servletPath.length()); } } super.mapAnnotatedService(reMap, path, request, w); }
producer = (KafkaProducer) config.properties().get("producer"); Set<String> topics = (Set<String>) config.properties().get("topics"); if (topics == null) { topics = new HashSet<String>(); config.properties().put("topics", topics); config.properties().put("producer", producer);
@Override public void configure(AtmosphereConfig config) { servletPath = IOUtils.guestServletPath(config); config.framework().getAtmosphereConfig().properties().put("servletPath", servletPath); this.config = config; }
@Override public void configure(final AtmosphereConfig config) { framework = config.framework(); supportWebSocket = config.framework().getAsyncSupport().supportWebSocket(); config.properties().put(HeaderConfig.JSONP_CALLBACK_NAME, "c"); for (AtmosphereInterceptor i : framework.interceptors()) { if (HeartbeatInterceptor.class.isAssignableFrom(i.getClass())) { HeartbeatInterceptor.class.cast(i).paddingText("h".getBytes()).heartbeatFrequencyInSeconds(25); } } if (config.handlers().size() == 0) { framework.addAtmosphereHandler("/*", ECHO_ATMOSPHEREHANDLER); } }
/** * {@inheritDoc} */ public void destroy() { if (!sharedPool) { Object lockingObject = getLockingObject(); synchronized (lockingObject) { try { disconnectPublisher(); disconnectSubscriber(); if (jedisPool != null) { jedisPool.destroy(); } } catch (Throwable t) { logger.warn("Jedis error on close", t); } finally { config.properties().put(REDIS_SHARED_POOL, null); } } } }
/** * {@inheritDoc} */ public void destroy() { if (!sharedPool) { Object lockingObject = getLockingObject(); synchronized (lockingObject) { try { disconnectPublisher(); disconnectSubscriber(); if (jedisPool != null) { jedisPool.destroy(); } } catch (Throwable t) { logger.warn("Jedis error on close", t); } finally { config.properties().put(REDIS_SHARED_POOL, null); } } } }
if (config.properties().get(REDIS_SHARED_POOL) != null) { jedisPool = (JedisPool) config.properties().get(REDIS_SHARED_POOL); config.properties().put(REDIS_SHARED_POOL, jedisPool); } else { disconnectSubscriber();
if (config.properties().get(REDIS_SHARED_POOL) != null) { jedisPool = (JedisPool) config.properties().get(REDIS_SHARED_POOL); config.properties().put(REDIS_SHARED_POOL, jedisPool); } else { disconnectSubscriber();
public AnnotatedProxy configure(AtmosphereConfig config, Object c) { this.proxiedInstance = c; this.onMessageMethods = populateMessage(c, OnMessage.class); this.onCloseMethod = populate(c, OnClose.class); this.onTimeoutMethod = populate(c, OnClose.class); this.onOpenMethod = populate(c, OnOpen.class); this.onResumeMethod = populate(c, OnClose.class); this.config = config; this.eventBus = (EventBus) config.properties().get("evenBus"); this.pathParams = pathParams(c); if (onMessageMethods.size() > 0) { populateEncoders(); populateDecoders(); } return this; }