use of org.killbill.billing.util.broadcast.dao.BroadcastModelDao in project killbill by killbill.
the class DefaultBroadcastService method initialize.
@LifecycleHandlerType(LifecycleLevel.INIT_SERVICE)
public void initialize() {
final BroadcastModelDao entry = broadcastDao.getLatestEntry();
this.latestRecordIdProcessed = entry != null ? new AtomicLong(entry.getRecordId()) : new AtomicLong(0L);
this.broadcastExecutor = Executors.newSingleThreadScheduledExecutor("BroadcastExecutor");
this.isStopped = false;
}
use of org.killbill.billing.util.broadcast.dao.BroadcastModelDao in project killbill by killbill.
the class DefaultBroadcastApi method broadcast.
@Override
public void broadcast(final String serviceName, final String type, final String event, final DateTime createdDate, final String createdBy, final boolean localNodeOnly) {
// If localNodeOnly, this is not really a broadcast api anymore, but we still rely on that broadcast bus event to notify the local node
if (localNodeOnly) {
final BroadcastInternalEvent busEvent = new DefaultBroadcastInternalEvent(serviceName, type, event);
try {
eventBus.post(busEvent);
} catch (final EventBusException e) {
logger.warn("Failed to post event {}", event, e);
}
} else {
final BroadcastModelDao modelDao = new BroadcastModelDao(serviceName, type, event, createdDate, createdBy);
dao.create(modelDao);
}
}
use of org.killbill.billing.util.broadcast.dao.BroadcastModelDao in project killbill by killbill.
the class TestBroadcastService method testBasic.
@Test(groups = "slow")
public void testBasic() {
final String eventJson = "\"{\"pluginName\":\"foo\",\"pluginVersion\":\"1.2.3\",\"properties\":[{\"key\":\"something\",\"value\":\"nothing\"}]}\"";
eventsListener.pushExpectedEvent(NextEvent.BROADCAST_SERVICE);
broadcastDao.create(new BroadcastModelDao("svc", "type", eventJson, clock.getUTCNow(), "tester"));
assertListenerStatus();
}
Aggregations