当前位置: 首页>>代码示例>>Java>>正文


Java ServiceBusException类代码示例

本文整理汇总了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;未经允许,请勿转载。