WSO2 Identity Server - event handler - what events are handled? - wso2-identity-server

The WSO2 Identity Server since version 5.1 has an option to engage the workflow on certain events using a custom event event/workflow handler. Nice! What events is it possible to handle? Well - from the example I see that any admin web service calls could be intercepted.
Next to that - I found the org.wso2.carbon.identity.event bundle providing option to handle events. What events is this feature intended?
Thank you all for any insight.

We developed identity-event component with the initial intention to handle events related to identity-management such as account lock, account disable, password reset, failed login attempt etc. We developed AbstractEventHandlerwhich defines different methods of handling events such as sending notifications. Account locking act as a method of handling events as well at the time of incorrect login attempt. Successful login attempt after failed login attempt also act as event where handler will reset the user's failed login attempt claim. We can map events to handler in repository/conf/identity/event-mgt.properties file. So we can register each events to 0 or more handlers which will fired when the event occurs.
Even though the initial intention of this event framework was to handle identity management event, later we improved it to be a more generic framework which can handle any event which we can describe in model I mentioned above. But as far as I know this only covers identity-management related event. But anyone who develop customize features can make use of this.
Its true that workflow handler is also a way of handling events which do the same task this framework do for some extent. After reading your question, I also got feeling that it also follows the same model. But we haven't thought of combining these two. So they will work as independent features.

Related

Ability to ensure message was successfully sent to Event Hub from APIM

Is it possible to ensure that a message was successfully delivered to an Event Hub when sending it with the log-to-eventhub policy in API Management?
Edit: In our solution we cannot allow any request to proceed if a message was not delivered to the Event Hub. As far as I can tell the log-to-eventhub policy doesn't check for this.
Welcome to Stackoveflow!
Note: Once the data has been passed to an Event Hub, it is persisted and will wait for Event Hub consumers to process it. The Event Hub does not care how it is processed; it just cares about making sure the message will be successfully delivered.
For more details, refer “Why send to an Azure Event Hub?”.
Hope this helps.
Event Hubs is built on top of Service Bus. According to the Service Bus documentation,
Using any of the supported Service Bus API clients, send operations into Service Bus are always explicitly settled, meaning that the API operation waits for an acceptance result from Service Bus to arrive, and then completes the send operation.
If the message is rejected by Service Bus, the rejection contains an error indicator and text with a "tracking-id" inside of it. The rejection also includes information about whether the operation can be retried with any expectation of success. In the client, this information is turned into an exception and raised to the caller of the send operation. If the message has been accepted, the operation silently completes.
When using the AMQP protocol, which is the exclusive protocol for the .NET Standard client and the Java client and which is an option for the .NET Framework client, message transfers and settlements are pipelined and completely asynchronous, and it is recommended that you use the asynchronous programming model API variants.
A sender can put several messages on the wire in rapid succession without having to wait for each message to be acknowledged, as would otherwise be the case with the SBMP protocol or with HTTP 1.1. Those asynchronous send operations complete as the respective messages are accepted and stored, on partitioned entities or when send operation to different entities overlap. The completions might also occur out of the original send order.
I think this means the SDK is getting a receipt for each message.
This theory is further aided by the RetryPolicy Class used in the ClientEntity.RetryPolicy Property of the EventHubSender Class.
In the API Management section on logging-to-eventhub, there is also a section on retry intervals. Below that are sections on modifying the return response or taking action on certain status codes.
Once the status codes of a failed logging attempt are known, you can modify the policies to take action on failed logging attempts.

Running Task In The Background

What is the technology which allows the web application to process the task in the background without holding user to wait until the task to finish.
Example, as a user,
1. I want to submit a form which requires heavy processing. (Assume it requires to checking or actions, upload documentation or etc)
2. After submitting the form, the task will be running in the background, then I can go to other page and do something else.
2.1 At the same time, I might submit another form to the server.
The request can be process at the same time or can be queue under a queue system
3. I will receive a notification from the system whenever the server return a response. (Regardless it is success or failure)
This feature is similar to Google Cloud Platform.
Try Kue or any other similar libraries. The term to "google" is "[language] task queue"
You can of course roll your own. Though it will be much easier if you make use of an existing server such as redis or rabbitmq. So that queuing part is handled for you by the server and you could concentrate on your business logic.

Best way to retrieve active calls without making request each second?

We need to create a monitor that will show any income calls in our extranet in live time.
We were able to show active calls by using /account/~/extension/~/active-calls, however, to achieve what we need we would need to make a request each second which I guess will be blocked by rate limits.
Is there a better solution for it?
Thanks
Subscription (Push Notification) API resource empowers developers to enable the client application(s) to create a single subscription (to one or more extension's) and continually receive push notifications in real time for each subscribed extension.When using this approach for your application(s) to receive events on your RingCentral account, no polling is involved.
You can create a subscription using either of the below-mentioned transportType for receiving push notifications:
PubNub
WebHook
Notifications which the client wants to receive can be specified by the event filters which are set in the subscription request. The event filter is exposed as a URL, pointing to the required RingCentral API resource. Currently the following event types are available for notifications: extensions, messages and presence. They are described in detail below:
Notifications Event Types
You can take a look at the Subscription API below:
Subscription API
If you are interested in Subscribing to Push notifications via WebHook then we have an Easy-to-follow Quickstart guide here:
RingCentral Webhooks Quickstart Guide

How do I notify the client application when a chaincode is invoked?

When a chaincode is invoked, is there a way to call a REST API (external) so that the client application can be notified on the new transaction.
Apart from REST, is there any other option?
It's better to use events
https://github.com/hyperledger/fabric/blob/master/docs/protocol-spec.md#35-events
Validating peers and chaincodes can emit events on the network that
applications may listen for and take actions on. There is a set of
pre-defined events, and chaincodes can generate custom events. Events
are consumed by 1 or more event adapters. Adapters may further deliver
events using other vehicles such as Web hooks or Kafka.
Application can subscribe for events stream from Fabric and listen for messages generate by your chaincode.
An example for how to work with Events can be found here:
https://github.com/hyperledger/fabric/tree/master/examples/events/block-listener
To add to Sergey's answer, there are 3 types of events.
BLOCK EVENTs, which are created when the ledger changes.
REJECTION EVENTs, which are created when any error occur( either in user chain code or in system chain code )
CHAINCODE EVENTs, which are user handles which lets user chain code create events. [ Weird thing I noticed is, only one CHAINCODE EVENT per invoke is allowed as per current design ]
You can have an event listener/client running at your end, listening on the gRPC port, ( you can get the port from the core.yaml file ) Or you can even refer to the example Sergey has mentioned.
In your case, I am guessing that you are looking for a successful transaction. In that case, you should listen on BLOCK events and REJECTION Events. The Transaction UUID which you received when your invoke was triggered, can be used to scan the events and trigger an action when it matches.
Also note that if a transaction results in REJECTION EVENT, then it would not have a BLOCK EVENT.
Hope this helps.

When would actor_tpye be "app" or "service_broker"?

The CF events api lists an "actor_type" field for events, which can be one of:
service_broker
system
user
v3-process
What is an example of an audit event's actor type being each of the above? Where is the documentation, at a higher level than a summary of the REST endpoints, and in more detail than this, for someone trying to consume this api?
actor_type represents what initiated the event. Similarly, actee_type is the resource that is being acted upon.
user: Most events (e.g. starting/stopping/deleting an app) will have actor_type "user", since the event was triggered by a user action.
service_broker: Some audit events are triggered by service brokers. Examples are registering a service offering or a service plan.
system: System is used when there is not a clear actor. There is currently a bug filed to investigate usage of this actor_type: https://www.pivotaltracker.com/story/show/132099009
v3-process: This was recently changed to be "process" in cf v245. This actor_type (along with the actor_type "app") is only used when the process/app crashes. There is also a bug around this actor_type: https://www.pivotaltracker.com/story/show/132098945
I could not find any documentation for audit events other than the API docs. How are you trying to consume the events API?