本文整理汇总了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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例6: testUncategorizedJmsException
import org.springframework.jms.UncategorizedJmsException; //导入依赖的package包/类
@Test
public void testUncategorizedJmsException() throws Exception {
doTestJmsException(new javax.jms.JMSException(""), UncategorizedJmsException.class);
}
示例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();
}