Index Changes

Difference between version and version     

Back to ESB Console Enable Alerting For Standalone Fuji, or ESB Console Enable Alerting For Standalone Fuji Info


At line 29 changed 2 lines.
09/17/2009 10:50 AM <DIR> .
09/17/2009 10:50 AM <DIR> ..
09/17/2009 11:16 AM <DIR> .
09/17/2009 11:16 AM <DIR> ..
At line 34 changed 2 lines.
09/03/2009 07:49 PM 803 run.bat
4 File(s) 723,315 bytes
05/14/2009 01:20 AM 360,075 jbi-admin-common.jar
09/17/2009 11:16 AM 787 run.bat
5 File(s) 1,083,374 bytes
At line 46 added 3 lines.
!!Step 2: - Run the Alert Client and start receiving alerts
Go into the client folder.
Run the run.bat batch file and follow the instructions. You should now be able to receive alerts as they are generated from your standalone Fuji instance.
At line 50 added 6 lines.
----
!!!Alerting Client Java Source Sample: TestAlertNotificationListener.java
----
This is the client sample to subscribe for alerts.
{{{
package org.glassfish.extended.management.sample.impl.alerts;
At line 57 added 235 lines.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.glassfish.openesb.extended.management.api.alerts.Alert;
import org.glassfish.openesb.extended.management.api.alerts.AlertNotificationService;
import org.glassfish.openesb.extended.management.api.alerts.AlertsManagementService;
import org.glassfish.openesb.extended.management.client.ExtendedManagementClient;
import org.glassfish.openesb.extended.management.client.ExtendedManagementClientFactory;
import org.glassfish.openesb.extended.management.common.ExtendedManagementRemoteException;
/**
*
* @author gopalan
*/
public class TestAlertNotificationListener {
String dasPort;
String dashostname;
String dasUser;
String dasPassword;
AlertsManagementService managementService;
AlertNotificationService notifService;
ExtendedManagementClient client;
String subscriptionID;
List idList = new ArrayList();
Map filterMap = new HashMap();
/**
* @throws ExtendedManagementRemoteException
*
*/
public TestAlertNotificationListener() throws ExtendedManagementRemoteException {
init();
}
public boolean init() throws ExtendedManagementRemoteException {
boolean valid = false;
dashostname = getUserInput(" enter DAS host name <localhost> :",
"localhost");
dasPort = getUserInput(" enter DAS http port <4848> :", "4848");
dasUser = getUserInput(" enter user name <admin> :", "admin");
dasPassword = getUserInput(" enter user password <adminadmin> :",
"adminadmin");
int port = new Integer(dasPort);
client = ExtendedManagementClientFactory.getInstance(dashostname, port,
dasUser, dasPassword);
if (client != null) {
System.out.println("Management Client is valid.");
valid = true;
managementService = client.getService(org.glassfish.openesb.extended.management.api.alerts.AlertsManagementService.class);
notifService = managementService.getAlertNotificationService();
if (notifService == null) {
valid = false;
System.out
.println("Could not obtain Alert Management Notification service");
}
} else {
System.out.println("Could not obtain the Management Client.");
valid = false;
}
return valid;
}
public String getUserInput(String message, String defaultValue) {
String returnvalue = "";
System.out.println(message);
try {
returnvalue = new BufferedReader(new InputStreamReader(System.in))
.readLine();
if (returnvalue.length() == 0) {
returnvalue = defaultValue;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return returnvalue;
}
public void subscribe(String[] targets) throws Exception {
subscriptionID = notifService.subscribe(new HashMap<String, String>(),
targets, this, "eventProcessCallBack", new Boolean(true), this,
"exceptionProcessCallBack");
System.err.println(" subcription id is " + subscriptionID);
}
public void eventProcessCallBack(Alert alert) {
System.out.println(" ---> alert received <-----");
System.out.println("alert date :" + alert.getAlertDateString());
System.out.println("alert severity :" + alert.getAlertSeverity());
System.out.println("alert message code :" + alert.getAlertMessageCode());
System.out.println("alert server name :" + alert.getAlertServer());
System.out.println("alert message details :"
+ alert.getAlertMessageDetails());
System.out.println("alert component name :" + alert.getAlertComponentName());
System.out.println("alert component project path :" + alert.getAlertComponentProjectPath());
System.out.println("alert component type :" + alert.getAlertComponentType());
System.out.println("alert deployment :" + alert.getAlertDeployment());
System.out.println("alert environment :" + alert.getAlertEnvironment());
System.out.println("alert logical host :" + alert.getAlertLogicalHost());
System.out.println("alert physical host :" + alert.getAlertPhysicalHost());
System.out.println("alert server type :" + alert.getAlertServerType());
System.out.println("alert state :" + alert.getAlertState());
System.out.println("alert status :" + alert.getAlertStatus());
System.out.println("alert type :" + alert.getAlertType());
}
public void exceptionProcessCallBack(Exception e) {
System.out.println("exception details :\n");
e.printStackTrace();
}
public void unsubscribe() {
if (subscriptionID == null) {
return;
}
String[] SubscriptionIDs = { subscriptionID };
try {
notifService.unsubscribe((String[]) SubscriptionIDs);
subscriptionID = null;
} catch (ExtendedManagementRemoteException exception) {
int index = 0;
String[] causes = exception.getCauseMessageTrace();
for (String cause : causes) {
System.out.println("Cause #" + (++index) + ": " + cause);
}
}
}
private void execCommand(String cmd) throws Exception {
try {
if (cmd.equalsIgnoreCase("reg")) {
subscribe(null);
} else if (cmd.equalsIgnoreCase("unreg")) {
unsubscribe();
}
} catch (ExtendedManagementRemoteException exception) {
int index = 0;
String[] causes = exception.getCauseMessageTrace();
if(causes != null) {
for (String cause : causes) {
System.out.println("Cause #" + (++index) + ": " + cause);
}
}
}
}
public String displayOptions() throws Exception {
String cmd = "";
init();
while (true) {
System.out
.println("valid opeartions:\n"
+ " REG - subscribe client for notification no filter and targets optional (comma delimited string) (can be called multiple time -return ID for each) \n"
+ " UNREG - unsubscribe client from receiving notification\n"
+ " EX - to exit the program ");
System.out.println("Please Select opertion:");
cmd = new BufferedReader(new InputStreamReader(System.in))
.readLine();
String[] validOption = { "reg", "unreg", "ex" };
boolean valid = false;
for (String option : validOption) {
String testCmd = cmd.toLowerCase();
if (testCmd.startsWith(option)) {
valid = true;
break;
}
}
if (!valid) {
System.out.println();
System.out.println();
System.out.println();
displayOptions();
} else {
System.out.println();
System.out.println();
System.out.println("the command is = " + cmd);
System.out.println();
System.out.println();
if (cmd.equalsIgnoreCase("ex")) {
unsubscribe();
System.exit(0);
} else {
execCommand(cmd);
}
}
}
}
/**
* @param args
*/
public static void main(String[] args) {
try {
TestAlertNotificationListener test = new TestAlertNotificationListener();
test.displayOptions();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}}}
\\
\\

JSPWiki v2.4.100
[RSS]
« Home Index Changes Prefs
This page (revision-5) was last changed on 04-Feb-10 23:41 PM, -0800 by newacct