Below is the java file AlarmAction.java i have also added the
public class AlarmAction implements Action { | private static final String JMS_ALARM_CFG = "AlarmMgrRecvQueue.xml"; | private static Category logger = Category.getInstance(AlarmAction.class.getName()); | private static Sender eventSender; | private static boolean initialized = false; | | private HashMap map = null; | | public AlarmAction(String cid) { | map = new HashMap(); | map.put("CID", cid); | if (!initialized) { | try { | init(); | initialized = true; | } | catch (Exception e) { | // ignore - it'll be detected later in act() | logger.error(Utility.getStackTrace(e)); | } | } | } | | public void setExpiration(Date d) { | map.put("TIMESTAMP", d); | } | | public void setUserId(String uid) { | map.put("USERID", uid); | } | | public void setEventObject(Object o) { | String key = "EventObject"; | if (o instanceof WFWorkItem) { | WFWorkItem wfwi = (WFWorkItem)o; | String id = (new Long(wfwi.getId())).toString(); | WFWorkItemRef wfwir = new WFWorkItemRef(id); | map.put(key, wfwir); | } | else { | map.put(key, o); | } | } | | public void addProperty(String key, Object value) { | if (key != null) | map.put(key, value); | } | | private synchronized void init() throws Exception { | logger.debug("In init()..."); | Properties globalProps = Utility.getTLProps(true); | String tl_dom = globalProps.getProperty("tl_domain"); | eventSender = new Sender(); | if (eventSender.init(tl_dom + "/" + JMS_ALARM_CFG) == false) | throw new TLException("Could not initialize Sender for: " + JMS_ALARM_CFG); | eventSender.start(); | } | | /** | * | * This evaluates every value in the stored HashMap, creates an ObjectMessage of type MSG_ADD_ALARM, | * and passes it to the AlarmMnager's queue. | * | */ | public void act() throws REException { | try { | if (!initialized) | throw new REException("Not initialized."); | | if (map.get("TIMESTAMP") == null || map.get("EventObject") == null) | throw new REException("Properties not set properly"); | | ObjectMessage omsg = null; | | synchronized (eventSender) { | omsg = eventSender.getObjectMessage(); | omsg.setStringProperty(AlarmManager.MSGTYPE, AlarmManager.MSG_ADD_ALARM); | omsg.setObject(map); | eventSender.sendObjectMessage(omsg); | } | } | catch (Exception e) { | logger.error(Utility.getStackTrace(e)); | throw new REException(e.getMessage()); | } | } | } | below is the AlarmMgrRecvQueue.xml which is used in the above java file <!DOCTYPE JMSConfig SYSTEM "JMSConfig.dtd"> | | <JMSConfig> | <Destination | destType="queue" | providerURL="jnp://localhost:3099" | connFactoryJNDIName="java:AlarmMgrConnectionFactory" | destJNDIName="queue/AlarmMgrRecvQueue" | timeToLive="1000000" | receiveTimeout="1000" | | /> | </JMSConfig> View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990930#3990930 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990930 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user