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

Java ServiceBusException类代码示例

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

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



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

示例1: onError

import com.microsoft.azure.servicebus.ServiceBusException; //导入依赖的package包/类
@Override
public void onError(Throwable throwable) {
  errorRate.inc();
  aggReadErrors.inc();

  if (throwable instanceof ServiceBusException) {
    ServiceBusException busException = (ServiceBusException) throwable;

    if (busException.getIsTransient()) {

      // Only set to transient throwable if there has been no previous errors
      eventHubHandlerError.compareAndSet(null, throwable);

      // Retry creating a receiver since error likely due to timeout
      renewPartitionReceiver(ssp);
      return;
    }
  }

  // Propagate non transient or unknown errors
  eventHubHandlerError.set(throwable);
}
 
开发者ID:apache,项目名称:samza,代码行数:23,代码来源:EventHubSystemConsumer.java


示例2: main

import com.microsoft.azure.servicebus.ServiceBusException; //导入依赖的package包/类
public static void main(String[] args)
    throws ServiceBusException, IOException, ExecutionException, InterruptedException {
  Options options = new Options();
  options.addOption(
      CommandLineHelper.createOption(OPT_SHORT_EVENTHUB_NAME, OPT_LONG_EVENTHUB_NAME, OPT_ARG_EVENTHUB_NAME, true,
      OPT_DESC_EVENTHUB_NAME));

  options.addOption(
      CommandLineHelper.createOption(OPT_SHORT_NAMESPACE, OPT_LONG_NAMESPACE, OPT_ARG_NAMESPACE, true, OPT_DESC_NAMESPACE));

  options.addOption(
      CommandLineHelper.createOption(OPT_SHORT_KEY_NAME, OPT_LONG_KEY_NAME, OPT_ARG_KEY_NAME, true, OPT_DESC_KEY_NAME));

  options.addOption(
      CommandLineHelper.createOption(OPT_SHORT_TOKEN, OPT_LONG_TOKEN, OPT_ARG_TOKEN, true, OPT_DESC_TOKEN));

  CommandLineParser parser = new BasicParser();
  CommandLine cmd;
  try {
    cmd = parser.parse(options, args);
  } catch (Exception e) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp(String.format("Error: %s%neh-console-consumer.sh", e.getMessage()), options);
    return;
  }

  String ehName = cmd.getOptionValue(OPT_SHORT_EVENTHUB_NAME);
  String namespace = cmd.getOptionValue(OPT_SHORT_NAMESPACE);
  String keyName = cmd.getOptionValue(OPT_SHORT_KEY_NAME);
  String token = cmd.getOptionValue(OPT_SHORT_TOKEN);

  consumeEvents(ehName, namespace, keyName, token);
}
 
开发者ID:srinipunuru,项目名称:samza-sql-tools,代码行数:34,代码来源:EventHubConsoleConsumer.java


示例3: consumeEvents

import com.microsoft.azure.servicebus.ServiceBusException; //导入依赖的package包/类
private static void consumeEvents(String ehName, String namespace, String keyName, String token)
    throws ServiceBusException, IOException, ExecutionException, InterruptedException {
  ConnectionStringBuilder connStr = new ConnectionStringBuilder(namespace, ehName, keyName, token);

  EventHubClient client = EventHubClient.createFromConnectionStringSync(connStr.toString());

  EventHubRuntimeInformation runTimeInfo = client.getRuntimeInformation().get();
  int numPartitions = runTimeInfo.getPartitionCount();
  for (int partition = 0; partition < numPartitions; partition++) {
    PartitionReceiver receiver =
        client.createReceiverSync(EventHubClient.DEFAULT_CONSUMER_GROUP_NAME, String.valueOf(partition),
            PartitionReceiver.START_OF_STREAM);
    receiver.receive(10).handle((records, throwable) -> handleComplete(receiver, records, throwable));
  }
}
 
开发者ID:srinipunuru,项目名称:samza-sql-tools,代码行数:16,代码来源:EventHubConsoleConsumer.java


示例4: isErrorTransient

import com.microsoft.azure.servicebus.ServiceBusException; //导入依赖的package包/类
private boolean isErrorTransient(Throwable throwable) {
  if (throwable instanceof ServiceBusException) {
    ServiceBusException serviceBusException = (ServiceBusException) throwable;
    return serviceBusException.getIsTransient();
  }
  return false;
}
 
开发者ID:apache,项目名称:samza,代码行数:8,代码来源:EventHubSystemConsumer.java


示例5: init

import com.microsoft.azure.servicebus.ServiceBusException; //导入依赖的package包/类
@Override
public void init() {
  String remoteHost = String.format(EVENTHUB_REMOTE_HOST_FORMAT, eventHubNamespace);
  try {
    ConnectionStringBuilder connectionStringBuilder =
            new ConnectionStringBuilder(eventHubNamespace, entityPath, sasKeyName, sasKey);

    eventHubClient = EventHubClient.createFromConnectionStringSync(connectionStringBuilder.toString(), retryPolicy);
  } catch (IOException | ServiceBusException e) {
    String msg = String.format("Creation of EventHub client failed for eventHub EntityPath: %s on remote host %s:%d",
            entityPath, remoteHost, ClientConstants.AMQPS_PORT);
    LOG.error(msg, e);
    throw new SamzaException(msg, e);
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:16,代码来源:SamzaEventHubClientManager.java


示例6: testReceive

import com.microsoft.azure.servicebus.ServiceBusException; //导入依赖的package包/类
@Test
public void testReceive() throws ServiceBusException {
  EventHubClientManagerFactory clientFactory = new EventHubClientManagerFactory();
  EventHubClientManager wrapper = clientFactory
          .getEventHubClientManager(SYSTEM_NAME, STREAM_NAME1, new EventHubConfig(createEventHubConfig()));
  wrapper.init();
  EventHubClient client = wrapper.getEventHubClient();
  PartitionReceiver receiver =
          client.createReceiverSync(EventHubClient.DEFAULT_CONSUMER_GROUP_NAME, "0",
                  EventHubSystemConsumer.START_OF_STREAM, true);
  receiveMessages(receiver, 300);
}
 
开发者ID:apache,项目名称:samza,代码行数:13,代码来源:ITestEventHubSystemProducer.java


示例7: receiveMessages

import com.microsoft.azure.servicebus.ServiceBusException; //导入依赖的package包/类
private void receiveMessages(PartitionReceiver receiver, int numMessages) throws ServiceBusException {
  int count = 0;
  while (count < numMessages) {

    Iterable<EventData> messages = receiver.receiveSync(100);
    if (messages == null) {
      break;
    }
    for (EventData data : messages) {
      count++;
      LOG.info("Data" + new String(data.getBytes()));
    }
  }
}
 
开发者ID:apache,项目名称:samza,代码行数:15,代码来源:ITestEventHubSystemProducer.java


示例8: createEventHubClient

import com.microsoft.azure.servicebus.ServiceBusException; //导入依赖的package包/类
public EventHubClient createEventHubClient() throws IOException, ServiceBusException {
  ConnectionStringBuilder connStr = new ConnectionStringBuilder(
      commonConf.namespaceName,
      commonConf.eventHubName,
      commonConf.sasKeyName,
      commonConf.sasKey
  );
  return EventHubClient.createFromConnectionStringSync(connStr.toString());
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:10,代码来源:EventHubCommon.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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