java set region_Java Message.setRegionDestination方法代码示例

import org.apache.activemq.command.Message; //导入方法依赖的package包/类

/**

* do send the message - this needs to be synchronized to ensure messages

* are stored AND dispatched in the right order

*

* @param producerExchange

* @param message

* @throws IOException

* @throws Exception

*/

synchronized void doMessageSend(final ProducerBrokerExchange producerExchange, final Message message)

throws IOException, Exception {

final ConnectionContext context = producerExchange.getConnectionContext();

message.setRegionDestination(this);

message.getMessageId().setBrokerSequenceId(getDestinationSequenceId());

Future result = null;

if (topicStore != null && message.isPersistent() && !canOptimizeOutPersistence()) {

if (systemUsage.getStoreUsage().isFull(getStoreUsageHighWaterMark())) {

final String logMessage = "Persistent store is Full, " + getStoreUsageHighWaterMark() + "% of "

+ systemUsage.getStoreUsage().getLimit() + ". Stopping producer (" + message.getProducerId()

+ ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "."

+ " See http://activemq.apache.org/producer-flow-control.html for more info";

if (!context.isNetworkConnection() && systemUsage.isSendFailIfNoSpace()) {

throw new javax.jms.ResourceAllocationException(logMessage);

}

waitForSpace(context,producerExchange, systemUsage.getStoreUsage(), getStoreUsageHighWaterMark(), logMessage);

}

result = topicStore.asyncAddTopicMessage(context, message,isOptimizeStorage());

}

message.incrementReferenceCount();

if (context.isInTransaction()) {

context.getTransaction().addSynchronization(new Synchronization() {

@Override

public void afterCommit() throws Exception {

// It could take while before we receive the commit

// operation.. by that time the message could have

// expired..

if (broker.isExpired(message)) {

getDestinationStatistics().getExpired().increment();

broker.messageExpired(context, message, null);

message.decrementReferenceCount();

return;

}

try {

dispatch(context, message);

} finally {

message.decrementReferenceCount();

}

}

});

} else {

try {

dispatch(context, message);

} finally {

message.decrementReferenceCount();

}

}

if (result != null && !result.isCancelled()) {

try {

result.get();

} catch (CancellationException e) {

// ignore - the task has been cancelled if the message

// has already been deleted

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值