Exemplo n.º 1
0
 @Override
 protected void doStart() throws Exception {
   new Thread() {
     @Override
     public void run() {
       try {
         // TODO support multiple address subscroption
         Messenger messenger = getEndpoint().getMessenger();
         messenger.subscribe(getEndpoint().getAddress());
         while (true) {
           messenger.recv();
           while (messenger.incoming() > 0) {
             Message msg = messenger.get();
             Section body = msg.getBody();
             AmqpValue amqpValue = (AmqpValue) body;
             Exchange exchange =
                 ExchangeBuilder.anExchange(getEndpoint().getCamelContext())
                     .withBody(amqpValue.getValue())
                     .build();
             getProcessor().process(exchange);
           }
         }
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }.start();
   super.doStart();
 }
Exemplo n.º 2
0
 @Override
 protected void doStart() throws Exception {
   server = SoapServer.builder().httpPort(configuration.getPort()).build();
   server.start();
   server.registerRequestResponder(configuration.getContext(), new CamelResponder(builder));
   super.doStart();
 }
Exemplo n.º 3
0
 @Override
 public void suspend() throws Exception {
   super.suspend();
   // currently do not support resume and suspend of listener, right
   // now this delegates to just stopping and
   // starting the consumer.
   doStop();
 }
  @Override
  protected void doStart() throws Exception {
    super.doStart();

    executor = getEndpoint().createExecutor();

    executor.submit(new ReplicationControllersConsumerTask());
  }
Exemplo n.º 5
0
 @Override
 protected void doStop() throws Exception {
   if (registration != null) {
     registration.unregister();
   }
   executor.shutdown();
   super.doStop();
 }
Exemplo n.º 6
0
  @Override
  protected void doStart() throws Exception {
    super.doStart();

    // validate that if backoff multiplier is in use, the threshold values is set correclty
    if (backoffMultiplier > 0) {
      if (backoffIdleThreshold <= 0 && backoffErrorThreshold <= 0) {
        throw new IllegalArgumentException(
            "backoffIdleThreshold and/or backoffErrorThreshold must be configured to a positive value when using backoffMultiplier");
      }
      LOG.debug(
          "Using backoff[multiplier={}, idleThreshold={}, errorThreshold={}] on {}",
          new Object[] {
            backoffMultiplier, backoffIdleThreshold, backoffErrorThreshold, getEndpoint()
          });
    }

    if (scheduler == null) {
      scheduler = new DefaultScheduledPollConsumerScheduler();
    }
    scheduler.setCamelContext(getEndpoint().getCamelContext());
    scheduler.onInit(this);
    scheduler.scheduleTask(this);

    // configure scheduler with options from this consumer
    Map<String, Object> properties = new HashMap<String, Object>();
    IntrospectionSupport.getProperties(this, properties, null);
    IntrospectionSupport.setProperties(
        getEndpoint().getCamelContext().getTypeConverter(), scheduler, properties);
    if (schedulerProperties != null && !schedulerProperties.isEmpty()) {
      // need to use a copy in case the consumer is restarted so we keep the properties
      Map<String, Object> copy = new HashMap<String, Object>(schedulerProperties);
      IntrospectionSupport.setProperties(
          getEndpoint().getCamelContext().getTypeConverter(), scheduler, copy);
      if (copy.size() > 0) {
        throw new FailedToCreateConsumerException(
            getEndpoint(),
            "There are "
                + copy.size()
                + " scheduler parameters that couldn't be set on the endpoint."
                + " Check the uri if the parameters are spelt correctly and that they are properties of the endpoint."
                + " Unknown parameters=["
                + copy
                + "]");
      }
    }

    ObjectHelper.notNull(scheduler, "scheduler", this);
    ObjectHelper.notNull(pollStrategy, "pollStrategy", this);

    ServiceHelper.startService(scheduler);

    if (isStartScheduler()) {
      startScheduler();
    }
  }
Exemplo n.º 7
0
 @Override
 protected void doStart() throws Exception {
   super.doStart();
   executor =
       endpoint
           .getCamelContext()
           .getExecutorServiceManager()
           .newFixedThreadPool(this, endpoint.getEndpointUri(), 1);
   listener = new Listener(endpoint, processor, socketFactory, contextFactory);
   executor.submit(listener);
 }
Exemplo n.º 8
0
 @Override
 protected void doStart() throws Exception {
   CamelWorkflowDefinitionFactoryFactory factoryFactory =
       new CamelWorkflowDefinitionFactoryFactory(this, configuration);
   genericWorker =
       new GenericWorkflowWorker(
           endpoint.getSWClient(), configuration.getDomainName(), configuration.getWorkflowList());
   genericWorker.setWorkflowDefinitionFactoryFactory(factoryFactory);
   genericWorker.start();
   super.doStart();
 }
Exemplo n.º 9
0
  @Override
  protected void doStop() throws Exception {
    ServiceHelper.stopService(scheduler);

    // clear counters
    backoffCounter = 0;
    idleCounter = 0;
    errorCounter = 0;

    super.doStop();
  }
Exemplo n.º 10
0
  protected void configureConsumer(Consumer consumer) throws Exception {
    if (consumerProperties != null) {
      // use a defensive copy of the consumer properties as the methods below will remove the used
      // properties
      // and in case we restart routes, we need access to the original consumer properties again
      Map<String, Object> copy = new HashMap<String, Object>(consumerProperties);

      // set reference properties first as they use # syntax that fools the regular properties
      // setter
      EndpointHelper.setReferenceProperties(getCamelContext(), consumer, copy);
      EndpointHelper.setProperties(getCamelContext(), consumer, copy);

      // special consumer.bridgeErrorHandler option
      Object bridge = copy.remove("bridgeErrorHandler");
      if (bridge != null && "true".equals(bridge)) {
        if (consumer instanceof DefaultConsumer) {
          DefaultConsumer defaultConsumer = (DefaultConsumer) consumer;
          defaultConsumer.setExceptionHandler(
              new BridgeExceptionHandlerToErrorHandler(defaultConsumer));
        } else {
          throw new IllegalArgumentException(
              "Option consumer.bridgeErrorHandler is only supported by endpoints,"
                  + " having their consumer extend DefaultConsumer. The consumer is a "
                  + consumer.getClass().getName()
                  + " class.");
        }
      }

      if (!this.isLenientProperties() && copy.size() > 0) {
        throw new ResolveEndpointFailedException(
            this.getEndpointUri(),
            "There are "
                + copy.size()
                + " parameters that couldn't be set on the endpoint consumer."
                + " Check the uri if the parameters are spelt correctly and that they are properties of the endpoint."
                + " Unknown consumer parameters=["
                + copy
                + "]");
      }
    }
  }
Exemplo n.º 11
0
 @Override
 protected void doStart() throws Exception {
   super.doStart();
   Properties props = new Properties();
   props.put("org.ops4j.pax.logging.appender.name", endpoint.getName());
   registration =
       endpoint
           .getComponent()
           .getBundleContext()
           .registerService(PaxAppender.class.getName(), this, props);
   executor = Executors.newSingleThreadExecutor();
 }
Exemplo n.º 12
0
  @Override
  protected void doStop() throws Exception {
    if (listenerContainer != null) {
      listenerContainer.stop();
      listenerContainer.destroy();
    }

    // null container and listener so they are fully re created if this consumer is restarted
    // then we will use updated configuration from jms endpoint that may have been managed using JMX
    listenerContainer = null;
    messageListener = null;
    super.doStop();
  }
  @Override
  protected void doStop() throws Exception {
    super.doStop();

    LOG.debug("Stopping Kubernetes Replication Controllers Consumer");
    if (executor != null) {
      if (getEndpoint() != null && getEndpoint().getCamelContext() != null) {
        getEndpoint().getCamelContext().getExecutorServiceManager().shutdownNow(executor);
      } else {
        executor.shutdownNow();
      }
    }
    executor = null;
  }
Exemplo n.º 14
0
 @Override
 protected void doStop() throws Exception {
   super.doStop();
   if (listener != null) {
     listener.stop();
   }
   if (executor != null) {
     LOGGER.debug("Shutdown of executor");
     if (!executor.isShutdown()) {
       executor.shutdownNow();
     }
     LOGGER.debug("Executor is now shutdown");
     executor = null;
   }
 }
Exemplo n.º 15
0
  /**
   * Initializes the mbean server connection and starts listening for Notification events from the
   * object.
   */
  @Override
  protected void doStart() throws Exception {
    super.doStart();

    JMXEndpoint ep = (JMXEndpoint) getEndpoint();

    // connect to the mbean server
    if (ep.isPlatformServer()) {
      setServerConnection(ManagementFactory.getPlatformMBeanServer());
    } else {
      JMXServiceURL url = new JMXServiceURL(ep.getServerURL());
      String[] creds = {ep.getUser(), ep.getPassword()};
      Map<String, String[]> map = Collections.singletonMap(JMXConnector.CREDENTIALS, creds);
      JMXConnector connector = JMXConnectorFactory.connect(url, map);
      setServerConnection(connector.getMBeanServerConnection());
    }
    // subscribe
    addNotificationListener();
  }
Exemplo n.º 16
0
  @Override
  protected void doStart() throws Exception {
    super.doStart();

    // create listener container
    if (listenerContainer == null) {
      createMessageListenerContainer();
    }

    listenerContainer.afterPropertiesSet();

    // only start listener if auto start is enabled or we are explicit invoking start later
    if (initialized || getEndpoint().isAutoStartup()) {
      // should we pre test connections before starting?
      if (getEndpoint().isTestConnectionOnStartup()) {
        testConnectionOnStartup();
      }
      startListenerContainer();
    }

    // mark as initialized for the first time
    initialized = true;
  }
Exemplo n.º 17
0
 @Override
 protected void doStop() throws Exception {
   getEndpoint().consumerStopped(this);
   super.doStop();
 }
Exemplo n.º 18
0
 @Override
 protected void doStart() throws Exception {
   super.doStart();
   ((ActivitiEndpoint) getEndpoint()).addConsumer(this);
 }
Exemplo n.º 19
0
 @Override
 protected void doShutdown() throws Exception {
   ServiceHelper.stopAndShutdownServices(scheduler);
   super.doShutdown();
 }
Exemplo n.º 20
0
 @Override
 public void resume() throws Exception {
   super.resume();
   doStart();
 }
Exemplo n.º 21
0
 @Override
 protected void doStop() throws Exception {
   getEndpoint().disconnect(this);
   super.doStop();
 }
Exemplo n.º 22
0
 @Override
 protected void doStart() throws Exception {
   super.doStart();
   getEndpoint().consumerStarted(this);
 }
Exemplo n.º 23
0
 @Override
 protected void doStop() throws Exception {
   genericWorker.setDisableServiceShutdownOnStop(true);
   genericWorker.shutdownNow();
   super.doStop();
 }
Exemplo n.º 24
0
 @Override
 protected void doStop() throws Exception {
   server.stop();
   super.doStop();
 }
Exemplo n.º 25
0
 /** Removes the notification listener */
 @Override
 protected void doStop() throws Exception {
   super.doStop();
   removeNotificationListener();
 }
Exemplo n.º 26
0
 @Override
 protected void doStart() throws Exception {
   ((QuickfixjEndpoint) getEndpoint()).ensureInitialized();
   super.doStart();
 }
Exemplo n.º 27
0
 @Override
 protected void doStop() throws Exception {
   endpoint.setActiveConsumer(null);
   super.doStop();
 }
Exemplo n.º 28
0
 @Override
 protected void doStart() throws Exception {
   super.doStart();
   endpoint.setActiveConsumer(this);
 }