当前位置: 首页>>代码示例>>Java>>正文


Java KSBJavaService类代码示例

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


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

示例1: testCallingQueueAsnyc

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test
   public void testCallingQueueAsnyc() throws Exception {

KSBTestUtils.setMessagingToAsync();
QName serviceName = new QName("testAppsSharedQueue", "sharedQueue");
String contextObject = "my_context_object";
SimpleCallback callback = new SimpleCallback();

	KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, callback, contextObject);
    
synchronized (callback) {
    testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));
    callback.waitForAsyncCall();
}

Object contextAfterMessaging = callback.getMethodCall().getContext();
assertEquals(contextObject, contextAfterMessaging);
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:ContextObjectMessagingTest.java

示例2: testCallingAsyncTopics

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test
   public void testCallingAsyncTopics() throws Exception {
KSBTestUtils.setMessagingToAsync();
QName serviceName = new QName("testAppsSharedTopic", "sharedTopic");

SimpleCallback callback = new SimpleCallback();
String contextObject = "my_context_object";
	KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, callback, contextObject);

synchronized (callback) {
    testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));
    callback.waitForAsyncCall();    
}

Object contextAfterMessaging = callback.getMethodCall().getContext();
assertEquals(contextObject, contextAfterMessaging);
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:ContextObjectMessagingTest.java

示例3: testMessageSentOnCommittedTransaction

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test
   public void testMessageSentOnCommittedTransaction() throws Exception {
KSBTestUtils.setMessagingToAsync();

KSBServiceLocator.getTransactionTemplate().execute(new TransactionCallback<Object>() {
    public Object doInTransaction(TransactionStatus status) {

	QName serviceName = new QName("testAppsSharedQueue", "sharedQueue");
	KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper()
		.getServiceAsynchronously(serviceName);
	testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));

	// this is a sanity check that we haven't sent the message before the trans is committed. dont remove this
               // line.
	assertFalse(MessageSendingTransactionSynchronization.CALLED_TRANS_COMMITTED.get());
	return null;
    }
});

assertTrue("Message not sent transactionallY", MessageSendingTransactionSynchronization.CALLED_TRANS_COMMITTED.get());

   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:TransactionMessagingTest.java

示例4: testMessageNotSentOnRolledBackTransaction

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test
   public void testMessageNotSentOnRolledBackTransaction() throws Exception {
KSBTestUtils.setMessagingToAsync();

KSBServiceLocator.getTransactionTemplate().execute(new TransactionCallback<Object>() {
    public Object doInTransaction(TransactionStatus status) {

	QName serviceName = new QName("testAppsSharedQueue", "sharedQueue");
	KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper()
		.getServiceAsynchronously(serviceName);
	testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));

	status.setRollbackOnly();
	// this is a sanity check that we haven't sent the message before the trans is committed. dont remove this
               // line.
	assertFalse(MessageSendingTransactionSynchronization.CALLED_TRANS_ROLLEDBACKED.get());
	return null;
    }
});

assertFalse("Message not sent transactionallY", MessageSendingTransactionSynchronization.CALLED_TRANS_COMMITTED.get());
assertTrue("Message not sent transactionallY", MessageSendingTransactionSynchronization.CALLED_TRANS_ROLLEDBACKED.get());

   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:TransactionMessagingTest.java

示例5: testCallingQueueAsnyc

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test
public void testCallingQueueAsnyc() throws Exception {
    KSBTestUtils.setMessagingToAsync();
    // Execute this 100 times, previously when only running a single iteration, this test would pass most of the
    // time but then would occasionally fail, it was possible to reproduce the failure every time by adding
    // these iterations, this allowed us to fix the underlying problem (an issue with KSB callbacks)
    for (int i = 0; i < 100; i++) {
        LOG.info("testCallingQueueAsnyc, iteration: " + i);
        QName serviceName = new QName("testAppsSharedQueue", "sharedQueue");
        SimpleCallback callback = new SimpleCallback();
        KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, callback);
        synchronized (callback) {
            testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));
            callback.waitForAsyncCall();
        }
        verifyServiceCalls(serviceName);
        KSBServiceLocator.getBAMService().clearBAMTables();
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:20,代码来源:DistributedQueueTest.java

示例6: testToStringOnService

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
/**
   * This test ensures that doing a toString on a service proxy does not cause infinite loop problems along the lines
   * as reported in https://jira.kuali.org/browse/KULRICE-6708
   */
  @Test
  public void testToStringOnService() {
      KSBTestUtils.setMessagingToAsync();
QName serviceName = new QName("TestCl1", "testJavaAsyncService");
SimpleCallback callback = new SimpleCallback();
   KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, callback);
      String toStringValue = testJavaAsyncService.toString();
      System.out.println("toString value on async service: " + toStringValue);
      assertTrue("toString should have started with 'Service call proxy' but was instead: " + toStringValue, toStringValue.startsWith("Service call proxy"));
  }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:15,代码来源:SimpleServiceCallTest.java

