Search in sources :

Example 96 with Subscribe

use of com.google.common.eventbus.Subscribe in project killbill by killbill.

the class InvoiceListener method handleBlockingStateTransition.

@AllowConcurrentEvents
@Subscribe
public void handleBlockingStateTransition(final BlockingTransitionInternalEvent event) {
    // We are only interested in blockBilling or unblockBilling transitions.
    if (!event.isTransitionedToUnblockedBilling() && !event.isTransitionedToBlockedBilling()) {
        return;
    }
    try {
        final InternalCallContext context = internalCallContextFactory.createInternalCallContext(event.getSearchKey2(), event.getSearchKey1(), "SubscriptionBaseTransition", CallOrigin.INTERNAL, UserType.SYSTEM, event.getUserToken());
        final UUID accountId = accountApi.getByRecordId(event.getSearchKey1(), context);
        dispatcher.processAccountFromNotificationOrBusEvent(accountId, null, null, context);
    } catch (InvoiceApiException e) {
        log.warn("Unable to process event {}", event, e);
    } catch (AccountApiException e) {
        log.warn("Unable to process event {}", event, e);
    }
}
Also used : InvoiceApiException(org.killbill.billing.invoice.api.InvoiceApiException) AccountApiException(org.killbill.billing.account.api.AccountApiException) InternalCallContext(org.killbill.billing.callcontext.InternalCallContext) UUID(java.util.UUID) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 97 with Subscribe

use of com.google.common.eventbus.Subscribe in project killbill by killbill.

the class InvoiceListener method handleSubscriptionTransition.

@AllowConcurrentEvents
@Subscribe
public void handleSubscriptionTransition(final EffectiveSubscriptionInternalEvent event) {
    try {
        //  Skip events which are marked as not being the last one
        if (event.getTransitionType() == SubscriptionBaseTransitionType.UNCANCEL || event.getRemainingEventsForUserOperation() > 0) {
            return;
        }
        final InternalCallContext context = internalCallContextFactory.createInternalCallContext(event.getSearchKey2(), event.getSearchKey1(), "SubscriptionBaseTransition", CallOrigin.INTERNAL, UserType.SYSTEM, event.getUserToken());
        dispatcher.processSubscriptionForInvoiceGeneration(event, context);
    } catch (InvoiceApiException e) {
        log.warn("Unable to process event {}", event, e);
    }
}
Also used : InvoiceApiException(org.killbill.billing.invoice.api.InvoiceApiException) InternalCallContext(org.killbill.billing.callcontext.InternalCallContext) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 98 with Subscribe

use of com.google.common.eventbus.Subscribe in project killbill by killbill.

the class InvoiceListener method handleChildrenInvoiceAdjustmentEvent.

@AllowConcurrentEvents
@Subscribe
public void handleChildrenInvoiceAdjustmentEvent(final DefaultInvoiceAdjustmentEvent event) {
    try {
        final InternalCallContext context = internalCallContextFactory.createInternalCallContext(event.getSearchKey2(), event.getSearchKey1(), "AdjustParentInvoice", CallOrigin.INTERNAL, UserType.SYSTEM, event.getUserToken());
        final Account account = accountApi.getAccountById(event.getAccountId(), context);
        // catch children invoices and populate the parent summary invoice
        if (isChildrenAccountAndPaymentDelegated(account)) {
            dispatcher.processParentInvoiceForAdjustments(account, event.getInvoiceId(), context);
        }
    } catch (InvoiceApiException e) {
        log.error(e.getMessage());
    } catch (AccountApiException e) {
        log.error(e.getMessage());
    }
}
Also used : Account(org.killbill.billing.account.api.Account) InvoiceApiException(org.killbill.billing.invoice.api.InvoiceApiException) AccountApiException(org.killbill.billing.account.api.AccountApiException) InternalCallContext(org.killbill.billing.callcontext.InternalCallContext) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 99 with Subscribe

use of com.google.common.eventbus.Subscribe in project killbill by killbill.

the class InvoiceTagHandler method process_AUTO_INVOICING_OFF_removal.

@AllowConcurrentEvents
@Subscribe
public void process_AUTO_INVOICING_OFF_removal(final ControlTagDeletionInternalEvent event) {
    if (event.getTagDefinition().getName().equals(ControlTagType.AUTO_INVOICING_OFF.toString()) && event.getObjectType() == ObjectType.ACCOUNT) {
        final UUID accountId = event.getObjectId();
        final InternalCallContext context = internalCallContextFactory.createInternalCallContext(event.getSearchKey2(), event.getSearchKey1(), "InvoiceTagHandler", CallOrigin.INTERNAL, UserType.SYSTEM, event.getUserToken());
        processUnpaid_AUTO_INVOICING_OFF_invoices(accountId, context);
    }
}
Also used : InternalCallContext(org.killbill.billing.callcontext.InternalCallContext) UUID(java.util.UUID) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 100 with Subscribe

use of com.google.common.eventbus.Subscribe in project killbill by killbill.

the class PaymentTagHandler method process_AUTO_PAY_OFF_removal.

@AllowConcurrentEvents
@Subscribe
public void process_AUTO_PAY_OFF_removal(final ControlTagDeletionInternalEvent event) {
    if (event.getTagDefinition().getName().equals(ControlTagType.AUTO_PAY_OFF.toString()) && event.getObjectType() == ObjectType.ACCOUNT) {
        final UUID accountId = event.getObjectId();
        processUnpaid_AUTO_PAY_OFF_payments(accountId, event.getSearchKey1(), event.getSearchKey2(), event.getUserToken());
    }
}
Also used : UUID(java.util.UUID) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)115 AllowConcurrentEvents (com.google.common.eventbus.AllowConcurrentEvents)13 EventBus (com.google.common.eventbus.EventBus)11 BuckEventBus (com.facebook.buck.event.BuckEventBus)10 Test (org.junit.Test)10 UPID (com.groupon.mesos.util.UPID)8 Scheduler (org.apache.mesos.Scheduler)8 SchedulerDriver (org.apache.mesos.SchedulerDriver)8 IOException (java.io.IOException)7 InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)7 FakeClock (com.facebook.buck.timing.FakeClock)6 ArrayList (java.util.ArrayList)6 LogRecord (java.util.logging.LogRecord)6 Description (org.junit.runner.Description)6 WatchEvent (java.nio.file.WatchEvent)5 EasyMock.anyObject (org.easymock.EasyMock.anyObject)5 EventKey (com.facebook.buck.event.EventKey)4 Action (com.google.devtools.build.lib.actions.Action)4 File (java.io.File)4 UUID (java.util.UUID)4