本文整理匯總了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);
}
示例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);
}
示例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());
}
示例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());
}
示例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();
}
}
示例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"));
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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());
}