Search in sources :

Example 1 with ServiceBusException

use of com.microsoft.azure.servicebus.ServiceBusException in project storm by apache.

the class EventHubBolt method execute.

@Override
public void execute(Tuple tuple) {
    try {
        EventData sendEvent = new EventData(boltConfig.getEventDataFormat().serialize(tuple));
        if (boltConfig.getPartitionMode() && sender != null) {
            sender.sendSync(sendEvent);
        } else if (boltConfig.getPartitionMode() && sender == null) {
            throw new EventHubException("Sender is null");
        } else if (!boltConfig.getPartitionMode() && ehClient != null) {
            ehClient.sendSync(sendEvent);
        } else if (!boltConfig.getPartitionMode() && ehClient == null) {
            throw new EventHubException("ehclient is null");
        }
        collector.ack(tuple);
    } catch (EventHubException ex) {
        collector.reportError(ex);
        collector.fail(tuple);
    } catch (ServiceBusException e) {
        collector.reportError(e);
        collector.fail(tuple);
    }
}
Also used : ServiceBusException(com.microsoft.azure.servicebus.ServiceBusException) EventHubException(org.apache.storm.eventhubs.spout.EventHubException) EventData(com.microsoft.azure.eventhubs.EventData)

Example 2 with ServiceBusException

use of com.microsoft.azure.servicebus.ServiceBusException in project storm by apache.

the class EventHubReceiverImpl method receive.

@Override
public EventDataWrap receive() {
    long start = System.currentTimeMillis();
    Iterable<EventData> receivedEvents = null;
    /*Get one message at a time for backward compatibility behaviour*/
    try {
        receivedEvents = receiver.receiveSync(1);
    } catch (ServiceBusException e) {
        logger.error("Exception occured during receive" + e.toString());
        return null;
    }
    long end = System.currentTimeMillis();
    long millis = (end - start);
    receiveApiLatencyMean.update(millis);
    receiveApiCallCount.incr();
    if (receivedEvents == null || receivedEvents.spliterator().getExactSizeIfKnown() == 0) {
        return null;
    }
    receiveMessageCount.incr();
    EventData receivedEvent = receivedEvents.iterator().next();
    MessageId messageId = new MessageId(partitionId, receivedEvent.getSystemProperties().getOffset(), receivedEvent.getSystemProperties().getSequenceNumber());
    return EventDataWrap.create(receivedEvent, messageId);
}
Also used : ServiceBusException(com.microsoft.azure.servicebus.ServiceBusException) EventData(com.microsoft.azure.eventhubs.EventData)

Aggregations

EventData (com.microsoft.azure.eventhubs.EventData)2 ServiceBusException (com.microsoft.azure.servicebus.ServiceBusException)2 EventHubException (org.apache.storm.eventhubs.spout.EventHubException)1