/** * Event handler for reactor init event. * @param event Proton Event object */ @Override public void onReactorInit(Event event) { // Codes_SRS_AMQPSIOTHUBCONNECTION_15_033: [The event handler shall set the current handler to handle the connection events.] if(this.useWebSockets) { event.getReactor().connectionToHost(this.config.getIotHubHostname(), amqpWebSocketPort, this); } else { event.getReactor().connectionToHost(this.config.getIotHubHostname(), amqpPort, this); } }
@Override public void run(Selectable selectable) { Reactor reactor = selectable.getReactor(); selectable.terminate(); reactor.update(selectable); } };
@Override public void run() { if (TRACE_LOGGER.isWarnEnabled()) { TRACE_LOGGER.warn(String.format(Locale.US, "messagingFactory[%s], hostName[%s], message[%s]", getClientId(), getHostName(), "Processing all pending tasks and closing old reactor.")); } try { rctr.stop(); rctr.process(); } catch (HandlerException e) { if (TRACE_LOGGER.isWarnEnabled()) { TRACE_LOGGER.warn(String.format(Locale.US, "messagingFactory[%s], hostName[%s], error[%s]", getClientId(), getHostName(), ExceptionUtil.toStackTraceString(e, "scheduleCompletePendingTasks - exception occurred while processing events."))); } } finally { rctr.free(); } } }, MessagingFactory.this.getOperationTimeout().getSeconds(), TimeUnit.SECONDS);
this.rctr.start(); this.hasStarted = true; if (!Thread.interrupted() && this.rctr.process()) { try { this.executor.execute(this); this.rctr.attachments().set(RejectedExecutionException.class, RejectedExecutionException.class, exception); this.rctr.stop(); } catch (HandlerException handlerException) { Throwable cause = handlerException.getCause(); this.rctr.free(); closeTask.complete(null); if (closeTimer != null) {
private void initializeSelectable() { Selectable schedulerSelectable = this.reactor.selectable(); schedulerSelectable.setChannel(this.ioSignal.source()); schedulerSelectable.onReadable(this.workScheduler); schedulerSelectable.onFree(new CloseHandler()); schedulerSelectable.setReading(true); this.reactor.update(schedulerSelectable); }
@Override public void run() { if (!messagingFactory.open.isDone()) { messagingFactory.open.completeExceptionally(new TimeoutException("Opening MessagingFactory timed out.")); messagingFactory.getReactor().stop(); } } },
@Override public void onReactorInit(Event e) { TRACE_LOGGER.info("reactor.onReactorInit"); final Reactor reactor = e.getReactor(); reactor.setTimeout(ClientConstants.REACTOR_IO_POLL_TIMEOUT); }
@Override public void run(Selectable selectable) { Reactor reactor = selectable.getReactor(); Transport transport = ((SelectableImpl)selectable).getTransport(); long deadline = transport.tick(reactor.now()); selectable.setDeadline(deadline); int c = capacity(selectable); int p = pending(selectable); selectable.setReading(c > 0); selectable.setWriting(p > 0); reactor.update(selectable); } };
handler = reactor.getHandler(); Connection conn = reactor.connection(handler); Record conn_recs = conn.attachments(); conn_recs.set(CONNECTION_ACCEPTOR_KEY, Acceptor.class, AcceptorImpl.this); int maxFrameSizeOption = reactor.getOptions().getMaxFrameSize(); if (maxFrameSizeOption != 0) { trans.setMaxFrameSize(maxFrameSizeOption); if(reactor.getOptions().isEnableSaslByDefault()) { Sasl sasl = trans.sasl(); sasl.server();
@Override public void run(Selectable selectable) { Reactor reactor = selectable.getReactor(); try { SocketChannel socketChannel = ((ServerSocketChannel)selectable.getChannel()).accept(); if (socketChannel == null) { throw new ReactorInternalException("Selectable readable, but no socket to accept"); } Handler handler = BaseHandler.getHandler(AcceptorImpl.this); if (handler == null) { handler = reactor.getHandler(); } Connection conn = reactor.connection(handler); Transport trans = Proton.transport(); Sasl sasl = trans.sasl(); sasl.server(); sasl.setMechanisms("ANONYMOUS"); sasl.done(SaslOutcome.PN_SASL_OK); trans.bind(conn); IOHandler.selectableTransport(reactor, socketChannel.socket(), trans); } catch(IOException ioException) { sel.error(); } } }
/** * Event handler for the reactor init event * @param event The proton event object */ @Override public void onReactorInit(Event event) { // You can use the connection method to create AMQP connections. // This connection's handler is the AmqpSendHandler object. All the events // for this connection will go to the AmqpSendHandler object instead of // going to the reactor. If you were to omit the AmqpSendHandler object, // all the events would go to the reactor. // Codes_SRS_SERVICE_SDK_JAVA_AMQPRECEIVE_12_002: [The event handler shall set the member AmqpsReceiveHandler object to handle the given connection events] event.getReactor().connection(amqpReceiveHandler); }
String url = reactor.getConnectionAddress(connection); String hostname = connection.getHostname(); int port = 5672;
String conAddr = reactor.getConnectionAddress(connection); if (conAddr != null) { Address addr = new Address(conAddr); int maxFrameSizeOption = reactor.getOptions().getMaxFrameSize(); if (maxFrameSizeOption != 0) { transport.setMaxFrameSize(maxFrameSizeOption); if (reactor.getOptions().isEnableSaslByDefault()) { Sasl sasl = transport.sasl(); sasl.client();
private void initializeSelectable() { Selectable schedulerSelectable = this.reactor.selectable(); schedulerSelectable.setChannel(this.ioSignal.source()); schedulerSelectable.onReadable(this.workScheduler); schedulerSelectable.onFree(new CloseHandler()); schedulerSelectable.setReading(true); this.reactor.update(schedulerSelectable); }
@Override public void run() { if (!closeTask.isDone()) { closeTask.completeExceptionally(new TimeoutException("Closing MessagingFactory timed out.")); getReactor().stop(); } } },
@Override public void onReactorInit(Event e) { TRACE_LOGGER.debug("reactor.onReactorInit"); final Reactor reactor = e.getReactor(); reactor.setTimeout(ClientConstants.REACTOR_IO_POLL_TIMEOUT); }
@Override public void run(Selectable selectable) { Reactor reactor = selectable.getReactor(); Transport transport = ((SelectableImpl)selectable).getTransport(); long deadline = transport.tick(reactor.now()); selectable.setDeadline(deadline); int c = capacity(selectable); int p = pending(selectable); selectable.setReading(c > 0); selectable.setWriting(p > 0); reactor.update(selectable); } };
/** * Event handler for the reactor init event * @param event The proton event object */ @Override public void onReactorInit(Event event) { // You can use the connection method to create AMQP connections. // This connection's handler is the AmqpSendHandler object. All the events // for this connection will go to the AmqpSendHandler object instead of // going to the reactor. If you were to omit the AmqpSendHandler object, // all the events would go to the reactor. // Codes_SRS_SERVICE_SDK_JAVA_AMQPSEND_12_003: [The event handler shall set the member AmqpsSendHandler object to handle the given connection events] event.getReactor().connection(amqpSendHandler); }