本文整理汇总了Java中com.alibaba.rocketmq.client.VirtualEnvUtil类的典型用法代码示例。如果您正苦于以下问题:Java VirtualEnvUtil类的具体用法?Java VirtualEnvUtil怎么用?Java VirtualEnvUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VirtualEnvUtil类属于com.alibaba.rocketmq.client包,在下文中一共展示了VirtualEnvUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateConsumerOffsetOneway
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
/**
* 更新Consumer消费进度
*
* @throws InterruptedException
* @throws RemotingSendRequestException
* @throws RemotingTimeoutException
* @throws RemotingTooMuchRequestException
*
* @throws RemotingConnectException
*/
public void updateConsumerOffsetOneway(//
final String addr,//
final UpdateConsumerOffsetRequestHeader requestHeader,//
final long timeoutMillis//
) throws RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException,
RemotingSendRequestException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
requestHeader.setConsumerGroup(VirtualEnvUtil.buildWithProjectGroup(
requestHeader.getConsumerGroup(), projectGroupPrefix));
requestHeader.setTopic(VirtualEnvUtil.buildWithProjectGroup(requestHeader.getTopic(),
projectGroupPrefix));
}
RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONSUMER_OFFSET, requestHeader);
this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
示例2: endTransactionOneway
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
/**
* 提交或者回滚事务
*/
public void endTransactionOneway(//
final String addr,//
final EndTransactionRequestHeader requestHeader,//
final String remark,//
final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
requestHeader.setProducerGroup(VirtualEnvUtil.buildWithProjectGroup(
requestHeader.getProducerGroup(), projectGroupPrefix));
}
RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.END_TRANSACTION, requestHeader);
request.setRemark(remark);
this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
示例3: queryMessage
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
/**
* 查询消息
*/
public void queryMessage(//
final String addr,//
final QueryMessageRequestHeader requestHeader,//
final long timeoutMillis,//
final InvokeCallback invokeCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
requestHeader.setTopic(VirtualEnvUtil.buildWithProjectGroup(requestHeader.getTopic(),
projectGroupPrefix));
}
RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.QUERY_MESSAGE, requestHeader);
this.remotingClient.invokeAsync(addr, request, timeoutMillis, invokeCallback);
}
示例4: updateConsumerOffsetOneway
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
/**
* 更新Consumer消费进度
*
* @throws InterruptedException
* @throws RemotingSendRequestException
* @throws RemotingTimeoutException
* @throws RemotingTooMuchRequestException
*
* @throws RemotingConnectException
*/
public void updateConsumerOffsetOneway(//
final String addr,//
final UpdateConsumerOffsetRequestHeader requestHeader,//
final long timeoutMillis//
) throws RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException,
RemotingSendRequestException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
requestHeader.setConsumerGroup(VirtualEnvUtil.buildWithProjectGroup(
requestHeader.getConsumerGroup(), projectGroupPrefix));
requestHeader.setTopic(VirtualEnvUtil.buildWithProjectGroup(requestHeader.getTopic(),
projectGroupPrefix));
}
RemotingCommand request =
RemotingCommand.createRequestCommand(MQRequestCode.UPDATE_CONSUMER_OFFSET_VALUE,
requestHeader);
this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
示例5: endTransactionOneway
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
/**
* 提交或者回滚事务
*/
public void endTransactionOneway(//
final String addr,//
final EndTransactionRequestHeader requestHeader,//
final String remark,//
final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
requestHeader.setProducerGroup(VirtualEnvUtil.buildWithProjectGroup(
requestHeader.getProducerGroup(), projectGroupPrefix));
}
RemotingCommand request =
RemotingCommand.createRequestCommand(MQRequestCode.END_TRANSACTION_VALUE, requestHeader);
request.setRemark(remark);
this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
示例6: queryMessage
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
/**
* 查询消息
*/
public void queryMessage(//
final String addr,//
final QueryMessageRequestHeader requestHeader,//
final long timeoutMillis,//
final InvokeCallback invokeCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
requestHeader.setTopic(VirtualEnvUtil.buildWithProjectGroup(requestHeader.getTopic(),
projectGroupPrefix));
}
RemotingCommand request =
RemotingCommand.createRequestCommand(MQRequestCode.QUERY_MESSAGE_VALUE, requestHeader);
this.remotingClient.invokeAsync(addr, request, timeoutMillis, invokeCallback);
}
示例7: registerClient
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
public boolean registerClient(final String addr, final HeartbeatData heartbeat, final long timeoutMillis)
throws RemotingException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
Set<ConsumerData> consumerDatas = heartbeat.getConsumerDataSet();
for (ConsumerData consumerData : consumerDatas) {
consumerData.setGroupName(VirtualEnvUtil.buildWithProjectGroup(consumerData.getGroupName(),
projectGroupPrefix));
Set<SubscriptionData> subscriptionDatas = consumerData.getSubscriptionDataSet();
for (SubscriptionData subscriptionData : subscriptionDatas) {
subscriptionData.setTopic(VirtualEnvUtil.buildWithProjectGroup(
subscriptionData.getTopic(), projectGroupPrefix));
}
}
Set<ProducerData> producerDatas = heartbeat.getProducerDataSet();
for (ProducerData producerData : producerDatas) {
producerData.setGroupName(VirtualEnvUtil.buildWithProjectGroup(producerData.getGroupName(),
projectGroupPrefix));
}
}
RemotingCommand request = RemotingCommand.createRequestCommand(MQRequestCode.HEART_BEAT_VALUE, null);
request.setBody(heartbeat.encode());
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
return response.getCode() == ResponseCode.SUCCESS_VALUE;
}
示例8: SendResult
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
public SendResult(SendStatus sendStatus, String msgId, MessageQueue messageQueue, long queueOffset,
String projectGroupPrefix) {
this.sendStatus = sendStatus;
this.msgId = msgId;
this.messageQueue = messageQueue;
this.queueOffset = queueOffset;
// 清除虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
this.messageQueue.setTopic(VirtualEnvUtil.clearProjectGroup(this.messageQueue.getTopic(),
projectGroupPrefix));
}
}
示例9: registerClient
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
public boolean registerClient(final String addr, final HeartbeatData heartbeat, final long timeoutMillis)
throws RemotingException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
Set<ConsumerData> consumerDatas = heartbeat.getConsumerDataSet();
for (ConsumerData consumerData : consumerDatas) {
consumerData.setGroupName(VirtualEnvUtil.buildWithProjectGroup(consumerData.getGroupName(),
projectGroupPrefix));
Set<SubscriptionData> subscriptionDatas = consumerData.getSubscriptionDataSet();
for (SubscriptionData subscriptionData : subscriptionDatas) {
subscriptionData.setTopic(VirtualEnvUtil.buildWithProjectGroup(
subscriptionData.getTopic(), projectGroupPrefix));
}
}
Set<ProducerData> producerDatas = heartbeat.getProducerDataSet();
for (ProducerData producerData : producerDatas) {
producerData.setGroupName(VirtualEnvUtil.buildWithProjectGroup(producerData.getGroupName(),
projectGroupPrefix));
}
}
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);
request.setBody(heartbeat.encode());
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
return response.getCode() == ResponseCode.SUCCESS;
}
示例10: unlockBatchMQ
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
public void unlockBatchMQ(//
final String addr,//
final UnlockBatchRequestBody requestBody,//
final long timeoutMillis,//
final boolean oneway//
) throws RemotingException, MQBrokerException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
requestBody.setConsumerGroup(VirtualEnvUtil.buildWithProjectGroup(requestBody.getConsumerGroup(),
projectGroupPrefix));
Set<MessageQueue> messageQueues = requestBody.getMqSet();
for (MessageQueue messageQueue : messageQueues) {
messageQueue.setTopic(VirtualEnvUtil.buildWithProjectGroup(messageQueue.getTopic(),
projectGroupPrefix));
}
}
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNLOCK_BATCH_MQ, null);
request.setBody(requestBody.encode());
if (oneway) {
this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
else {
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return;
}
default:
break;
}
throw new MQBrokerException(response.getCode(), response.getRemark());
}
}
示例11: getTopicStatsInfo
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis)
throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
RemotingConnectException, MQBrokerException {
// 添加虚拟运行环境相关的projectGroupPrefix
String topicWithProjectGroup = topic;
if (!UtilAll.isBlank(projectGroupPrefix)) {
topicWithProjectGroup = VirtualEnvUtil.buildWithProjectGroup(topic, projectGroupPrefix);
}
GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
requestHeader.setTopic(topicWithProjectGroup);
RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
TopicStatsTable topicStatsTable =
TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
// 清除虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
HashMap<MessageQueue, TopicOffset> newTopicOffsetMap =
new HashMap<MessageQueue, TopicOffset>();
for (Map.Entry<MessageQueue, TopicOffset> messageQueue : topicStatsTable.getOffsetTable()
.entrySet()) {
MessageQueue key = messageQueue.getKey();
key.setTopic(VirtualEnvUtil.clearProjectGroup(key.getTopic(), projectGroupPrefix));
newTopicOffsetMap.put(key, messageQueue.getValue());
}
topicStatsTable.setOffsetTable(newTopicOffsetMap);
}
return topicStatsTable;
}
default:
break;
}
throw new MQBrokerException(response.getCode(), response.getRemark());
}
示例12: getProducerConnectionList
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
/**
* 根据ProducerGroup获取Producer连接列表
*/
public ProducerConnection getProducerConnectionList(final String addr, final String producerGroup,
final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, InterruptedException, MQBrokerException {
// 添加虚拟运行环境相关的projectGroupPrefix
String producerGroupWithProjectGroup = producerGroup;
if (!UtilAll.isBlank(projectGroupPrefix)) {
producerGroupWithProjectGroup =
VirtualEnvUtil.buildWithProjectGroup(producerGroup, projectGroupPrefix);
}
GetProducerConnectionListRequestHeader requestHeader = new GetProducerConnectionListRequestHeader();
requestHeader.setProducerGroup(producerGroupWithProjectGroup);
RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.GET_PRODUCER_CONNECTION_LIST, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return ProducerConnection.decode(response.getBody(), ProducerConnection.class);
}
default:
break;
}
throw new MQBrokerException(response.getCode(), response.getRemark());
}
示例13: getConsumerConnectionList
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
/**
* 根据ConsumerGroup获取Consumer连接列表以及订阅关系
*/
public ConsumerConnection getConsumerConnectionList(final String addr, final String consumerGroup,
final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException,
RemotingTimeoutException, InterruptedException, MQBrokerException {
// 添加虚拟运行环境相关的projectGroupPrefix
String consumerGroupWithProjectGroup = consumerGroup;
if (!UtilAll.isBlank(projectGroupPrefix)) {
consumerGroupWithProjectGroup =
VirtualEnvUtil.buildWithProjectGroup(consumerGroup, projectGroupPrefix);
}
GetConsumerConnectionListRequestHeader requestHeader = new GetConsumerConnectionListRequestHeader();
requestHeader.setConsumerGroup(consumerGroupWithProjectGroup);
RemotingCommand request =
RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_CONNECTION_LIST, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
ConsumerConnection consumerConnection =
ConsumerConnection.decode(response.getBody(), ConsumerConnection.class);
if (!UtilAll.isBlank(projectGroupPrefix)) {
ConcurrentHashMap<String, SubscriptionData> subscriptionDataConcurrentHashMap =
consumerConnection.getSubscriptionTable();
for (Map.Entry<String, SubscriptionData> subscriptionDataEntry : subscriptionDataConcurrentHashMap
.entrySet()) {
SubscriptionData subscriptionData = subscriptionDataEntry.getValue();
subscriptionDataEntry.getValue().setTopic(
VirtualEnvUtil.clearProjectGroup(subscriptionData.getTopic(), projectGroupPrefix));
}
}
return consumerConnection;
}
default:
break;
}
throw new MQBrokerException(response.getCode(), response.getRemark());
}
示例14: unlockBatchMQ
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
public void unlockBatchMQ(//
final String addr,//
final UnlockBatchRequestBody requestBody,//
final long timeoutMillis,//
final boolean oneway//
) throws RemotingException, MQBrokerException, InterruptedException {
// 添加虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
requestBody.setConsumerGroup(VirtualEnvUtil.buildWithProjectGroup(requestBody.getConsumerGroup(),
projectGroupPrefix));
Set<MessageQueue> messageQueues = requestBody.getMqSet();
for (MessageQueue messageQueue : messageQueues) {
messageQueue.setTopic(VirtualEnvUtil.buildWithProjectGroup(messageQueue.getTopic(),
projectGroupPrefix));
}
}
RemotingCommand request =
RemotingCommand.createRequestCommand(MQRequestCode.UNLOCK_BATCH_MQ_VALUE, null);
request.setBody(requestBody.encode());
if (oneway) {
this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
else {
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS_VALUE: {
return;
}
default:
break;
}
throw new MQBrokerException(response.getCode(), response.getRemark());
}
}
示例15: getTopicStatsInfo
import com.alibaba.rocketmq.client.VirtualEnvUtil; //导入依赖的package包/类
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis)
throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
RemotingConnectException, MQBrokerException {
// 添加虚拟运行环境相关的projectGroupPrefix
String topicWithProjectGroup = topic;
if (!UtilAll.isBlank(projectGroupPrefix)) {
topicWithProjectGroup = VirtualEnvUtil.buildWithProjectGroup(topic, projectGroupPrefix);
}
GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
requestHeader.setTopic(topicWithProjectGroup);
RemotingCommand request =
RemotingCommand.createRequestCommand(MQRequestCode.GET_TOPIC_STATS_INFO_VALUE, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS_VALUE: {
TopicStatsTable topicStatsTable =
TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
// 清除虚拟运行环境相关的projectGroupPrefix
if (!UtilAll.isBlank(projectGroupPrefix)) {
HashMap<MessageQueue, TopicOffset> newTopicOffsetMap =
new HashMap<MessageQueue, TopicOffset>();
for (Map.Entry<MessageQueue, TopicOffset> messageQueue : topicStatsTable.getOffsetTable()
.entrySet()) {
MessageQueue key = messageQueue.getKey();
key.setTopic(VirtualEnvUtil.clearProjectGroup(key.getTopic(), projectGroupPrefix));
newTopicOffsetMap.put(key, messageQueue.getValue());
}
topicStatsTable.setOffsetTable(newTopicOffsetMap);
}
return topicStatsTable;
}
default:
break;
}
throw new MQBrokerException(response.getCode(), response.getRemark());
}