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


Java UncategorizedJmsException类代码示例

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


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

示例1: send

import org.springframework.jms.UncategorizedJmsException; //导入依赖的package包/类
@Override
public void send(Destination destination, MessageCreator messageCreator) throws JmsException {
	
	Session innerSession = new InnerSession();
	
	try {
		Message message = (Message) messageCreator.createMessage(innerSession);
		
		if (message instanceof EmailMessage && !sendMailEnabled) return;
		
		if (message instanceof SingleEventMessage && !((InnerQueue) destination).contains(message)) {
			((InnerQueue) destination).addMessage(message);
		} else if (message instanceof SymbolEventsMessage) {
			((InnerQueue) destination).addMessage(message);
		} else {
			((InnerQueue) destination).addMessage(message);
		}
		
	} catch (JMSException e) {
		e.printStackTrace();
		throw new UncategorizedJmsException(e);
	}
	
	
}
 
开发者ID:premiummarkets,项目名称:pm,代码行数:26,代码来源:InnerJmsTemplate.java

示例2: testMultipleExceptions

import org.springframework.jms.UncategorizedJmsException; //导入依赖的package包/类
@Test
public void testMultipleExceptions() throws InterruptedException {
  republisher.start();

  Object publishedObject1 = new Object();
  CountDownLatch latch = new CountDownLatch(11);

  //republication succeeds
  publisher.publish(publishedObject1); // failure
  // should re-attempt publication every 100ms
  EasyMock.expectLastCall().andAnswer(() -> { latch.countDown(); throw new UncategorizedJmsException(""); }).times(10);

  publisher.publish(publishedObject1); // success
  EasyMock.expectLastCall().andAnswer(() -> { latch.countDown(); return null; });

  control.replay();

  republisher.publicationFailed(publishedObject1);

  //Thread.sleep(2000);
  latch.await();

  assertEquals(11, republisher.getNumberFailedPublications());
  assertEquals(0, republisher.getSizeUnpublishedList());

  control.verify();
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:28,代码来源:RepublisherImplTest.java

示例3: testMultiplePublicationsWithExceptions

import org.springframework.jms.UncategorizedJmsException; //导入依赖的package包/类
@Test
public void testMultiplePublicationsWithExceptions() throws InterruptedException {
  republisher.start();

  Object publishedObject1 = new Object();
  Object publishedObject2 = new Object();
  Object publishedObject3 = new Object();
  CountDownLatch latch = new CountDownLatch(18);

  //republication succeeds
  publisher.publish(publishedObject1); // failure
  // should re-attempt publication every 100ms
  EasyMock.expectLastCall().andAnswer(() -> { latch.countDown(); throw new UncategorizedJmsException(""); }).times(10);

  publisher.publish(publishedObject1); //success
  EasyMock.expectLastCall().andAnswer(() -> { latch.countDown(); return null; });

  publisher.publish(publishedObject2); //failure
  // should re-attempt publication every 100ms
  EasyMock.expectLastCall().andAnswer(() -> { latch.countDown(); throw new UncategorizedJmsException(""); }).times(5);

  publisher.publish(publishedObject2); //success
  EasyMock.expectLastCall().andAnswer(() -> { latch.countDown(); return null; });
  publisher.publish(publishedObject3); //success
  EasyMock.expectLastCall().andAnswer(() -> { latch.countDown(); return null; });

  control.replay();

  republisher.publicationFailed(publishedObject1);
  republisher.publicationFailed(publishedObject2);
  republisher.publicationFailed(publishedObject3);

  // Thread.sleep(2000);
  latch.await();

  assertEquals(11 + 6 + 1, republisher.getNumberFailedPublications());
  assertEquals(0, republisher.getSizeUnpublishedList());

  control.verify();
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:41,代码来源:RepublisherImplTest.java

示例4: testFailToPublish

import org.springframework.jms.UncategorizedJmsException; //导入依赖的package包/类
@Test
public void testFailToPublish() throws InterruptedException {
  republisher.start();

  Object publishedObject1 = new Object();
  Object publishedObject2 = new Object();
  Object publishedObject3 = new Object();

  publisher.publish(publishedObject1); //failure
  EasyMock.expectLastCall().andThrow(new UncategorizedJmsException("")).anyTimes();
  publisher.publish(publishedObject2); //failure
  EasyMock.expectLastCall().andThrow(new UncategorizedJmsException("")).anyTimes();
  publisher.publish(publishedObject3); //failure
  EasyMock.expectLastCall().andThrow(new UncategorizedJmsException("")).anyTimes();

  control.replay();

  republisher.publicationFailed(publishedObject1);
  republisher.publicationFailed(publishedObject2);
  republisher.publicationFailed(publishedObject3);

  Thread.sleep(1000);

  assertTrue(republisher.getNumberFailedPublications() > 0);
  assertEquals(3, republisher.getSizeUnpublishedList());

  control.verify();
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:29,代码来源:RepublisherImplTest.java

示例5: convertJmsAccessException

import org.springframework.jms.UncategorizedJmsException; //导入依赖的package包/类
/**
 * Convert the specified checked {@link javax.jms.JMSException JMSException} to a
 * Spring runtime {@link org.springframework.jms.JmsException JmsException} equivalent.
 * @param ex the original checked JMSException to convert
 * @return the Spring runtime JmsException wrapping the given exception
 */
public static JmsException convertJmsAccessException(JMSException ex) {
	Assert.notNull(ex, "JMSException must not be null");

	if (ex instanceof javax.jms.IllegalStateException) {
		return new org.springframework.jms.IllegalStateException((javax.jms.IllegalStateException) ex);
	}
	if (ex instanceof javax.jms.InvalidClientIDException) {
		return new InvalidClientIDException((javax.jms.InvalidClientIDException) ex);
	}
	if (ex instanceof javax.jms.InvalidDestinationException) {
		return new InvalidDestinationException((javax.jms.InvalidDestinationException) ex);
	}
	if (ex instanceof javax.jms.InvalidSelectorException) {
		return new InvalidSelectorException((javax.jms.InvalidSelectorException) ex);
	}
	if (ex instanceof javax.jms.JMSSecurityException) {
		return new JmsSecurityException((javax.jms.JMSSecurityException) ex);
	}
	if (ex instanceof javax.jms.MessageEOFException) {
		return new MessageEOFException((javax.jms.MessageEOFException) ex);
	}
	if (ex instanceof javax.jms.MessageFormatException) {
		return new MessageFormatException((javax.jms.MessageFormatException) ex);
	}
	if (ex instanceof javax.jms.MessageNotReadableException) {
		return new MessageNotReadableException((javax.jms.MessageNotReadableException) ex);
	}
	if (ex instanceof javax.jms.MessageNotWriteableException) {
		return new MessageNotWriteableException((javax.jms.MessageNotWriteableException) ex);
	}
	if (ex instanceof javax.jms.ResourceAllocationException) {
		return new ResourceAllocationException((javax.jms.ResourceAllocationException) ex);
	}
	if (ex instanceof javax.jms.TransactionInProgressException) {
		return new TransactionInProgressException((javax.jms.TransactionInProgressException) ex);
	}
	if (ex instanceof javax.jms.TransactionRolledBackException) {
		return new TransactionRolledBackException((javax.jms.TransactionRolledBackException) ex);
	}

	// fallback
	return new UncategorizedJmsException(ex);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:50,代码来源:JmsUtils.java

示例6: testUncategorizedJmsException

import org.springframework.jms.UncategorizedJmsException; //导入依赖的package包/类
@Test
public void testUncategorizedJmsException() throws Exception {
	doTestJmsException(new javax.jms.JMSException(""), UncategorizedJmsException.class);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:JmsTemplateTests.java

示例7: testSingleRepublicationAfterException

import org.springframework.jms.UncategorizedJmsException; //导入依赖的package包/类
/**
 * Test republication if publisher throws 1 exception.
 * @throws InterruptedException
 */
@Test
public void testSingleRepublicationAfterException() throws InterruptedException {
  republisher.start();

  Object publishedObject = new Object();

  //re-publication fails
  publisher.publish(publishedObject);
  EasyMock.expectLastCall().andThrow(new UncategorizedJmsException(""));

  //second succeeds
  publisher.publish(publishedObject);

  control.replay();

  republisher.publicationFailed(publishedObject);

  Thread.sleep(500);

  assertEquals(2, republisher.getNumberFailedPublications()); //manual call + automatic publication
  assertEquals(0, republisher.getSizeUnpublishedList());

  control.verify();
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:29,代码来源:RepublisherImplTest.java


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