コード例 #1
0
  /**
   * Used to refresh the service registry after the Application Context is initialized. This way any
   * services that were exported on startup will be available in the service registry once startup
   * is complete.
   */
  private void requeueMessages() {
    LOG.info("Refreshing Service Registry to export services to the bus.");
    KsbApiServiceLocator.getServiceBus().synchronizeLocalServices();

    // automatically requeue documents sitting with status of 'R'
    MessageFetcher messageFetcher = new MessageFetcher((Integer) null);
    KSBServiceLocator.getThreadPool().execute(messageFetcher);
  }
コード例 #2
0
 @Override
 protected void doAdditionalModuleStartLogic() throws Exception {
   // this allows us to become aware of remote services, in case the application needs to use any
   // of them during startup
   LOG.info("Synchronizing remote services with service bus after KSB startup...");
   long startTime = System.currentTimeMillis();
   KsbApiServiceLocator.getServiceBus().synchronizeRemoteServices();
   long endTime = System.currentTimeMillis();
   LOG.info(
       "...total time to synchronize remote services with service bus after KSB startup: "
           + (endTime - startTime));
 }
コード例 #3
0
 @Override
 public void start() throws Exception {
   if (serviceDefinitions != null && !serviceDefinitions.isEmpty()) {
     LOG.debug(
         "Configuring "
             + serviceDefinitions.size()
             + " services for application id "
             + CoreConfigHelper.getApplicationId()
             + " using config for classloader "
             + ClassLoaderUtils.getDefaultClassLoader());
     KsbApiServiceLocator.getServiceBus().publishServices(serviceDefinitions, true);
     super.start();
   }
 }
コード例 #4
0
  @Test
  public void testDelayedAsynchronousServiceCall() throws Exception {
    KSBTestUtils.setMessagingToAsync();

    QName serviceName = new QName("testAppsSharedQueue", "sharedQueue");

    // Queue up the service to be called asynchronously after 5 seconds
    KSBJavaService testJavaAsyncService =
        (KSBJavaService)
            KsbApiServiceLocator.getMessageHelper()
                .getServiceAsynchronously(serviceName, "context", "value1", "value2", 5000);
    testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));
    verifyServiceCalls(serviceName, false);

    // sleep for 1 second, should not have been called
    Thread.sleep(1000);
    verifyServiceCalls(serviceName, false);

    // sleep for 1 second, should not have been called
    Thread.sleep(1000);
    verifyServiceCalls(serviceName, false);

    // sleep for 1 second, should not have been called
    Thread.sleep(1000);
    verifyServiceCalls(serviceName, false);

    Thread.sleep(1000);
    verifyServiceCalls(serviceName, false);

    // TODO this isn't the best test ever because it's relying on waits and timing which is most
    // likely doomed to occasional
    // failure in the CI environment.  If this occurs than I may need to yank this.  A better long
    // term solution would be
    // to allow for the use of callbacks for delayed asynchronous services but that's not something
    // I wanted to try
    // to tackle at the moment

    // now sleep for 3 more seconds, the call should be invoked
    Thread.sleep(3000);
    verifyServiceCalls(serviceName, true);
  }