PersistentBus
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.killbill.bus.api.PersistentBus(Showing top 20 results out of 315)

Refine search

  • InternalCallContext
  • AfterMethod
  • BeforeMethod
origin: org.kill-bill.billing/killbill-account

@Override
public void create(final AccountModelDao account, final InternalCallContext context) throws AccountApiException {
  super.create(account, context);
  try {
    final Long accountRecordId = getRecordId(account.getId(), context);
    final long tenantRecordId = context == null ? InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID
                          : context.getTenantRecordId();
    eventBus.post(new DefaultAccountCreationEvent(new DefaultAccountData(account), account.getId(), accountRecordId, tenantRecordId, UUID.randomUUID()));
  } catch (final EventBusException ex) {
    Assert.fail(ex.toString());
  }
}
origin: org.kill-bill.billing/killbill-subscription

private void notifyBusOfRequestedChange(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final DefaultSubscriptionBase subscription,
                    final SubscriptionBaseEvent nextEvent, final SubscriptionBaseTransitionType transitionType, final InternalCallContext context) {
  try {
    eventBus.postFromTransaction(new DefaultRequestedSubscriptionEvent(subscription, nextEvent, transitionType, context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()), entitySqlDaoWrapperFactory.getHandle().getConnection());
  } catch (final EventBusException e) {
    log.warn("Failed to post requested change event for subscriptionId='{}'", subscription.getId(), e);
  }
}
origin: org.kill-bill.billing/killbill-overdue

  @AfterMethod(groups = "slow")
  public void afterMethod() throws Exception {
    service.stop();
    bus.unregister(listener);
    bus.stop();
  }
}
origin: org.kill-bill.billing/killbill-overdue

@BeforeMethod(groups = "fast")
public void beforeMethod() throws Exception {
  bus.start();
  service.initialize();
  service.start();
}
origin: org.kill-bill.billing/killbill-account

  @AfterMethod(groups = "fast")
  public void afterMethod() throws Exception {
    bus.stop();
  }
}
origin: org.kill-bill.billing/killbill-invoice

private void notifyBusOfInvoiceAdjustment(final UUID invoiceId, final UUID accountId, final InternalCallContext context) {
  final DefaultInvoiceAdjustmentEvent event = new DefaultInvoiceAdjustmentEvent(invoiceId, accountId, context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
  try {
    eventBus.post(event);
  } catch (final EventBusException e) {
    log.warn("Failed to post event {}", event, e);
  }
}
origin: org.kill-bill.billing/killbill-invoice

@Override
public void createInvoice(final InvoiceModelDao invoice,
             final FutureAccountNotifications callbackDateTimePerSubscriptions, final InternalCallContext context) {
  synchronized (monitor) {
    storeInvoice(invoice, context);
  }
  try {
    eventBus.post(new DefaultInvoiceCreationEvent(invoice.getId(), invoice.getAccountId(),
                           InvoiceModelDaoHelper.getRawBalanceForRegularInvoice(invoice), invoice.getCurrency(),
                           context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()));
  } catch (final PersistentBus.EventBusException ex) {
    throw new RuntimeException(ex);
  }
}
origin: org.kill-bill.billing/killbill-overdue

@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
  super.beforeMethod();
  cacheControllerDispatcher.clearAll();
  bus.start();
  bus.register(listener);
  service.loadConfig();
  service.initialize();
  service.start();
}
origin: org.kill-bill.billing/killbill-invoice

