本文整理汇总了Java中javax.jms.JMSRuntimeException类的典型用法代码示例。如果您正苦于以下问题:Java JMSRuntimeException类的具体用法?Java JMSRuntimeException怎么用?Java JMSRuntimeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JMSRuntimeException类属于javax.jms包,在下文中一共展示了JMSRuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commit
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
/**
* Commits the current transaction. If the current transaction contains a message that could not
* be processed, the transaction is "in peril" and is rolled back instead to avoid data loss.
*
* @throws RetriableException Operation failed, but connector should continue to retry.
* @throws ConnectException Operation failed and connector should stop.
*/
public void commit() throws ConnectException, RetriableException {
connectInternal();
try {
if (inflight) {
inflight = false;
if (inperil) {
inperil = false;
log.trace("Rolling back in-flight transaction");
jmsCtxt.rollback();
throw new RetriableException("Transaction rolled back");
}
else {
jmsCtxt.commit();
}
}
}
catch (JMSRuntimeException jmse) {
log.debug("JMS exception {}", jmse);
handleException(jmse);
}
}
示例2: createContext
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Override
public JMSContext createContext(String username, String password, int sessionMode) {
if (stopped.get()) {
LOG.debug("JmsPoolConnectionFactory is stopped, skip create new connection.");
return null;
}
if (!jmsContextSupported) {
throw new JMSRuntimeException("Configured ConnectionFactory is not JMS 2+ capable");
}
if (isUseProviderJMSContext()) {
return createProviderContext(username, password, sessionMode);
} else {
try {
return newPooledConnectionContext(createJmsPoolConnection(username, password), sessionMode);
} catch (JMSException e) {
throw JMSExceptionSupport.createRuntimeException(e);
}
}
}
示例3: testCreateJMSProducer
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testCreateJMSProducer() throws JMSException {
JmsPoolJMSProducer producer = (JmsPoolJMSProducer) context.createProducer();
assertNotNull(producer);
MockJMSMessageProducer mockProducer = (MockJMSMessageProducer) producer.getMessageProducer();
assertNotNull(mockProducer);
// JMSProducer instances are always anonymous producers.
assertNull(mockProducer.getDestination());
context.close();
try {
producer.getMessageProducer();
fail("should throw on closed context.");
} catch (JMSRuntimeException jmsre) {}
}
示例4: testRun
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Test(timeout = 60000)
public void testRun() throws Exception {
JmsPoolConnection connection = (JmsPoolConnection) cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
try {
session.run();
fail("Session should be unable to run outside EE.");
} catch (JMSRuntimeException jmsre) {}
session.close();
try {
session.run();
fail("Session should be closed.");
} catch (IllegalStateRuntimeException isre) {}
}
示例5: testStartStopConnection
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Test(timeout = 30000)
public void testStartStopConnection() throws JMSException {
JmsPoolJMSContext context = (JmsPoolJMSContext) cf.createContext();
context.setAutoStart(false);
assertNotNull(context.createConsumer(context.createQueue(getTestName())));
MockJMSConnection connection = (MockJMSConnection) context.getConnection();
assertFalse(connection.isStarted());
context.start();
assertTrue(connection.isStarted());
// We cannot stop a JMS Connection from the pool as it is a shared resource.
context.stop();
assertTrue(connection.isStarted());
context.close();
try {
context.stop();
fail("Cannot call stop on a closed context.");
} catch (JMSRuntimeException jmsre) {}
}
示例6: close
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
/**
* Closes the connection.
*/
public void close() {
try {
inflight = false;
connected = false;
if (jmsCtxt != null) {
jmsCtxt.close();
}
}
catch (JMSRuntimeException jmse) {
;
}
finally
{
jmsCtxt = null;
}
}
示例7: connectInternal
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
/**
* Internal method to connect to MQ.
*
* @throws RetriableException Operation failed, but connector should continue to retry.
* @throws ConnectException Operation failed and connector should stop.
*/
private void connectInternal() throws ConnectException, RetriableException {
if (connected) {
return;
}
try {
if (userName != null) {
jmsCtxt = mqConnFactory.createContext(userName, password, JMSContext.SESSION_TRANSACTED);
}
else {
jmsCtxt = mqConnFactory.createContext(JMSContext.SESSION_TRANSACTED);
}
jmsProd = jmsCtxt.createProducer();
jmsProd.setDeliveryMode(deliveryMode);
jmsProd.setTimeToLive(timeToLive);
connected = true;
}
catch (JMSRuntimeException jmse) {
log.debug("JMS exception {}", jmse);
handleException(jmse);
}
}
示例8: connectInternal
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
/**
* Internal method to connect to MQ.
*
* @throws RetriableException Operation failed, but connector should continue to retry.
* @throws ConnectException Operation failed and connector should stop.
*/
private void connectInternal() throws ConnectException, RetriableException {
if (connected) {
return;
}
if (closeNow.get()) {
throw new ConnectException("Connection closing");
}
try {
if (userName != null) {
jmsCtxt = mqConnFactory.createContext(userName, password, JMSContext.SESSION_TRANSACTED);
}
else {
jmsCtxt = mqConnFactory.createContext(JMSContext.SESSION_TRANSACTED);
}
jmsCons = jmsCtxt.createConsumer(queue);
connected = true;
}
catch (JMSRuntimeException jmse) {
log.debug("JMS exception {}", jmse);
handleException(jmse);
}
}
示例9: closeInternal
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
/**
* Internal method to close the connection.
*/
private void closeInternal() {
try {
inflight = false;
inperil = false;
connected = false;
if (jmsCtxt != null) {
jmsCtxt.close();
}
}
catch (JMSRuntimeException jmse) {
;
}
finally
{
jmsCtxt = null;
}
}
示例10: testGetAnotherContextFromIt
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Test
public void testGetAnotherContextFromIt() {
JMSContext c2 = context.createContext(Session.DUPS_OK_ACKNOWLEDGE);
Assert.assertNotNull(c2);
Assert.assertEquals(Session.DUPS_OK_ACKNOWLEDGE, c2.getSessionMode());
Message m2 = c2.createMessage();
Assert.assertNotNull(m2);
c2.close(); // should close its session, but not its (shared) connection
try {
c2.createMessage();
Assert.fail("session should be closed...");
} catch (JMSRuntimeException expected) {
// expected
}
Message m1 = context.createMessage();
Assert.assertNotNull("connection must be open", m1);
}
示例11: sharedNonDurableSubOnDifferentSelector
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Test
public void sharedNonDurableSubOnDifferentSelector() throws Exception {
context = cf.createContext();
try {
context.createSharedConsumer(topic1, "mySharedCon", "sel = 'sel1'");
try {
context.createSharedConsumer(topic1, "mySharedCon", "sel = 'sel2'");
fail("expected JMSRuntimeException");
} catch (JMSRuntimeException jmse) {
//pass
} catch (Exception e) {
fail("threw wrong exception expected JMSRuntimeException got " + e);
}
} finally {
context.close();
}
}
示例12: sharedNonDurableSubOnDifferentSelectorSrcFilterNull
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Test
public void sharedNonDurableSubOnDifferentSelectorSrcFilterNull() throws Exception {
context = cf.createContext();
try {
context.createSharedConsumer(topic1, "mySharedCon");
try {
context.createSharedConsumer(topic1, "mySharedCon", "sel = 'sel2'");
fail("expected JMSRuntimeException");
} catch (JMSRuntimeException jmse) {
//pass
} catch (Exception e) {
fail("threw wrong exception expected JMSRuntimeException got " + e);
}
} finally {
context.close();
}
}
示例13: sharedNonDurableSubOnDifferentSelectorTargetFilterNull
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Test
public void sharedNonDurableSubOnDifferentSelectorTargetFilterNull() throws Exception {
context = cf.createContext();
try {
context.createSharedConsumer(topic1, "mySharedCon", "sel = 'sel1'");
try {
context.createSharedConsumer(topic1, "mySharedCon");
fail("expected JMSRuntimeException");
} catch (JMSRuntimeException jmse) {
//pass
} catch (Exception e) {
fail("threw wrong exception expected JMSRuntimeException got " + e);
}
} finally {
context.close();
}
}
示例14: sharedDurableSubOnDifferentTopic
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Test
public void sharedDurableSubOnDifferentTopic() throws Exception {
context = cf.createContext();
try {
context.createSharedDurableConsumer(topic1, "mySharedCon");
try {
context.createSharedDurableConsumer(topic2, "mySharedCon");
fail("expected JMSRuntimeException");
} catch (JMSRuntimeException jmse) {
//pass
} catch (Exception e) {
fail("threw wrong exception expected JMSRuntimeException got " + e);
}
} finally {
context.close();
}
}
示例15: sharedDurableSubOnDifferentSelector
import javax.jms.JMSRuntimeException; //导入依赖的package包/类
@Test
public void sharedDurableSubOnDifferentSelector() throws Exception {
context = cf.createContext();
try {
context.createSharedDurableConsumer(topic1, "mySharedCon", "sel = 'sel1'");
try {
context.createSharedDurableConsumer(topic1, "mySharedCon", "sel = 'sel2'");
fail("expected JMSRuntimeException");
} catch (JMSRuntimeException jmse) {
//pass
} catch (Exception e) {
fail("threw wrong exception expected JMSRuntimeException got " + e);
}
} finally {
context.close();
}
}