示例7: testAsyncJavaCall

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test
   public void testAsyncJavaCall() throws Exception {
    KSBTestUtils.setMessagingToAsync();
	
	QName serviceName = new QName("TestCl1", "testJavaAsyncService");
	SimpleCallback callback = new SimpleCallback();
KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper()
	.getServiceAsynchronously(serviceName, callback);
    synchronized (callback) {
        testJavaAsyncService.invoke(new MessagingTestObject("message content"));
        callback.waitForAsyncCall();
    }
	verifyServiceCalls(serviceName);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:15,代码来源:SimpleServiceCallTest.java

示例8: testSuccessfullyCallingSyncTopics

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test
public void testSuccessfullyCallingSyncTopics() throws Exception {
	
	KsbApiServiceLocator.getServiceBus().synchronize();
	QName serviceName = new QName("testAppsSharedTopic", "sharedTopic");
	
	KSBJavaService testJavaAsyncService = KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName);
	testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));
	
	assertTrue("Test harness topic never called", (ServiceCallInformationHolder.flags.get("TestHarnessCalled")).booleanValue());
	assertTrue("Client1 app topic never called", (ServiceCallInformationHolder.flags.get("Client1Called")).booleanValue());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:13,代码来源:DistributedTopicTest.java

示例9: testCallingAsyncTopics

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test public void testCallingAsyncTopics() throws Exception {
    	KSBTestUtils.setMessagingToAsync();
	
	QName serviceName = new QName("testAppsSharedTopic", "sharedTopic");
	
	SimpleCallback simpleCallback = new SimpleCallback();
	KSBJavaService testJavaAsyncService = KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, simpleCallback);
	synchronized (simpleCallback) {
	    testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));
	    simpleCallback.waitForAsyncCall();
	}
	//because topic invocation doesn't happen in the message service invoker like it should this wait is really on half the answer.  We need to wait long and poll 
	//to determine if the client1 has been called.
	
	int i = 0;
	while (i < 100) {
	    if (ServiceCallInformationHolder.flags.get("Client1Called") != null) {
		break;
	    }
	    Thread.sleep(1000);
	    i++;
	}

	assertTrue("Test harness topic never called", (ServiceCallInformationHolder.flags.get("TestHarnessCalled")).booleanValue());
	assertTrue("Client1 app topic never called", (ServiceCallInformationHolder.flags.get("Client1Called"))
               .booleanValue());

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:DistributedTopicTest.java

示例10: testDelayedAsynchronousServiceCall

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@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);

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:36,代码来源:DelayedAsynchronousServiceTest.java

示例11: testSuccessfullyCallingQueueOnce

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
/**
 * If calling a queue with multiple subscribers only one subscriber should be called.
 * 
 * @throws Exception
 */
@Test
public void testSuccessfullyCallingQueueOnce() throws Exception {
    QName serviceName = new QName("testAppsSharedQueue", "sharedQueue");
    KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName);
    testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));
    verifyServiceCalls(serviceName);

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:14,代码来源:DistributedQueueTest.java

示例12: testTimeToLive

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
/**
 * test that service is in queue marked 'E' when the time to live is expired.
 * @throws Exception
 */
@Test public void testTimeToLive() throws Exception {

	KSBJavaService explodingQueue = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(this.queueTimeToLiveServiceName);
	explodingQueue.invoke("");
	TestUtilities.waitForExceptionRouting();
	//this service is on a 3 second wait the queue is on a 1 sec.
	Thread.sleep(10000);

	//verify the entry is in exception routing
	List<PersistedMessageBO> messagesQueued = KSBServiceLocator.getMessageQueueService().findByServiceName(this.queueTimeToLiveServiceName, "invoke");
	PersistedMessageBO message = messagesQueued.get(0);
	assertEquals("Message should be in exception status", KSBConstants.ROUTE_QUEUE_EXCEPTION, message.getQueueStatus());
	assertTrue("Message expiration date should be equal to or earlier than last queue date", message.getExpirationDate().getTime() <= message.getQueueDate().getTime());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:ExceptionMessagingTest.java

示例13: testCallingQueueAsnyc

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test public void testCallingQueueAsnyc() throws Exception {
    KSBTestUtils.setMessagingToAsync();
    ConfigContext.getCurrentContextConfig().putProperty(KSBConstants.Config.MESSAGING_OFF, "true");

    QName serviceName = QName.valueOf("{testAppsSharedTopic}sharedTopic");
    String value1 = "value1";
    String value2 = "value2";
    KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, null, null, value1, value2);
    testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));

    PersistedMessageBO message = KSBServiceLocator.getMessageQueueService().getNextDocuments(null).get(0);
    assertEquals("value1 incorrectly saved", value1, message.getValue1());
    assertEquals("value2 incorrectly saved", value2, message.getValue2());
	
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:16,代码来源:Value1AndValue2PersistedOnMessageCallTest.java

示例14: testStartTheBus

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test
public void testStartTheBus() {
	QName serviceName = new QName("TestCl1", "testJavaAsyncService");
	
	KsbApiServiceLocator.getServiceBus().synchronize();
	
	KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName);
	testJavaAsyncService.invoke(new MessagingTestObject("message content"));
	
	// verifyServiceCalls(serviceName);
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:12,代码来源:StartBusTest.java

示例15: testSuccessfullyCallingSyncTopics

import org.kuali.rice.ksb.messaging.service.KSBJavaService; //导入依赖的package包/类
@Test
public void testSuccessfullyCallingSyncTopics() throws Exception {
	
	KsbApiServiceLocator.getServiceBus().synchronize();
	QName serviceName = new QName("testAppsSharedTopic", "sharedTopic");
	
	KSBJavaService testJavaAsyncService = (KSBJavaService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName);
	testJavaAsyncService.invoke(new ClientAppServiceSharedPayloadObj("message content", false));
	
	assertTrue("Test harness topic never called", ((Boolean)ServiceCallInformationHolder.stuff.get("TestHarnessCalled")).booleanValue());
	assertTrue("Client1 app topic never called", ((Boolean)ServiceCallInformationHolder.stuff.get("Client1Called")).booleanValue());
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:13,代码来源:DistributedTopicTest.java


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