{"action":"opened","issue":{"url":"https://api.github.com/repos/killbill/killbill/issues/493","repository_url":"https://api.github.com/repos/killbill/killbill","labels_url":"https://api.github.com/repos/killbill/killbill/issues/493/labels{/name}","comments_url":"https://api.github.com/repos/killbill/killbill/issues/493/comments","events_url":"https://api.github.com/repos/killbill/killbill/issues/493/events","html_url":"https://github.com/killbill/killbill/issues/493","id":134394272,"number":493,"title":"Change events sent in entitlements","user":{"login":"sbrossie","id":246910,"avatar_url":"https://avatars.githubusercontent.com/u/246910?v=3","gravatar_id":"","url":"https://api.github.com/users/sbrossie","html_url":"https://github.com/sbrossie","followers_url":"https://api.github.com/users/sbrossie/followers","following_url":"https://api.github.com/users/sbrossie/following{/other_user}","gists_url":"https://api.github.com/users/sbrossie/gists{/gist_id}","starred_url":"https://api.github.com/users/sbrossie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbrossie/subscriptions","organizations_url":"https://api.github.com/users/sbrossie/orgs","repos_url":"https://api.github.com/users/sbrossie/repos","events_url":"https://api.github.com/users/sbrossie/events{/privacy}","received_events_url":"https://api.github.com/users/sbrossie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-17T20:42:39Z","updated_at":"2016-02-17T20:42:39Z","closed_at":null,"body":"Today situation is confusing because on some entitlement operations, we send both `BlockingTransitionInternalEvent` and `DefaultEffectiveEntitlementEvent`, and some others only `BlockingTransitionInternalEvent`.\r\n\r\nAlso on the external bus nothing is sent for `BlockingTransitionInternalEvent`\r\n\r\nThe proposal is the following:\r\n\r\n**Internal Bus:**\r\n\r\n* We remove `DefaultEffectiveEntitlementEvent`, only used for pause/resume today (and this currently sent in addition to the `BlockingTransitionInternalEvent`, so we get 2 events, one of which is sent from transaction and cleaned up  correctly with [magic logic](https://github.com/killbill/killbill/blob/work-for-release-0.17.0/entitlement/src/main/java/org/killbill/billing/entitlement/dao/DefaultBlockingStateDao.java#L185) and the other one sent outside of transaction with no cleanup).\r\n\r\n* We only keep `BlockingTransitionInternalEvent`. However we still have all the info we need as those `BlockingTransitionInternalEvent` have a service ('entitlement-service')  and a state (`ENT_STATE_START`, `ENT_STATE_BLOCKED`, `ENT_STATE_CLEAR`, `ENT_STATE_CANCELLED`), so any internal Kill Bill piece can correctly interpret those as needed\r\n\r\n**External Bus:**\r\n\r\n* We transform all the BlockingTransitionInternalEvent (svc='entitlement-service') into something that makes sense (e.g START_ENTITLEMENT for state = ENT_STATE_START,..). Today we are missing operation types (nothing for entitlement operations except BUNDLE_PAUSE, BUNDLE_RESUME),\r\n\r\n* We fix our currently broken code (eventBusType  is not set so no event is sent) to send an external bus (another type needed again)\r\n\r\n"}}