• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ResourceAllocationException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testAddressIsBlockedForOtherProdudersWhenFull

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
@Test(timeout = 60000)
public void testAddressIsBlockedForOtherProdudersWhenFull() throws Exception {
   Connection connection = createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Destination d = session.createQueue(getQueueName());
   MessageProducer p = session.createProducer(d);

   fillAddress(getQueueName());

   Exception e = null;
   try {
      p.send(session.createBytesMessage());
   } catch (ResourceAllocationException rae) {
      e = rae;
   }
   assertTrue(e instanceof ResourceAllocationException);
   assertTrue(e.getMessage().contains("resource-limit-exceeded"));

   long addressSize = server.getPagingManager().getPageStore(new SimpleString(getQueueName())).getAddressSize();
   assertTrue(addressSize >= MAX_SIZE_BYTES_REJECT_THRESHOLD);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:AmqpFlowControlTest.java


示例2: convertToRuntimeException

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
public static JMSRuntimeException convertToRuntimeException(JMSException e) {
    if (e instanceof javax.jms.IllegalStateException) {
        return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidClientIDException) {
        return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidDestinationException) {
        return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidSelectorException) {
        return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof JMSSecurityException) {
        return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageFormatException) {
        return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageNotWriteableException) {
        return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof ResourceAllocationException) {
        return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionInProgressException) {
        return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionRolledBackException) {
        return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:34,代码来源:Utils.java


示例3: waitForSpace

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
protected final void waitForSpace(ConnectionContext context, ProducerBrokerExchange producerBrokerExchange, Usage<?> usage, int highWaterMark, String warning) throws IOException, InterruptedException, ResourceAllocationException {
    if (!context.isNetworkConnection() && systemUsage.isSendFailIfNoSpace()) {
        getLog().debug("sendFailIfNoSpace, forcing exception on send, usage: {}: {}", usage, warning);
        throw new ResourceAllocationException(warning);
    }
    if (!context.isNetworkConnection() && systemUsage.getSendFailIfNoSpaceAfterTimeout() != 0) {
        if (!usage.waitForSpace(systemUsage.getSendFailIfNoSpaceAfterTimeout(), highWaterMark)) {
            getLog().debug("sendFailIfNoSpaceAfterTimeout expired, forcing exception on send, usage: {}: {}", usage, warning);
            throw new ResourceAllocationException(warning);
        }
    } else {
        long start = System.currentTimeMillis();
        long nextWarn = start;
        producerBrokerExchange.blockingOnFlowControl(true);
        destinationStatistics.getBlockedSends().increment();
        while (!usage.waitForSpace(1000, highWaterMark)) {
            if (context.getStopping().get()) {
                throw new IOException("Connection closed, send aborted.");
            }

            long now = System.currentTimeMillis();
            if (now >= nextWarn) {
                getLog().info("{}: {} (blocking for: {}s)", new Object[]{ usage, warning, new Long(((now - start) / 1000))});
                nextWarn = now + blockedProducerWarningInterval;
            }
        }
        long finish = System.currentTimeMillis();
        long totalTimeBlocked = finish - start;
        destinationStatistics.getBlockedTime().addTime(totalTimeBlocked);
        producerBrokerExchange.incrementTimeBlocked(this,totalTimeBlocked);
        producerBrokerExchange.blockingOnFlowControl(false);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:34,代码来源:BaseDestination.java


示例4: run

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
@Override
public void run() {
    TimeoutMessage timeout;
    try {
        while (true) {
            timeout = flowControlTimeoutMessages.take();
            if (timeout != null) {
                synchronized (messagesWaitingForSpace) {
                    if (messagesWaitingForSpace.remove(timeout.message.getMessageId()) != null) {
                        ExceptionResponse response = new ExceptionResponse(
                                new ResourceAllocationException(
                                        "Usage Manager Memory Limit reached. Stopping producer ("
                                                + timeout.message.getProducerId()
                                                + ") to prevent flooding "
                                                + getActiveMQDestination().getQualifiedName()
                                                + "."
                                                + " See http://activemq.apache.org/producer-flow-control.html for more info"));
                        response.setCorrelationId(timeout.message.getCommandId());
                        timeout.context.getConnection().dispatchAsync(response);
                    }
                }
            }
        }
    } catch (InterruptedException e) {
        LOG.debug(getName() + "Producer Flow Control Timeout Task is stopping");
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:28,代码来源:Queue.java


示例5: getConnectionFactory

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
protected ConnectionFactory getConnectionFactory() throws Exception {
   factory.setExceptionListener(new ExceptionListener() {
      @Override
      public void onException(JMSException arg0) {
         if (arg0 instanceof ResourceAllocationException) {
            gotResourceException.set(true);
         }
      }
   });
   return factory;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:ProducerFlowControlSendFailTest.java


示例6: convertToRuntimeException

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
/**
 * Converts instances of sub-classes of {@link JMSException} into the corresponding sub-class of
 * {@link JMSRuntimeException}.
 *
 * @param e
 * @return
 */
public static JMSRuntimeException convertToRuntimeException(JMSException e) {
   if (e instanceof javax.jms.IllegalStateException) {
      return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof InvalidClientIDException) {
      return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof InvalidDestinationException) {
      return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof InvalidSelectorException) {
      return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof JMSSecurityException) {
      return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof MessageFormatException) {
      return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof MessageNotWriteableException) {
      return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof ResourceAllocationException) {
      return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof TransactionInProgressException) {
      return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof TransactionRolledBackException) {
      return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:41,代码来源:JmsExceptionUtils.java


示例7: testRemotelyCloseProducerWithSendWaitingForCredit

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
@Repeat(repetitions = 1)
@Test(timeout = 20000)
public void testRemotelyCloseProducerWithSendWaitingForCredit() throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
        Connection connection = testFixture.establishConnecton(testPeer);

        testPeer.expectBegin();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        // Expect producer creation, don't give it credit.
        testPeer.expectSenderAttachWithoutGrantingCredit();

        // Producer has no credit so the send should block waiting for it, then fail when the remote close occurs
        testPeer.remotelyDetachLastOpenedLinkOnLastOpenedSession(true, true, AmqpError.RESOURCE_LIMIT_EXCEEDED, "Producer closed", 50);
        testPeer.expectClose();

        Queue queue = session.createQueue("myQueue");
        final MessageProducer producer = session.createProducer(queue);

        Message message = session.createTextMessage("myMessage");

        try {
            producer.send(message);
            fail("Expected exception to be thrown due to close of producer");
        } catch (ResourceAllocationException rae) {
            // Expected if remote close beat the send to the provider
        } catch (IllegalStateException ise) {
            // Can happen if send fires before remote close if processed.
        }

        connection.close();

        testPeer.waitForAllHandlersToComplete(3000);
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:36,代码来源:ProducerIntegrationTest.java


示例8: toRuntimeException

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
public static JMSRuntimeException toRuntimeException(final JMSException e) {
    if (e instanceof javax.jms.IllegalStateException) {
        return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidClientIDException) {
        return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidDestinationException) {
        return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidSelectorException) {
        return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof JMSSecurityException) {
        return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageFormatException) {
        return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageNotWriteableException) {
        return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof ResourceAllocationException) {
        return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionInProgressException) {
        return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionRolledBackException) {
        return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
 
开发者ID:apache,项目名称:tomee,代码行数:34,代码来源:JMS2.java


示例9: testConvertsResourceAllocationExceptionToResourceAllocationRuntimeException

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
@Test(expected = ResourceAllocationRuntimeException.class)
public void testConvertsResourceAllocationExceptionToResourceAllocationRuntimeException() {
    throw JMSExceptionSupport.createRuntimeException(new ResourceAllocationException("error"));
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:5,代码来源:JMSExceptionSupportTest.java


示例10: testPublisherRecoverAfterBlockWithSyncSend

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
@Test
public void testPublisherRecoverAfterBlockWithSyncSend() throws Exception {
   ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) getConnectionFactory();
   factory.setExceptionListener(null);
   factory.setUseAsyncSend(false);
   this.flowControlConnection = (ActiveMQConnection) factory.createConnection();
   this.flowControlConnection.start();

   final Session session = this.flowControlConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
   final MessageProducer producer = session.createProducer(queueA);

   final AtomicBoolean keepGoing = new AtomicBoolean(true);
   final AtomicInteger exceptionCount = new AtomicInteger(0);
   Thread thread = new Thread("Filler") {
      @Override
      public void run() {
         while (keepGoing.get()) {
            try {
               producer.send(session.createTextMessage("Test message"));
            } catch (JMSException arg0) {
               if (arg0 instanceof ResourceAllocationException) {
                  gotResourceException.set(true);
                  exceptionCount.incrementAndGet();
               }
            }
         }
      }
   };
   thread.start();
   waitForBlockedOrResourceLimit(new AtomicBoolean(false));

   // resourceException on second message, resumption if we
   // can receive 10
   MessageConsumer consumer = session.createConsumer(queueA);
   TextMessage msg;
   for (int idx = 0; idx < 10; ++idx) {
      msg = (TextMessage) consumer.receive(1000);
      if (msg != null) {
         msg.acknowledge();
      }
   }
   assertTrue("we were blocked at least 5 times", 5 < exceptionCount.get());
   keepGoing.set(false);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:45,代码来源:ProducerFlowControlSendFailTest.java


示例11: testConvertsResourceAllocationExceptionToResourceAllocationRuntimeException

import javax.jms.ResourceAllocationException; //导入依赖的package包/类
@Test(expected = ResourceAllocationRuntimeException.class)
public void testConvertsResourceAllocationExceptionToResourceAllocationRuntimeException() {
    throw JmsExceptionSupport.createRuntimeException(new ResourceAllocationException("error"));
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:5,代码来源:JmsExceptionSupportTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MessageNotReadableException类代码示例发布时间:2022-05-23
下一篇:
Java BaseRefactoringAction类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap