Oracle Service Bus enables you to monitor and collect run-time information required for system operations. This post explains the steps to use alerts in Oracle Service Bus. Alerts are used inside message flow to generate an alert and that alert we can see in OSB console. To generate an alert in message flow, we use alert activity and each alert activity is linked to alert destination.
When we use alerts in OSB, for each alert we need to define alert destination i.e. we need to define the destination of the alert. In OSB in alert destination we can perform below two functions.
- Send email
- Send message to JMS queue/Topic
To create an alert destination, click on resources folder and choose “Alert Destination” from resource type drop down list.
Specify the alert destination name and click on add button as we send alert message to JMS queue.
Take special care while specifying queue Endpoint URI.
It is JNDI name of Connection factory, if you are using default connection factory then this will be equal to “Weblogic.jms.XAConnectionFactory” and if you are using any custom connection factory then you have to mention connection factory JNDI name.
Let’s suppose you are using below connection factory for your queue.
Connection Factory Name- SampleCF
Then your FactoryJNDIName will be “jms.SampleCF”.
It is JNDI name of JMS queue. We are following JMS queue.
JMS Queue- SampleQueue
JNDI – jms/SampleQueue
So our DestJndiName will be “jms.SampleQueue”.
Now your alert destination should look like below.
You can also add email recipients if you want to send a notification in case of alert. For that you need to click on Add button.
Mail Recipients field: In this field enter an e-mail recipient in the format: mailto:username@hostname
This is a required field.
You can specify multiple e-mail recipients by entering the user names and hostnames in a comma-separated list. For example,mailto:username@hostname [,username_1@hostname_1]...[,username_n@hostname_n]
Only the first mail recipient needs to be prefixed with the text "mailto:".
SMTP Server field: select the name of the SMTP Server for the outgoing e-mail. This field is not required if a mail session is selected in the next step.
Mail Session field: select an available mail session. This field is not required if an SMTP Server is selected in the previous step.
From Name field: Provide a sender's name for the alert notification. This field is optional.
From Address field: Provide a valid e-mail address. This field is required if a value for "From Name" field is specified.
Reply To Name field: Provide a name to which a reply may be addressed. This field is optional.
Reply To Address field: Provide an e-mail address to which a reply may be sent. This field is required if a value for "Reply To Name" field is specified.
Connection Timeout field: Enter the number of seconds a connection must wait for a response from the server before timing out. The default value is 0.
Request Encoding field: Enter a character set encoding value. The default encoding value is iso-8859-1.
Specify all these values and save your alert destination.
Now go to proxy service message flow and add an Alert activity to generate the alert. To add an alert activity, go to Reporting à Alert.
Click on destination link and choose earlier created alert destination.
Click on expression and specify fault context variable since we have added this alert in error handler but you can pass any context variable in the alert as we send this fault message to alert destination.
Also choose the level of severity from drop down.
These alerts you can see in OSB console and whatever action you choose in alert destination, that alert message will flow there.