public void processSubscriptionForInvoiceNotification(final UUID subscriptionId, final LocalDate targetDate, final InternalCallContext context) throws InvoiceApiException {
  final Invoice dryRunInvoice = processSubscriptionInternal(subscriptionId, targetDate, true, context);
  if (dryRunInvoice != null && dryRunInvoice.getBalance().compareTo(BigDecimal.ZERO) > 0) {
    final InvoiceNotificationInternalEvent event = new DefaultInvoiceNotificationInternalEvent(dryRunInvoice.getAccountId(), dryRunInvoice.getBalance(), dryRunInvoice.getCurrency(),
                                                  context.toUTCDateTime(targetDate), context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
    try {
      eventBus.post(event);
    } catch (EventBusException e) {
      log.warn("Failed to post event {}", event, e);
    }
  }
}
origin: org.kill-bill.billing/killbill-subscription

private void notifyBusOfEffectiveImmediateChange(final DefaultSubscriptionBase subscription, final SubscriptionBaseEvent immediateEvent, final int seqId, final InternalCallContext context) {
  try {
    final SubscriptionBaseTransitionData transition = subscription.getTransitionFromEvent(immediateEvent, seqId);
    final BusEvent busEvent = new DefaultEffectiveSubscriptionEvent(transition,
                                    subscription.getAlignStartDate(),
                                    context.getUserToken(),
                                    context.getAccountRecordId(),
                                    context.getTenantRecordId());
    eventBus.post(busEvent);
  } catch (final EventBusException e) {
    log.warn("Failed to post effective event for subscription " + subscription.getId(), e);
  }
}
origin: org.kill-bill.commons/killbill-queue

@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
  super.beforeMethod();
  // Reinitialize to restart the pool
  busService = new DefaultPersistentBus(getDBI(), clock, getPersistentBusConfig(), metricRegistry, databaseTransactionNotificationApi);
  testEventBusBase = new TestEventBusBase(busService);
  busService.start();
}
origin: org.kill-bill.billing/killbill-account

@Override
public void update(final AccountModelDao account, final InternalCallContext context) {
  super.update(account, context);
  final AccountModelDao currentAccount = getById(account.getId(), context);
  final Long accountRecordId = getRecordId(account.getId(), context);
  final long tenantRecordId = context == null ? InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID
                        : context.getTenantRecordId();
  final AccountChangeInternalEvent changeEvent = new DefaultAccountChangeEvent(account.getId(), currentAccount, account,
                                         accountRecordId, tenantRecordId, UUID.randomUUID(),
                                         clock.getUTCNow());
  if (changeEvent.hasChanges()) {
    try {
      eventBus.post(changeEvent);
    } catch (final EventBusException ex) {
      Assert.fail(ex.toString());
    }
  }
}
origin: org.kill-bill.billing/killbill-invoice

  @AfterMethod(groups = "slow")
  public void afterMethod() throws Exception {
    bus.stop();
    stopInvoiceService(invoiceService);
  }
}
origin: org.kill-bill.billing/killbill-invoice

@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
  super.beforeMethod();
  controllerDispatcher.clearAll();
  bus.start();
  restartInvoiceService(invoiceService);
  clock.resetDeltaFromReality();
}
origin: org.kill-bill.billing/killbill-invoice

private void notifyBusOfInvoiceCreation(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final InvoiceModelDao invoice, final InternalCallContext context) {
  try {
    // This is called for a new COMMITTED invoice (which cannot be writtenOff as it does not exist yet, so rawBalance == balance)
    final BigDecimal rawBalance = InvoiceModelDaoHelper.getRawBalanceForRegularInvoice(invoice);
    final DefaultInvoiceCreationEvent event = new DefaultInvoiceCreationEvent(invoice.getId(), invoice.getAccountId(),
                                         rawBalance, invoice.getCurrency(),
                                         context.getAccountRecordId(), context.getTenantRecordId(),
                                         context.getUserToken());
    eventBus.postFromTransaction(event, entitySqlDaoWrapperFactory.getHandle().getConnection());
  } catch (final EventBusException e) {
    log.error(String.format("Failed to post invoice creation event %s for account %s", invoice.getAccountId()), e);
  }
}
origin: org.kill-bill.billing/killbill-account

@Override
protected void postBusEventFromTransaction(final AccountModelDao account, final AccountModelDao savedAccount, final ChangeType changeType,
                      final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final InternalCallContext context) throws BillingExceptionBase {
  // This is only called for the create call (see update below)
  switch (changeType) {
    case INSERT:
      break;
    default:
      return;
  }
  final Long recordId = savedAccount.getRecordId();
  // We need to re-hydrate the callcontext with the account record id
  final InternalCallContext rehydratedContext = internalCallContextFactory.createInternalCallContext(savedAccount, recordId, context);
  final AccountCreationInternalEvent creationEvent = new DefaultAccountCreationEvent(new DefaultAccountData(savedAccount), savedAccount.getId(),
                                            rehydratedContext.getAccountRecordId(), rehydratedContext.getTenantRecordId(), rehydratedContext.getUserToken());
  try {
    eventBus.postFromTransaction(creationEvent, entitySqlDaoWrapperFactory.getHandle().getConnection());
  } catch (final EventBusException e) {
    log.warn("Failed to post account creation event for accountId='{}'", savedAccount.getId(), e);
  }
}
origin: org.kill-bill.billing/killbill-util

@Override
protected void postBusEventFromTransaction(final CustomFieldModelDao customField, final CustomFieldModelDao savedCustomField, final ChangeType changeType,
                      final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final InternalCallContext context)
    throws BillingExceptionBase {
  BusInternalEvent customFieldEvent = null;
  switch (changeType) {
    case INSERT:
      customFieldEvent = new DefaultCustomFieldCreationEvent(customField.getId(), customField.getObjectId(), customField.getObjectType(),
                                  context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
      break;
    case DELETE:
      customFieldEvent = new DefaultCustomFieldDeletionEvent(customField.getId(), customField.getObjectId(), customField.getObjectType(),
                                  context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
      break;
    default:
      return;
  }
  try {
    bus.postFromTransaction(customFieldEvent, entitySqlDaoWrapperFactory.getHandle().getConnection());
  } catch (final PersistentBus.EventBusException e) {
    log.warn("Failed to post tag event for customFieldId='{}'", customField.getId().toString(), e);
  }
}
origin: org.kill-bill.commons/killbill-queue

@BeforeMethod(groups = "load")
public void beforeMethod() throws Exception {
  super.beforeMethod();
  eventBus.start();
}
origin: org.kill-bill.billing/killbill-util

@AfterMethod(groups = "slow")
public void afterMethod() throws Exception {
  eventBus.unregister(eventsListener);
  eventBus.stop();
}
origin: org.kill-bill.billing/killbill-subscription

private void notifyBusOfEffectiveImmediateChange(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final DefaultSubscriptionBase subscription,
                         final SubscriptionBaseEvent immediateEvent, final int seqId, final InternalCallContext context) {
  try {
    final SubscriptionBaseTransitionData transition = subscription.getTransitionFromEvent(immediateEvent, seqId);
    if (transition != null) {
      final BusEvent busEvent = new DefaultEffectiveSubscriptionEvent(transition,
                                      subscription.getAlignStartDate(),
                                      context.getUserToken(),
                                      context.getAccountRecordId(),
                                      context.getTenantRecordId());
      eventBus.postFromTransaction(busEvent, entitySqlDaoWrapperFactory.getHandle().getConnection());
    }
  } catch (final EventBusException e) {
    log.warn("Failed to post effective event for subscriptionId='{}'", subscription.getId(), e);
  }
}
org.killbill.bus.apiPersistentBus

Javadoc

When an Iterable is returned, the client must iterate through all results to close the DB connection.

Most used methods

  • post
    Post an event asynchronously
  • register
    Registers all handler methods on object to receive events. Handler methods need to be Annotated with
  • start
    Start accepting events and dispatching them
  • stop
    Stop accepting events and flush event queue before it returns.
  • unregister
    Unregister the handler for a particular type of event
  • postFromTransaction
    Post an event from within a transaction. Guarantees that the event is persisted on disk from within
  • getInProcessingBusEvents
  • getNbReadyEntries
    Count the number of bus entries ready to be processed

Popular classes and methods

  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • runOnUiThread (Activity)
  • FlowLayout (java.awt)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • TimeZone (java.util)
    TimeZone represents a time zone, primarily used for configuring a Calendar or java.text.SimpleDateF
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)